diff --git a/BUILD b/BUILD index a462935cac3f..8ab4cb413e92 100644 --- a/BUILD +++ b/BUILD @@ -524,6 +524,7 @@ RELATIVE_TEST_PROTOS = [ "google/protobuf/unittest_proto3_arena.proto", "google/protobuf/unittest_proto3_arena_lite.proto", "google/protobuf/unittest_proto3_lite.proto", + "google/protobuf/unittest_proto3_optional.proto", "google/protobuf/unittest_well_known_types.proto", "google/protobuf/util/internal/testdata/anys.proto", "google/protobuf/util/internal/testdata/books.proto", diff --git a/benchmarks/datasets/google_message2/benchmark_message2.proto b/benchmarks/datasets/google_message2/benchmark_message2.proto index 7c10302e82a2..500c5d699f1e 100644 --- a/benchmarks/datasets/google_message2/benchmark_message2.proto +++ b/benchmarks/datasets/google_message2/benchmark_message2.proto @@ -28,6 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + // Benchmark messages for proto2. syntax = "proto2"; diff --git a/benchmarks/datasets/google_message3/benchmark_message3.proto b/benchmarks/datasets/google_message3/benchmark_message3.proto index e6beac989555..82422f924ea4 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3.proto @@ -28,8 +28,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_1.proto"; import "datasets/google_message3/benchmark_message3_2.proto"; import "datasets/google_message3/benchmark_message3_3.proto"; @@ -37,7 +41,6 @@ import "datasets/google_message3/benchmark_message3_4.proto"; import "datasets/google_message3/benchmark_message3_5.proto"; import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_1.proto b/benchmarks/datasets/google_message3/benchmark_message3_1.proto index af8f4641cc65..1ee5c9eca624 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_1.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_1.proto @@ -28,14 +28,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_2.proto"; import "datasets/google_message3/benchmark_message3_3.proto"; import "datasets/google_message3/benchmark_message3_5.proto"; import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; @@ -130,15 +133,13 @@ message Message36876 { optional int32 field37047 = 115; optional int32 field37048 = 157; } - repeated group Message36878 = 168 { - } + repeated group Message36878 = 168 {} repeated group Message36879 = 55 { required string field37050 = 56; optional int32 field37051 = 69; } repeated .benchmarks.google_message3.UnusedEmptyMessage field36984 = 78; - optional group Message36880 = 137 { - } + optional group Message36880 = 137 {} optional uint64 field36986 = 59; optional bytes field36987 = 121; optional .benchmarks.google_message3.UnusedEmptyMessage field36988 = 2; @@ -154,11 +155,9 @@ message Message36876 { optional int32 field36998 = 47; optional int32 field36999 = 48; optional .benchmarks.google_message3.UnusedEmptyMessage field37000 = 68; - repeated group Message36881 = 23 { - } + repeated group Message36881 = 23 {} optional .benchmarks.google_message3.Message4144 field37002 = 125; - repeated group Message36882 = 35 { - } + repeated group Message36882 = 35 {} optional .benchmarks.google_message3.UnusedEmptyMessage field37004 = 49; optional .benchmarks.google_message3.Message18921 field37005 = 52; optional .benchmarks.google_message3.Message36858 field37006 = 46; @@ -171,20 +170,15 @@ message Message36876 { optional .benchmarks.google_message3.Message0 field37013 = 143; optional .benchmarks.google_message3.UnusedEmptyMessage field37014 = 53; optional .benchmarks.google_message3.Message36869 field37015 = 15; - optional group Message36883 = 3 { - } - repeated group Message36884 = 16 { - } - repeated group Message36885 = 27 { - } - optional group Message36886 = 32 { - } + optional group Message36883 = 3 {} + repeated group Message36884 = 16 {} + repeated group Message36885 = 27 {} + optional group Message36886 = 32 {} repeated .benchmarks.google_message3.UnusedEnum field37020 = 71; repeated int32 field37021 = 70; optional .benchmarks.google_message3.UnusedEmptyMessage field37022 = 66; optional .benchmarks.google_message3.Message13090 field37023 = 67; - optional group Message36887 = 62 { - } + optional group Message36887 = 62 {} repeated .benchmarks.google_message3.Message10155 field37025 = 50; repeated .benchmarks.google_message3.Message11874 field37026 = 151; optional string field37027 = 12; @@ -232,8 +226,7 @@ message Message36876 { optional int32 field37118 = 160; repeated string field37119 = 161; } - repeated group Message36910 = 119 { - } + repeated group Message36910 = 119 {} optional group Message36911 = 126 { optional .benchmarks.google_message3.UnusedEmptyMessage field37121 = 127; optional .benchmarks.google_message3.Message35538 field37122 = 130; @@ -247,11 +240,9 @@ message Message36876 { optional .benchmarks.google_message3.UnusedEmptyMessage field37042 = 155; } -message Message1328 { -} +message Message1328 {} -message Message6850 { -} +message Message6850 {} message Message6863 { optional .benchmarks.google_message3.Enum6858 field6931 = 1; @@ -289,8 +280,7 @@ message Message6863 { optional bool field6963 = 34; } -message Message6871 { -} +message Message6871 {} message Message7547 { required bytes field7549 = 1; @@ -312,8 +302,7 @@ message Message7648 { optional bool field7680 = 12; } -message Message7865 { -} +message Message7865 {} message Message7928 { optional string field7940 = 1; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_2.proto b/benchmarks/datasets/google_message3/benchmark_message3_2.proto index 2596daac2019..d123a7204caa 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_2.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_2.proto @@ -28,14 +28,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_3.proto"; import "datasets/google_message3/benchmark_message3_4.proto"; import "datasets/google_message3/benchmark_message3_5.proto"; import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; @@ -109,8 +112,7 @@ message Message24391 { repeated string field24655 = 6; } -message Message27454 { -} +message Message27454 {} message Message27357 { optional string field27410 = 1; @@ -192,8 +194,7 @@ message Message36869 { } message Message33968 { - repeated group Message33969 = 1 { - } + repeated group Message33969 = 1 {} repeated .benchmarks.google_message3.Message33958 field33989 = 3; optional .benchmarks.google_message3.UnusedEmptyMessage field33990 = 106; optional bool field33991 = 108; @@ -268,8 +269,7 @@ message Message35573 { optional string field35696 = 1000; optional string field35697 = 1004; optional int32 field35698 = 1003; - repeated group Message35574 = 1012 { - } + repeated group Message35574 = 1012 {} optional int64 field35700 = 1011; optional int64 field35701 = 1005; optional int64 field35702 = 1006; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_3.proto b/benchmarks/datasets/google_message3/benchmark_message3_3.proto index 0765a79edb8c..2e534a67d6c5 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_3.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_3.proto @@ -28,13 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_4.proto"; import "datasets/google_message3/benchmark_message3_5.proto"; import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; @@ -96,8 +99,7 @@ message Message2356 { optional bytes field2410 = 124; } optional string field2389 = 120; - optional group Message2358 = 107 { - } + optional group Message2358 = 107 {} repeated group Message2359 = 40 { optional string field2413 = 41; optional string field2414 = 42; @@ -438,8 +440,7 @@ message Message16724 { optional bool field16773 = 13; } -message Message17728 { -} +message Message17728 {} message Message24356 { optional string field24559 = 1; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_4.proto b/benchmarks/datasets/google_message3/benchmark_message3_4.proto index ceb14cca9a34..b30414819815 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_4.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_4.proto @@ -28,19 +28,21 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_5.proto"; import "datasets/google_message3/benchmark_message3_6.proto"; import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; -message Message24346 { -} +message Message24346 {} message Message24401 { optional .benchmarks.google_message3.Message24400 field24679 = 1; @@ -219,12 +221,9 @@ message Message13083 { optional float field13099 = 45; optional uint64 field13100 = 46; optional float field13101 = 47; - optional group Message13085 = 16 { - } - repeated group Message13086 = 23 { - } - repeated group Message13087 = 29 { - } + optional group Message13085 = 16 {} + repeated group Message13086 = 23 {} + repeated group Message13087 = 29 {} optional .benchmarks.google_message3.UnusedEmptyMessage field13105 = 43; } @@ -292,12 +291,10 @@ message Message16816 { optional float field16826 = 1; optional .benchmarks.google_message3.Enum16819 field16827 = 2; optional float field16828 = 3; - repeated group Message16817 = 4 { - } + repeated group Message16817 = 4 {} optional bool field16830 = 7; optional bool field16831 = 8; - repeated group Message16818 = 12 { - } + repeated group Message16818 = 12 {} optional string field16833 = 10; optional bool field16834 = 13; optional bool field16835 = 14; @@ -338,11 +335,9 @@ message Message1374 { optional string field1376 = 2; } -message Message18943 { -} +message Message18943 {} -message Message18944 { -} +message Message18944 {} message Message18856 { optional string field18857 = 1; @@ -466,8 +461,7 @@ message Message8475 { optional int64 field8482 = 2; } -message Message12559 { -} +message Message12559 {} message Message12817 { optional int32 field12826 = 1; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_5.proto b/benchmarks/datasets/google_message3/benchmark_message3_5.proto index e4b6c0ad408f..e72d7ee85af4 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_5.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_5.proto @@ -28,21 +28,22 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_6.proto"; import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; -message Message24377 { -} +message Message24377 {} -message Message24378 { -} +message Message24378 {} message Message24400 { optional int32 field24674 = 1; @@ -52,11 +53,9 @@ message Message24400 { optional int32 field24678 = 5; } -message Message24380 { -} +message Message24380 {} -message Message24381 { -} +message Message24381 {} message Message719 { repeated string field881 = 1; @@ -133,6 +132,7 @@ message Message697 { message Message0 { option message_set_wire_format = true; + extensions 4 to 2147483646; } @@ -223,7 +223,8 @@ message Message10155 { optional fixed64 field10232 = 13; optional fixed64 field10233 = 20; optional bool field10234 = 79; - repeated .benchmarks.google_message3.Enum10167 field10235 = 80 [packed = true]; + repeated .benchmarks.google_message3.Enum10167 field10235 = 80 + [packed = true]; optional int32 field10236 = 14; optional int32 field10237 = 15; optional int32 field10238 = 28; @@ -315,25 +316,20 @@ message Message13145 { extensions 1000 to 536870911; } -message Message16686 { -} +message Message16686 {} message Message12796 { repeated fixed64 field12800 = 1; optional uint64 field12801 = 2; } -message Message6722 { -} +message Message6722 {} -message Message6727 { -} +message Message6727 {} -message Message6724 { -} +message Message6724 {} -message Message6735 { -} +message Message6735 {} message Message8183 { optional string field8226 = 1; @@ -355,8 +351,7 @@ message Message8301 { extensions 64 to 536870911; } -message Message8456 { -} +message Message8456 {} message Message8302 { optional string field8339 = 1; @@ -383,8 +378,7 @@ message Message8302 { extensions 64 to 536870911; } -message Message8457 { -} +message Message8457 {} message Message8449 { optional string field8458 = 1; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_6.proto b/benchmarks/datasets/google_message3/benchmark_message3_6.proto index c9e8f062d96a..c766f7c2efb0 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_6.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_6.proto @@ -28,17 +28,19 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message3; + import "datasets/google_message3/benchmark_message3_7.proto"; import "datasets/google_message3/benchmark_message3_8.proto"; -package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; -message Message10576 { -} +message Message10576 {} message Message10154 { optional bytes field10192 = 1; @@ -373,8 +375,7 @@ message Message8939 { optional string field9012 = 3; repeated string field9013 = 4; optional string field9014 = 5; - repeated group Message8940 = 11 { - } + repeated group Message8940 = 11 {} optional int64 field9016 = 21; optional int64 field9017 = 22; optional int64 field9018 = 23; @@ -453,8 +454,7 @@ message Message9627 { optional float field9672 = 5; } -message Message11020 { -} +message Message11020 {} message Message11013 { optional bytes field11757 = 19; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_7.proto b/benchmarks/datasets/google_message3/benchmark_message3_7.proto index e0d81c35249a..0f8f10cd3732 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_7.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_7.proto @@ -35,8 +35,7 @@ package benchmarks.google_message3; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; -message Message11018 { -} +message Message11018 {} message Message10800 { optional string field10808 = 1; @@ -45,8 +44,7 @@ message Message10800 { optional float field10811 = 4; } -message Message10802 { -} +message Message10802 {} message Message10748 { optional string field10750 = 1; @@ -69,16 +67,14 @@ message Message708 { repeated string field828 = 5; } -message Message8942 { -} +message Message8942 {} message Message11011 { required bytes field11752 = 1; required bytes field11753 = 2; } -message UnusedEmptyMessage { -} +message UnusedEmptyMessage {} message Message741 { repeated string field936 = 1; diff --git a/benchmarks/datasets/google_message3/benchmark_message3_8.proto b/benchmarks/datasets/google_message3/benchmark_message3_8.proto index 0b95d6330f52..68fe8e901a6c 100644 --- a/benchmarks/datasets/google_message3/benchmark_message3_8.proto +++ b/benchmarks/datasets/google_message3/benchmark_message3_8.proto @@ -639,9 +639,7 @@ enum Enum10325 { ENUM_VALUE10334 = 8; } -enum Enum10335 { - ENUM_VALUE10336 = 0; -} +enum Enum10335 { ENUM_VALUE10336 = 0; } enum Enum10337 { ENUM_VALUE10338 = 0; @@ -1887,9 +1885,7 @@ enum Enum33960 { ENUM_VALUE33967 = 6; } -enum Enum34388 { - ENUM_VALUE34389 = 1; -} +enum Enum34388 { ENUM_VALUE34389 = 1; } enum Enum35477 { ENUM_VALUE35478 = 4; diff --git a/benchmarks/datasets/google_message4/benchmark_message4.proto b/benchmarks/datasets/google_message4/benchmark_message4.proto index 9b84ee744fd5..424ed1081169 100644 --- a/benchmarks/datasets/google_message4/benchmark_message4.proto +++ b/benchmarks/datasets/google_message4/benchmark_message4.proto @@ -28,12 +28,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message4; + import "datasets/google_message4/benchmark_message4_1.proto"; import "datasets/google_message4/benchmark_message4_2.proto"; import "datasets/google_message4/benchmark_message4_3.proto"; -package benchmarks.google_message4; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; @@ -176,8 +179,7 @@ message Message176 { optional .benchmarks.google_message4.UnusedEnum field455 = 37; optional .benchmarks.google_message4.UnusedEnum field456 = 34; optional int32 field457 = 35; - repeated group Message178 = 101 { - } + repeated group Message178 = 101 {} optional bool field459 = 52; optional uint64 field460 = 58; optional uint64 field461 = 59; @@ -458,10 +460,8 @@ message Message2356 { optional bytes field2410 = 124; } optional string field2389 = 120; - optional group Message2358 = 107 { - } - repeated group Message2359 = 40 { - } + optional group Message2358 = 107 {} + repeated group Message2359 = 40 {} optional int32 field2392 = 50; optional .benchmarks.google_message4.UnusedEmptyMessage field2393 = 60; optional .benchmarks.google_message4.UnusedEmptyMessage field2394 = 70; @@ -473,6 +473,7 @@ message Message2356 { message Message0 { option message_set_wire_format = true; + extensions 4 to 2147483646; } diff --git a/benchmarks/datasets/google_message4/benchmark_message4_1.proto b/benchmarks/datasets/google_message4/benchmark_message4_1.proto index 3a5e96985413..c5deecd0df84 100644 --- a/benchmarks/datasets/google_message4/benchmark_message4_1.proto +++ b/benchmarks/datasets/google_message4/benchmark_message4_1.proto @@ -28,11 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: ALLOW_GROUPS + syntax = "proto2"; +package benchmarks.google_message4; + import "datasets/google_message4/benchmark_message4_2.proto"; import "datasets/google_message4/benchmark_message4_3.proto"; -package benchmarks.google_message4; option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; @@ -46,8 +49,7 @@ message Message12686 { optional .benchmarks.google_message4.Message12685 field12700 = 2; } -message Message11949 { -} +message Message11949 {} message Message11975 { optional string field11992 = 1; @@ -134,8 +136,7 @@ message Message3061 { } optional .benchmarks.google_message4.UnusedEmptyMessage field3315 = 39; optional int32 field3316 = 76; - optional group Message3065 = 63 { - } + optional group Message3065 = 63 {} optional .benchmarks.google_message4.Enum2806 field3318 = 54; optional int32 field3319 = 46; repeated string field3320 = 24; @@ -163,8 +164,7 @@ message Message3061 { optional int32 field3333 = 17; } -message Message12949 { -} +message Message12949 {} message Message8572 { optional bytes field8647 = 1; @@ -269,11 +269,9 @@ message Message12825 { repeated .benchmarks.google_message4.UnusedEmptyMessage field12868 = 7; } -message Message8590 { -} +message Message8590 {} -message Message8587 { -} +message Message8587 {} message Message1374 { required string field1375 = 1; @@ -453,8 +451,7 @@ message Message3052 { optional string field3262 = 9; } -message Message8575 { -} +message Message8575 {} message Message7843 { optional bool field7844 = 5; diff --git a/benchmarks/datasets/google_message4/benchmark_message4_2.proto b/benchmarks/datasets/google_message4/benchmark_message4_2.proto index a5c6eff74c9b..0c4cdfd853a1 100644 --- a/benchmarks/datasets/google_message4/benchmark_message4_2.proto +++ b/benchmarks/datasets/google_message4/benchmark_message4_2.proto @@ -30,9 +30,10 @@ syntax = "proto2"; -import "datasets/google_message4/benchmark_message4_3.proto"; package benchmarks.google_message4; +import "datasets/google_message4/benchmark_message4_3.proto"; + option cc_enable_arenas = true; option java_package = "com.google.protobuf.benchmarks"; @@ -132,8 +133,7 @@ message Message5881 { optional .benchmarks.google_message4.Message5880 field5902 = 6; } -message Message6110 { -} +message Message6110 {} message Message6107 { optional .benchmarks.google_message4.Message4016 field6134 = 1; @@ -211,8 +211,7 @@ message Message3850 { optional bool field3929 = 14; } -message Message7865 { -} +message Message7865 {} message Message7511 { optional bool field7523 = 1; @@ -224,8 +223,7 @@ message Message7511 { optional int32 field7529 = 7; } -message Message3920 { -} +message Message3920 {} message Message7928 { optional string field7940 = 1; @@ -261,8 +259,7 @@ message Message6054 { optional string field6090 = 2; } -message Message6127 { -} +message Message6127 {} message Message6052 { required string field6084 = 1; @@ -302,8 +299,7 @@ message Message4016 { required int32 field4020 = 4; } -message Message6108 { -} +message Message6108 {} message Message5907 { optional .benchmarks.google_message4.Message5903 field5967 = 1; @@ -312,8 +308,7 @@ message Message5907 { optional .benchmarks.google_message4.Message5903 field5970 = 4; } -message UnusedEmptyMessage { -} +message UnusedEmptyMessage {} message Message5903 { required int32 field5965 = 1; diff --git a/benchmarks/datasets/google_message4/benchmark_message4_3.proto b/benchmarks/datasets/google_message4/benchmark_message4_3.proto index 5372a0f0f98b..42e254b762f4 100644 --- a/benchmarks/datasets/google_message4/benchmark_message4_3.proto +++ b/benchmarks/datasets/google_message4/benchmark_message4_3.proto @@ -77,6 +77,7 @@ enum Enum2806 { enum Enum2851 { option allow_alias = true; + ENUM_VALUE2852 = 0; ENUM_VALUE2853 = 0; ENUM_VALUE2854 = 1; @@ -747,9 +748,7 @@ enum Enum10325 { ENUM_VALUE10334 = 8; } -enum Enum10335 { - ENUM_VALUE10336 = 0; -} +enum Enum10335 { ENUM_VALUE10336 = 0; } enum Enum10337 { ENUM_VALUE10338 = 0; diff --git a/cmake/tests.cmake b/cmake/tests.cmake index d4b47c54e500..c3ef7301f55e 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -67,6 +67,7 @@ set(tests_protos google/protobuf/unittest_proto3_arena.proto google/protobuf/unittest_proto3_arena_lite.proto google/protobuf/unittest_proto3_lite.proto + google/protobuf/unittest_proto3_optional.proto google/protobuf/unittest_well_known_types.proto google/protobuf/util/internal/testdata/anys.proto google/protobuf/util/internal/testdata/books.proto @@ -93,6 +94,7 @@ macro(compile_proto_file filename) COMMAND protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto --proto_path=${protobuf_source_dir}/src --cpp_out=${protobuf_source_dir}/src + --experimental_allow_proto3_optional ) endmacro(compile_proto_file) diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index f8665e2c3e0e..93f43dc12b0d 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -2156,12 +2156,12 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForNonRepeatedTypes() { { TestAllTypesProto3 message; message.set_optional_double( - WireFormatLite::DecodeDouble(0x7FFA123456789ABCLL)); + WireFormatLite::DecodeDouble(int64{0x7FFA123456789ABC})); RunValidJsonTestWithProtobufInput( "DoubleFieldNormalizeQuietNan", REQUIRED, message, "optional_double: nan"); message.set_optional_double( - WireFormatLite::DecodeDouble(0xFFFBCBA987654321LL)); + WireFormatLite::DecodeDouble(uint64{0xFFFBCBA987654321})); RunValidJsonTestWithProtobufInput( "DoubleFieldNormalizeSignalingNan", REQUIRED, message, "optional_double: nan"); diff --git a/conformance/conformance_python.py b/conformance/conformance_python.py index 37ee36e24c51..3949cd9603ec 100755 --- a/conformance/conformance_python.py +++ b/conformance/conformance_python.py @@ -157,7 +157,8 @@ def do_test(request): elif request.requested_output_format == conformance_pb2.JSON: try: - response.json_payload = json_format.MessageToJson(test_message) + response.json_payload = json_format.MessageToJson( + test_message, float_precision=None) except Exception as e: response.serialize_error = str(e) return response diff --git a/conformance/text_format_conformance_suite.cc b/conformance/text_format_conformance_suite.cc index fc7b2515230b..6574b10c50f4 100644 --- a/conformance/text_format_conformance_suite.cc +++ b/conformance/text_format_conformance_suite.cc @@ -313,6 +313,66 @@ void TextFormatConformanceTestSuite::RunSuiteImpl() { } } )"); + + // Map fields + TestAllTypesProto3 prototype; + (*prototype.mutable_map_string_string())["c"] = "value"; + (*prototype.mutable_map_string_string())["b"] = "value"; + (*prototype.mutable_map_string_string())["a"] = "value"; + RunValidTextFormatTestWithMessage("AlphabeticallySortedMapStringKeys", + REQUIRED, + R"( + map_string_string { + key: "a" + value: "value" + } + map_string_string { + key: "b" + value: "value" + } + map_string_string { + key: "c" + value: "value" + } + )", + prototype); + + prototype.Clear(); + (*prototype.mutable_map_int32_int32())[3] = 0; + (*prototype.mutable_map_int32_int32())[2] = 0; + (*prototype.mutable_map_int32_int32())[1] = 0; + RunValidTextFormatTestWithMessage("AlphabeticallySortedMapIntKeys", REQUIRED, + R"( + map_int32_int32 { + key: 1 + value: 0 + } + map_int32_int32 { + key: 2 + value: 0 + } + map_int32_int32 { + key: 3 + value: 0 + } + )", + prototype); + + prototype.Clear(); + (*prototype.mutable_map_bool_bool())[true] = false; + (*prototype.mutable_map_bool_bool())[false] = false; + RunValidTextFormatTestWithMessage("AlphabeticallySortedMapBoolKeys", REQUIRED, + R"( + map_bool_bool { + key: false + value: false + } + map_bool_bool { + key: true + value: false + } + )", + prototype); } } // namespace protobuf diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs index e55df12f2ec8..a35b6e0fe3c8 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs @@ -4314,7 +4314,7 @@ public sealed partial class RepeatedGroup : pb::IMessage { } /// - /// This proto includes a recusively nested message. + /// This proto includes a recursively nested message. /// public sealed partial class NestedTestAllTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index d00db7fdeb76..425d70857e7c 100644 Binary files a/csharp/src/Google.Protobuf.Test/testprotos.pb and b/csharp/src/Google.Protobuf.Test/testprotos.pb differ diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 59c260018c04..8b39573d7c4b 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -54,7 +54,7 @@ public static partial class DescriptorReflection { "b2J1Zi5FeHRlbnNpb25SYW5nZU9wdGlvbnMaKwoNUmVzZXJ2ZWRSYW5nZRIN", "CgVzdGFydBgBIAEoBRILCgNlbmQYAiABKAUiZwoVRXh0ZW5zaW9uUmFuZ2VP", "cHRpb25zEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2ds", - "ZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIivAUK", + "ZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi1QUK", "FEZpZWxkRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkSDgoGbnVtYmVy", "GAMgASgFEjoKBWxhYmVsGAQgASgOMisuZ29vZ2xlLnByb3RvYnVmLkZpZWxk", "RGVzY3JpcHRvclByb3RvLkxhYmVsEjgKBHR5cGUYBSABKA4yKi5nb29nbGUu", @@ -62,102 +62,103 @@ public static partial class DescriptorReflection { "bWUYBiABKAkSEAoIZXh0ZW5kZWUYAiABKAkSFQoNZGVmYXVsdF92YWx1ZRgH", "IAEoCRITCgtvbmVvZl9pbmRleBgJIAEoBRIRCglqc29uX25hbWUYCiABKAkS", "LgoHb3B0aW9ucxgIIAEoCzIdLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlv", - "bnMitgIKBFR5cGUSDwoLVFlQRV9ET1VCTEUQARIOCgpUWVBFX0ZMT0FUEAIS", - "DgoKVFlQRV9JTlQ2NBADEg8KC1RZUEVfVUlOVDY0EAQSDgoKVFlQRV9JTlQz", - "MhAFEhAKDFRZUEVfRklYRUQ2NBAGEhAKDFRZUEVfRklYRUQzMhAHEg0KCVRZ", - "UEVfQk9PTBAIEg8KC1RZUEVfU1RSSU5HEAkSDgoKVFlQRV9HUk9VUBAKEhAK", - "DFRZUEVfTUVTU0FHRRALEg4KClRZUEVfQllURVMQDBIPCgtUWVBFX1VJTlQz", - "MhANEg0KCVRZUEVfRU5VTRAOEhEKDVRZUEVfU0ZJWEVEMzIQDxIRCg1UWVBF", - "X1NGSVhFRDY0EBASDwoLVFlQRV9TSU5UMzIQERIPCgtUWVBFX1NJTlQ2NBAS", - "IkMKBUxhYmVsEhIKDkxBQkVMX09QVElPTkFMEAESEgoOTEFCRUxfUkVRVUlS", - "RUQQAhISCg5MQUJFTF9SRVBFQVRFRBADIlQKFE9uZW9mRGVzY3JpcHRvclBy", - "b3RvEgwKBG5hbWUYASABKAkSLgoHb3B0aW9ucxgCIAEoCzIdLmdvb2dsZS5w", - "cm90b2J1Zi5PbmVvZk9wdGlvbnMipAIKE0VudW1EZXNjcmlwdG9yUHJvdG8S", - "DAoEbmFtZRgBIAEoCRI4CgV2YWx1ZRgCIAMoCzIpLmdvb2dsZS5wcm90b2J1", - "Zi5FbnVtVmFsdWVEZXNjcmlwdG9yUHJvdG8SLQoHb3B0aW9ucxgDIAEoCzIc", - "Lmdvb2dsZS5wcm90b2J1Zi5FbnVtT3B0aW9ucxJOCg5yZXNlcnZlZF9yYW5n", - "ZRgEIAMoCzI2Lmdvb2dsZS5wcm90b2J1Zi5FbnVtRGVzY3JpcHRvclByb3Rv", - "LkVudW1SZXNlcnZlZFJhbmdlEhUKDXJlc2VydmVkX25hbWUYBSADKAkaLwoR", - "RW51bVJlc2VydmVkUmFuZ2USDQoFc3RhcnQYASABKAUSCwoDZW5kGAIgASgF", - "ImwKGEVudW1WYWx1ZURlc2NyaXB0b3JQcm90bxIMCgRuYW1lGAEgASgJEg4K", - "Bm51bWJlchgCIAEoBRIyCgdvcHRpb25zGAMgASgLMiEuZ29vZ2xlLnByb3Rv", - "YnVmLkVudW1WYWx1ZU9wdGlvbnMikAEKFlNlcnZpY2VEZXNjcmlwdG9yUHJv", - "dG8SDAoEbmFtZRgBIAEoCRI2CgZtZXRob2QYAiADKAsyJi5nb29nbGUucHJv", - "dG9idWYuTWV0aG9kRGVzY3JpcHRvclByb3RvEjAKB29wdGlvbnMYAyABKAsy", - "Hy5nb29nbGUucHJvdG9idWYuU2VydmljZU9wdGlvbnMiwQEKFU1ldGhvZERl", - "c2NyaXB0b3JQcm90bxIMCgRuYW1lGAEgASgJEhIKCmlucHV0X3R5cGUYAiAB", - "KAkSEwoLb3V0cHV0X3R5cGUYAyABKAkSLwoHb3B0aW9ucxgEIAEoCzIeLmdv", - "b2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zEh8KEGNsaWVudF9zdHJlYW1p", - "bmcYBSABKAg6BWZhbHNlEh8KEHNlcnZlcl9zdHJlYW1pbmcYBiABKAg6BWZh", - "bHNlIqYGCgtGaWxlT3B0aW9ucxIUCgxqYXZhX3BhY2thZ2UYASABKAkSHAoU", - "amF2YV9vdXRlcl9jbGFzc25hbWUYCCABKAkSIgoTamF2YV9tdWx0aXBsZV9m", - "aWxlcxgKIAEoCDoFZmFsc2USKQodamF2YV9nZW5lcmF0ZV9lcXVhbHNfYW5k", - "X2hhc2gYFCABKAhCAhgBEiUKFmphdmFfc3RyaW5nX2NoZWNrX3V0ZjgYGyAB", - "KAg6BWZhbHNlEkYKDG9wdGltaXplX2ZvchgJIAEoDjIpLmdvb2dsZS5wcm90", - "b2J1Zi5GaWxlT3B0aW9ucy5PcHRpbWl6ZU1vZGU6BVNQRUVEEhIKCmdvX3Bh", - "Y2thZ2UYCyABKAkSIgoTY2NfZ2VuZXJpY19zZXJ2aWNlcxgQIAEoCDoFZmFs", - "c2USJAoVamF2YV9nZW5lcmljX3NlcnZpY2VzGBEgASgIOgVmYWxzZRIiChNw", - "eV9nZW5lcmljX3NlcnZpY2VzGBIgASgIOgVmYWxzZRIjChRwaHBfZ2VuZXJp", - "Y19zZXJ2aWNlcxgqIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgXIAEoCDoF", - "ZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFsc2USGQoRb2Jq", - "Y19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVzcGFjZRglIAEo", - "CRIUCgxzd2lmdF9wcmVmaXgYJyABKAkSGAoQcGhwX2NsYXNzX3ByZWZpeBgo", - "IAEoCRIVCg1waHBfbmFtZXNwYWNlGCkgASgJEh4KFnBocF9tZXRhZGF0YV9u", - "YW1lc3BhY2UYLCABKAkSFAoMcnVieV9wYWNrYWdlGC0gASgJEkMKFHVuaW50", - "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu", - "dGVycHJldGVkT3B0aW9uIjoKDE9wdGltaXplTW9kZRIJCgVTUEVFRBABEg0K", - "CUNPREVfU0laRRACEhAKDExJVEVfUlVOVElNRRADKgkI6AcQgICAgAJKBAgm", - "ECci8gEKDk1lc3NhZ2VPcHRpb25zEiYKF21lc3NhZ2Vfc2V0X3dpcmVfZm9y", - "bWF0GAEgASgIOgVmYWxzZRIuCh9ub19zdGFuZGFyZF9kZXNjcmlwdG9yX2Fj", - "Y2Vzc29yGAIgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxz", - "ZRIRCgltYXBfZW50cnkYByABKAgSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y", - "5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24q", - "CQjoBxCAgICAAkoECAgQCUoECAkQCiKeAwoMRmllbGRPcHRpb25zEjoKBWN0", - "eXBlGAEgASgOMiMuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlw", - "ZToGU1RSSU5HEg4KBnBhY2tlZBgCIAEoCBI/CgZqc3R5cGUYBiABKA4yJC5n", - "b29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkpTVHlwZToJSlNfTk9STUFM", - "EhMKBGxhenkYBSABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZh", - "bHNlEhMKBHdlYWsYCiABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0", - "aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0", - "aW9uIi8KBUNUeXBlEgoKBlNUUklORxAAEggKBENPUkQQARIQCgxTVFJJTkdf", - "UElFQ0UQAiI1CgZKU1R5cGUSDQoJSlNfTk9STUFMEAASDQoJSlNfU1RSSU5H", - "EAESDQoJSlNfTlVNQkVSEAIqCQjoBxCAgICAAkoECAQQBSJeCgxPbmVvZk9w", - "dGlvbnMSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xl", - "LnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoL", - "RW51bU9wdGlvbnMSEwoLYWxsb3dfYWxpYXMYAiABKAgSGQoKZGVwcmVjYXRl", - "ZBgDIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygL", - "MiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCA", - "gICAAkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQY", - "ASABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIk", - "Lmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICA", - "gAIiewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFs", - "c2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy", - "b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKtAgoNTWV0", - "aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJfChFpZGVt", - "cG90ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RP", - "cHRpb25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VOS05PV04S", + "bnMSFwoPcHJvdG8zX29wdGlvbmFsGBEgASgIIrYCCgRUeXBlEg8KC1RZUEVf", + "RE9VQkxFEAESDgoKVFlQRV9GTE9BVBACEg4KClRZUEVfSU5UNjQQAxIPCgtU", + "WVBFX1VJTlQ2NBAEEg4KClRZUEVfSU5UMzIQBRIQCgxUWVBFX0ZJWEVENjQQ", + "BhIQCgxUWVBFX0ZJWEVEMzIQBxINCglUWVBFX0JPT0wQCBIPCgtUWVBFX1NU", + "UklORxAJEg4KClRZUEVfR1JPVVAQChIQCgxUWVBFX01FU1NBR0UQCxIOCgpU", + "WVBFX0JZVEVTEAwSDwoLVFlQRV9VSU5UMzIQDRINCglUWVBFX0VOVU0QDhIR", + "Cg1UWVBFX1NGSVhFRDMyEA8SEQoNVFlQRV9TRklYRUQ2NBAQEg8KC1RZUEVf", + "U0lOVDMyEBESDwoLVFlQRV9TSU5UNjQQEiJDCgVMYWJlbBISCg5MQUJFTF9P", + "UFRJT05BTBABEhIKDkxBQkVMX1JFUVVJUkVEEAISEgoOTEFCRUxfUkVQRUFU", + "RUQQAyJUChRPbmVvZkRlc2NyaXB0b3JQcm90bxIMCgRuYW1lGAEgASgJEi4K", + "B29wdGlvbnMYAiABKAsyHS5nb29nbGUucHJvdG9idWYuT25lb2ZPcHRpb25z", + "IqQCChNFbnVtRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkSOAoFdmFs", + "dWUYAiADKAsyKS5nb29nbGUucHJvdG9idWYuRW51bVZhbHVlRGVzY3JpcHRv", + "clByb3RvEi0KB29wdGlvbnMYAyABKAsyHC5nb29nbGUucHJvdG9idWYuRW51", + "bU9wdGlvbnMSTgoOcmVzZXJ2ZWRfcmFuZ2UYBCADKAsyNi5nb29nbGUucHJv", + "dG9idWYuRW51bURlc2NyaXB0b3JQcm90by5FbnVtUmVzZXJ2ZWRSYW5nZRIV", + "Cg1yZXNlcnZlZF9uYW1lGAUgAygJGi8KEUVudW1SZXNlcnZlZFJhbmdlEg0K", + "BXN0YXJ0GAEgASgFEgsKA2VuZBgCIAEoBSJsChhFbnVtVmFsdWVEZXNjcmlw", + "dG9yUHJvdG8SDAoEbmFtZRgBIAEoCRIOCgZudW1iZXIYAiABKAUSMgoHb3B0", + "aW9ucxgDIAEoCzIhLmdvb2dsZS5wcm90b2J1Zi5FbnVtVmFsdWVPcHRpb25z", + "IpABChZTZXJ2aWNlRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkSNgoG", + "bWV0aG9kGAIgAygLMiYuZ29vZ2xlLnByb3RvYnVmLk1ldGhvZERlc2NyaXB0", + "b3JQcm90bxIwCgdvcHRpb25zGAMgASgLMh8uZ29vZ2xlLnByb3RvYnVmLlNl", + "cnZpY2VPcHRpb25zIsEBChVNZXRob2REZXNjcmlwdG9yUHJvdG8SDAoEbmFt", + "ZRgBIAEoCRISCgppbnB1dF90eXBlGAIgASgJEhMKC291dHB1dF90eXBlGAMg", + "ASgJEi8KB29wdGlvbnMYBCABKAsyHi5nb29nbGUucHJvdG9idWYuTWV0aG9k", + "T3B0aW9ucxIfChBjbGllbnRfc3RyZWFtaW5nGAUgASgIOgVmYWxzZRIfChBz", + "ZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVmYWxzZSKlBgoLRmlsZU9wdGlvbnMS", + "FAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGphdmFfb3V0ZXJfY2xhc3NuYW1l", + "GAggASgJEiIKE2phdmFfbXVsdGlwbGVfZmlsZXMYCiABKAg6BWZhbHNlEikK", + "HWphdmFfZ2VuZXJhdGVfZXF1YWxzX2FuZF9oYXNoGBQgASgIQgIYARIlChZq", + "YXZhX3N0cmluZ19jaGVja191dGY4GBsgASgIOgVmYWxzZRJGCgxvcHRpbWl6", + "ZV9mb3IYCSABKA4yKS5nb29nbGUucHJvdG9idWYuRmlsZU9wdGlvbnMuT3B0", + "aW1pemVNb2RlOgVTUEVFRBISCgpnb19wYWNrYWdlGAsgASgJEiIKE2NjX2dl", + "bmVyaWNfc2VydmljZXMYECABKAg6BWZhbHNlEiQKFWphdmFfZ2VuZXJpY19z", + "ZXJ2aWNlcxgRIAEoCDoFZmFsc2USIgoTcHlfZ2VuZXJpY19zZXJ2aWNlcxgS", + "IAEoCDoFZmFsc2USIwoUcGhwX2dlbmVyaWNfc2VydmljZXMYKiABKAg6BWZh", + "bHNlEhkKCmRlcHJlY2F0ZWQYFyABKAg6BWZhbHNlEh4KEGNjX2VuYWJsZV9h", + "cmVuYXMYHyABKAg6BHRydWUSGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkS", + "GAoQY3NoYXJwX25hbWVzcGFjZRglIAEoCRIUCgxzd2lmdF9wcmVmaXgYJyAB", + "KAkSGAoQcGhwX2NsYXNzX3ByZWZpeBgoIAEoCRIVCg1waHBfbmFtZXNwYWNl", + "GCkgASgJEh4KFnBocF9tZXRhZGF0YV9uYW1lc3BhY2UYLCABKAkSFAoMcnVi", + "eV9wYWNrYWdlGC0gASgJEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMo", + "CzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uIjoKDE9w", + "dGltaXplTW9kZRIJCgVTUEVFRBABEg0KCUNPREVfU0laRRACEhAKDExJVEVf", + "UlVOVElNRRADKgkI6AcQgICAgAJKBAgmECci8gEKDk1lc3NhZ2VPcHRpb25z", + "EiYKF21lc3NhZ2Vfc2V0X3dpcmVfZm9ybWF0GAEgASgIOgVmYWxzZRIuCh9u", + "b19zdGFuZGFyZF9kZXNjcmlwdG9yX2FjY2Vzc29yGAIgASgIOgVmYWxzZRIZ", + "CgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRIRCgltYXBfZW50cnkYByABKAgS", "QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv", - "YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lMZXZlbBIX", - "ChNJREVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZFQ1RTEAES", - "DgoKSURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJwcmV0ZWRP", - "cHRpb24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5VbmludGVy", - "cHJldGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFsdWUYAyAB", - "KAkSGgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0aXZlX2lu", - "dF92YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoMc3RyaW5n", - "X3ZhbHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRozCghOYW1l", - "UGFydBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigI", - "ItUBCg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2ds", - "ZS5wcm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoITG9jYXRp", - "b24SEAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAESGAoQbGVh", - "ZGluZ19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50cxgEIAEo", - "CRIhChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIqcBChFHZW5l", - "cmF0ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29vZ2xlLnBy", - "b3RvYnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24aTwoKQW5ub3Rh", - "dGlvbhIQCgRwYXRoGAEgAygFQgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRIN", - "CgViZWdpbhgDIAEoBRILCgNlbmQYBCABKAVCjwEKE2NvbS5nb29nbGUucHJv", - "dG9idWZCEERlc2NyaXB0b3JQcm90b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcv", - "cHJvdG9idWYvcHJvdG9jLWdlbi1nby9kZXNjcmlwdG9yO2Rlc2NyaXB0b3L4", - "AQGiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg==")); + "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", + "BCABKAVCjwEKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2NyaXB0b3JQcm90", + "b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHJvdG9jLWdlbi1n", + "by9kZXNjcmlwdG9yO2Rlc2NyaXB0b3L4AQGiAgNHUEKqAhpHb29nbGUuUHJv", + "dG9idWYuUmVmbGVjdGlvbg==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { @@ -166,7 +167,7 @@ public static partial class DescriptorReflection { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto), global::Google.Protobuf.Reflection.DescriptorProto.Parser, new[]{ "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange.Parser, new[]{ "Start", "End", "Options" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange.Parser, new[]{ "Start", "End" }, null, null, null, null)}), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ExtensionRangeOptions), global::Google.Protobuf.Reflection.ExtensionRangeOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser, new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "JsonName", "Options" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser, new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "JsonName", "Options", "Proto3Optional" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), global::Google.Protobuf.Reflection.OneofDescriptorProto.Parser, new[]{ "Name", "Options" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser, new[]{ "Name", "Value", "Options", "ReservedRange", "ReservedName" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto.Types.EnumReservedRange), global::Google.Protobuf.Reflection.EnumDescriptorProto.Types.EnumReservedRange.Parser, new[]{ "Start", "End" }, null, null, null, null)}), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null, null), @@ -1791,6 +1792,7 @@ public sealed partial class FieldDescriptorProto : pb::IMessageField number for the "proto3_optional" field. + public const int Proto3OptionalFieldNumber = 17; + private readonly static bool Proto3OptionalDefaultValue = false; + + private bool proto3Optional_; + /// + /// If true, this is a proto3 "optional". When a proto3 field is optional, it + /// tracks presence regardless of field type. + /// + /// For message fields this doesn't create any semantic change, since + /// non-repeated message fields always track presence. However it still + /// indicates the semantic detail of whether the user wrote "optional" or not. + /// This can be useful for round-tripping the .proto file. + /// + /// Proto2 optional fields do not set this flag, because they already indicate + /// optional with `LABEL_OPTIONAL`. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Proto3Optional { + get { if ((_hasBits0 & 16) != 0) { return proto3Optional_; } else { return Proto3OptionalDefaultValue; } } + set { + _hasBits0 |= 16; + proto3Optional_ = value; + } + } + /// Gets whether the "proto3_optional" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasProto3Optional { + get { return (_hasBits0 & 16) != 0; } + } + /// Clears the value of the "proto3_optional" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearProto3Optional() { + _hasBits0 &= ~16; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FieldDescriptorProto); @@ -2086,6 +2124,7 @@ public sealed partial class FieldDescriptorProto : pb::IMessage { /// Field number for the "cc_enable_arenas" field. public const int CcEnableArenasFieldNumber = 31; - private readonly static bool CcEnableArenasDefaultValue = false; + private readonly static bool CcEnableArenasDefaultValue = true; private bool ccEnableArenas_; /// diff --git a/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java b/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java index 65dcd53aa4d2..f023baa9a079 100644 --- a/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java @@ -140,6 +140,26 @@ public boolean getBoolean(int index) { return array[index]; } + @Override + public int indexOf(Object element) { + if (!(element instanceof Boolean)) { + return -1; + } + boolean unboxedElement = (Boolean) element; + int numElems = size(); + for (int i = 0; i < numElems; i++) { + if (array[i] == unboxedElement) { + return i; + } + } + return -1; + } + + @Override + public boolean contains(Object element) { + return indexOf(element) != -1; + } + @Override public int size() { return size; diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java index f2c7cc47236a..e20a8858c22a 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java @@ -484,7 +484,7 @@ final boolean shouldDiscardUnknownFields() { * Returns true if the stream has reached the end of the input. This is the case if either the end * of the underlying input source has been reached or if the stream has reached a limit created * using {@link #pushLimit(int)}. This function may get blocked when using StreamDecoder as it - * invokes {@link #StreamDecoder.tryRefillBuffer(int)} in this function which will try to read + * invokes {@link StreamDecoder#tryRefillBuffer(int)} in this function which will try to read * bytes from input. */ public abstract boolean isAtEnd() throws IOException; diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index a20829e56df6..960ff5da8f9e 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -1125,6 +1125,34 @@ public OneofDescriptor getContainingOneof() { return containingOneof; } + /** + * Returns true if this field was syntactically written with "optional" in the .proto file. + * Excludes singular proto3 fields that do not have a label. + */ + public boolean hasOptionalKeyword() { + return isProto3Optional + || (file.getSyntax() == Syntax.PROTO2 && isOptional() && getContainingOneof() == null); + } + + /** + * Returns true if this is a non-oneof field that tracks presence. + * + *

This includes all "required" and "optional" fields in the .proto file, but excludes oneof + * fields and singular proto3 fields without "optional". + * + *

In implementations that use hasbits, this method will probably indicate whether this field + * uses a hasbit. + */ + boolean isSingularWithPresence() { + if (isRepeated()) { + return false; + } + if (getContainingOneof() != null && !getContainingOneof().isSynthetic()) { + return false; + } + return getType() == Type.MESSAGE || isProto3Optional || file.getSyntax() == Syntax.PROTO2; + } + /** * For extensions defined nested within message types, gets the outer type. Not valid for * non-extension fields. For example, consider this {@code .proto} file: @@ -1203,6 +1231,7 @@ public String toString() { private final String jsonName; private final FileDescriptor file; private final Descriptor extensionScope; + private final boolean isProto3Optional; // Possibly initialized during cross-linking. private Type type; @@ -1327,6 +1356,8 @@ private FieldDescriptor( type = Type.valueOf(proto.getType()); } + isProto3Optional = proto.getProto3Optional(); + if (getNumber() <= 0) { throw new DescriptorValidationException(this, "Field numbers must be positive integers."); } @@ -2627,6 +2658,10 @@ public OneofOptions getOptions() { return proto.getOptions(); } + public boolean isSynthetic() { + return fields.length == 1 && fields[0].isProto3Optional; + } + /** Get a list of this message type's fields. */ public List getFields() { return Collections.unmodifiableList(Arrays.asList(fields)); diff --git a/java/core/src/main/java/com/google/protobuf/DoubleArrayList.java b/java/core/src/main/java/com/google/protobuf/DoubleArrayList.java index ac14949e6f50..12824abe6621 100644 --- a/java/core/src/main/java/com/google/protobuf/DoubleArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/DoubleArrayList.java @@ -140,6 +140,26 @@ public double getDouble(int index) { return array[index]; } + @Override + public int indexOf(Object element) { + if (!(element instanceof Double)) { + return -1; + } + double unboxedElement = (Double) element; + int numElems = size(); + for (int i = 0; i < numElems; i++) { + if (array[i] == unboxedElement) { + return i; + } + } + return -1; + } + + @Override + public boolean contains(Object element) { + return indexOf(element) != -1; + } + @Override public int size() { return size; diff --git a/java/core/src/main/java/com/google/protobuf/FloatArrayList.java b/java/core/src/main/java/com/google/protobuf/FloatArrayList.java index 9d2ab71d7c38..9589816f8ec5 100644 --- a/java/core/src/main/java/com/google/protobuf/FloatArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/FloatArrayList.java @@ -139,6 +139,26 @@ public float getFloat(int index) { return array[index]; } + @Override + public int indexOf(Object element) { + if (!(element instanceof Float)) { + return -1; + } + float unboxedElement = (Float) element; + int numElems = size(); + for (int i = 0; i < numElems; i++) { + if (array[i] == unboxedElement) { + return i; + } + } + return -1; + } + + @Override + public boolean contains(Object element) { + return indexOf(element) != -1; + } + @Override public int size() { return size; diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java index 1ee785de8e6b..8456713fa029 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java @@ -121,7 +121,11 @@ public boolean equals( return true; } - if (!getDefaultInstanceForType().getClass().isInstance(other)) { + if (other == null) { + return false; + } + + if (this.getClass() != other.getClass()) { return false; } diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java index 4a0e28e127cf..86f88a0228f2 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java @@ -1987,9 +1987,9 @@ public FieldAccessorTable ensureFieldAccessorsInitialized( int oneofsSize = oneofs.length; for (int i = 0; i < oneofsSize; i++) { - oneofs[i] = new OneofAccessor( - descriptor, camelCaseNames[i + fieldsSize], - messageClass, builderClass); + oneofs[i] = + new OneofAccessor( + descriptor, i, camelCaseNames[i + fieldsSize], messageClass, builderClass); } initialized = true; camelCaseNames = null; @@ -2057,14 +2057,22 @@ Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder builder, /** OneofAccessor provides access to a single oneof. */ private static class OneofAccessor { OneofAccessor( - final Descriptor descriptor, final String camelCaseName, + final Descriptor descriptor, + final int oneofIndex, + final String camelCaseName, final Class messageClass, final Class builderClass) { this.descriptor = descriptor; - caseMethod = - getMethodOrDie(messageClass, "get" + camelCaseName + "Case"); - caseMethodBuilder = - getMethodOrDie(builderClass, "get" + camelCaseName + "Case"); + OneofDescriptor oneofDescriptor = descriptor.getOneofs().get(oneofIndex); + if (oneofDescriptor.isSynthetic()) { + caseMethod = null; + caseMethodBuilder = null; + fieldDescriptor = oneofDescriptor.getFields().get(0); + } else { + caseMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Case"); + caseMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Case"); + fieldDescriptor = null; + } clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); } @@ -2072,33 +2080,51 @@ private static class OneofAccessor { private final Method caseMethod; private final Method caseMethodBuilder; private final Method clearMethod; + private final FieldDescriptor fieldDescriptor; public boolean has(final GeneratedMessageV3 message) { - if (((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() == 0) { - return false; + if (fieldDescriptor != null) { + return message.hasField(fieldDescriptor); + } else { + if (((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() == 0) { + return false; + } } return true; } public boolean has(GeneratedMessageV3.Builder builder) { - if (((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() == 0) { - return false; + if (fieldDescriptor != null) { + return builder.hasField(fieldDescriptor); + } else { + if (((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() == 0) { + return false; + } } return true; } public FieldDescriptor get(final GeneratedMessageV3 message) { - int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); - if (fieldNumber > 0) { - return descriptor.findFieldByNumber(fieldNumber); + if (fieldDescriptor != null) { + return message.hasField(fieldDescriptor) ? fieldDescriptor : null; + } else { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } } return null; } public FieldDescriptor get(GeneratedMessageV3.Builder builder) { - int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); - if (fieldNumber > 0) { - return descriptor.findFieldByNumber(fieldNumber); + if (fieldDescriptor != null) { + return builder.hasField(fieldDescriptor) ? fieldDescriptor : null; + } else { + int fieldNumber = + ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } } return null; } @@ -2108,10 +2134,6 @@ public void clear(final Builder builder) { } } - private static boolean supportFieldPresence(FileDescriptor file) { - return file.getSyntax() == FileDescriptor.Syntax.PROTO2; - } - // --------------------------------------------------------------- private static class SingularFieldAccessor implements FieldAccessor { @@ -2216,9 +2238,13 @@ public void clear(final GeneratedMessageV3.Builder builder) { final Class messageClass, final Class builderClass, final String containingOneofCamelCaseName) { - isOneofField = descriptor.getContainingOneof() != null; - hasHasMethod = supportFieldPresence(descriptor.getFile()) - || (!isOneofField && descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE); + isOneofField = + descriptor.getContainingOneof() != null + && !descriptor.getContainingOneof().isSynthetic(); + hasHasMethod = + descriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO2 + || descriptor.hasOptionalKeyword() + || (!isOneofField && descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE); ReflectionInvoker reflectionInvoker = new ReflectionInvoker( descriptor, diff --git a/java/core/src/main/java/com/google/protobuf/IntArrayList.java b/java/core/src/main/java/com/google/protobuf/IntArrayList.java index 98f1f81331c4..e9c3b1aee0ba 100644 --- a/java/core/src/main/java/com/google/protobuf/IntArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/IntArrayList.java @@ -139,6 +139,26 @@ public int getInt(int index) { return array[index]; } + @Override + public int indexOf(Object element) { + if (!(element instanceof Integer)) { + return -1; + } + int unboxedElement = (Integer) element; + int numElems = size(); + for (int i = 0; i < numElems; i++) { + if (array[i] == unboxedElement) { + return i; + } + } + return -1; + } + + @Override + public boolean contains(Object element) { + return indexOf(element) != -1; + } + @Override public int size() { return size; diff --git a/java/core/src/main/java/com/google/protobuf/LongArrayList.java b/java/core/src/main/java/com/google/protobuf/LongArrayList.java index 2dd15b4deb28..04f44756c43b 100644 --- a/java/core/src/main/java/com/google/protobuf/LongArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/LongArrayList.java @@ -139,6 +139,26 @@ public long getLong(int index) { return array[index]; } + @Override + public int indexOf(Object element) { + if (!(element instanceof Long)) { + return -1; + } + long unboxedElement = (Long) element; + int numElems = size(); + for (int i = 0; i < numElems; i++) { + if (array[i] == unboxedElement) { + return i; + } + } + return -1; + } + + @Override + public boolean contains(Object element) { + return indexOf(element) != -1; + } + @Override public int size() { return size; diff --git a/java/core/src/main/java/com/google/protobuf/MessageSchema.java b/java/core/src/main/java/com/google/protobuf/MessageSchema.java index 8f9ce7328ee0..139e55a97142 100755 --- a/java/core/src/main/java/com/google/protobuf/MessageSchema.java +++ b/java/core/src/main/java/com/google/protobuf/MessageSchema.java @@ -89,6 +89,7 @@ final class MessageSchema implements Schema { private static final int FIELD_TYPE_MASK = 0x0FF00000; private static final int REQUIRED_MASK = 0x10000000; private static final int ENFORCE_UTF8_MASK = 0x20000000; + private static final int NO_PRESENCE_SENTINEL = -1 & OFFSET_MASK; private static final int[] EMPTY_INT_ARRAY = new int[0]; /** An offset applied to the field type ID for scalar fields that are a member of a oneof. */ @@ -118,6 +119,11 @@ final class MessageSchema implements Schema { * [70 - 75] field presence mask shift (unused for oneof/repeated fields) * [76 - 95] presence field offset / oneof case field offset / cached size field offset * + * + * Note that presence field offset can only use 20 bits - 1. All bits set to 1 is the sentinel + * value for non-presence. This is not validated at runtime, we simply assume message layouts + * will not exceed 1MB (assuming ~10 bytes per field, that implies 100k fields which should hit + * other javac limits first). */ private final int[] buffer; @@ -260,7 +266,7 @@ static MessageSchema newSchemaForRawMessageInfo( } next = result | (next << shift); } - final int flags = next; + final int unusedFlags = next; next = info.charAt(i++); if (next >= 0xD800) { @@ -464,8 +470,7 @@ static MessageSchema newSchemaForRawMessageInfo( || oneofFieldType == 17 /* FieldType.GROUP */) { objects[bufferIndex / INTS_PER_FIELD * 2 + 1] = messageInfoObjects[objectsPosition++]; } else if (oneofFieldType == 12 /* FieldType.ENUM */) { - // proto2 - if ((flags & 0x1) == 0x1) { + if (!isProto3) { objects[bufferIndex / INTS_PER_FIELD * 2 + 1] = messageInfoObjects[objectsPosition++]; } } @@ -508,7 +513,7 @@ static MessageSchema newSchemaForRawMessageInfo( } else if (fieldType == 12 /* FieldType.ENUM */ || fieldType == 30 /* FieldType.ENUM_LIST */ || fieldType == 44 /* FieldType.ENUM_LIST_PACKED */) { - if ((flags & 0x1) == 0x1) { + if (!isProto3) { objects[bufferIndex / INTS_PER_FIELD * 2 + 1] = messageInfoObjects[objectsPosition++]; } } else if (fieldType == 50 /* FieldType.MAP */) { @@ -520,7 +525,8 @@ static MessageSchema newSchemaForRawMessageInfo( } fieldOffset = (int) unsafe.objectFieldOffset(field); - if ((flags & 0x1) == 0x1 && fieldType <= 17 /* FieldType.GROUP */) { + boolean hasHasBit = (fieldTypeWithExtraBits & 0x1000) == 0x1000; + if (hasHasBit && fieldType <= 17 /* FieldType.GROUP */) { next = info.charAt(i++); if (next >= 0xD800) { int result = next & 0x1FFF; @@ -546,7 +552,7 @@ static MessageSchema newSchemaForRawMessageInfo( presenceFieldOffset = (int) unsafe.objectFieldOffset(hasBitsField); presenceMaskShift = hasBitsIndex % 32; } else { - presenceFieldOffset = 0; + presenceFieldOffset = NO_PRESENCE_SENTINEL; presenceMaskShift = 0; } @@ -662,7 +668,7 @@ static MessageSchema newSchemaForMessageInfo( // We found the entry for the next field. Store the entry in the manifest for // this field and increment the field index. - storeFieldData(fi, buffer, bufferIndex, isProto3, objects); + storeFieldData(fi, buffer, bufferIndex, objects); // Convert field number to index if (checkInitializedIndex < checkInitialized.length @@ -719,7 +725,7 @@ static MessageSchema newSchemaForMessageInfo( } private static void storeFieldData( - FieldInfo fi, int[] buffer, int bufferIndex, boolean proto3, Object[] objects) { + FieldInfo fi, int[] buffer, int bufferIndex, Object[] objects) { final int fieldOffset; final int typeId; final int presenceMaskShift; @@ -735,8 +741,13 @@ private static void storeFieldData( FieldType type = fi.getType(); fieldOffset = (int) UnsafeUtil.objectFieldOffset(fi.getField()); typeId = type.id(); - if (!proto3 && !type.isList() && !type.isMap()) { - presenceFieldOffset = (int) UnsafeUtil.objectFieldOffset(fi.getPresenceField()); + if (!type.isList() && !type.isMap()) { + Field presenceField = fi.getPresenceField(); + if (presenceField == null) { + presenceFieldOffset = NO_PRESENCE_SENTINEL; + } else { + presenceFieldOffset = (int) UnsafeUtil.objectFieldOffset(presenceField); + } presenceMaskShift = Integer.numberOfTrailingZeros(fi.getPresenceMask()); } else { if (fi.getCachedSizeField() == null) { @@ -1408,13 +1419,13 @@ private void mergeOneofMessage(T message, T other, int pos) { public int getSerializedSize(T message) { return proto3 ? getSerializedSizeProto3(message) : getSerializedSizeProto2(message); } - + @SuppressWarnings("unchecked") private int getSerializedSizeProto2(T message) { int size = 0; final sun.misc.Unsafe unsafe = UNSAFE; - int currentPresenceFieldOffset = -1; + int currentPresenceFieldOffset = NO_PRESENCE_SENTINEL; int currentPresenceField = 0; for (int i = 0; i < buffer.length; i += INTS_PER_FIELD) { final int typeAndOffset = typeAndOffsetAt(i); @@ -2548,7 +2559,7 @@ private void writeFieldsInAscendingOrderProto2(T message, Writer writer) throws nextExtension = extensionIterator.next(); } } - int currentPresenceFieldOffset = -1; + int currentPresenceFieldOffset = NO_PRESENCE_SENTINEL; int currentPresenceField = 0; final int bufferLength = buffer.length; final sun.misc.Unsafe unsafe = UNSAFE; @@ -2924,7 +2935,6 @@ private void writeFieldsInAscendingOrderProto3(T message, Writer writer) throws nextExtension = extensionIterator.next(); } } - final int bufferLength = buffer.length; for (int pos = 0; pos < bufferLength; pos += INTS_PER_FIELD) { final int typeAndOffset = typeAndOffsetAt(pos); @@ -4867,7 +4877,7 @@ int parseProto2Message( T message, byte[] data, int position, int limit, int endGroup, Registers registers) throws IOException { final sun.misc.Unsafe unsafe = UNSAFE; - int currentPresenceFieldOffset = -1; + int currentPresenceFieldOffset = NO_PRESENCE_SENTINEL; int currentPresenceField = 0; int tag = 0; int oldNumber = -1; @@ -4901,7 +4911,7 @@ int parseProto2Message( // We cache the 32-bit has-bits integer value and only write it back when parsing a field // using a different has-bits integer. if (presenceFieldOffset != currentPresenceFieldOffset) { - if (currentPresenceFieldOffset != -1) { + if (currentPresenceFieldOffset != NO_PRESENCE_SENTINEL) { unsafe.putInt(message, (long) currentPresenceFieldOffset, currentPresenceField); } currentPresenceFieldOffset = presenceFieldOffset; @@ -5143,7 +5153,7 @@ int parseProto2Message( tag, data, position, limit, getMutableUnknownFields(message), registers); } } - if (currentPresenceFieldOffset != -1) { + if (currentPresenceFieldOffset != NO_PRESENCE_SENTINEL) { unsafe.putInt(message, (long) currentPresenceFieldOffset, currentPresenceField); } UnknownFieldSetLite unknownFields = null; @@ -5175,6 +5185,8 @@ int parseProto2Message( private int parseProto3Message( T message, byte[] data, int position, int limit, Registers registers) throws IOException { final sun.misc.Unsafe unsafe = UNSAFE; + int currentPresenceFieldOffset = NO_PRESENCE_SENTINEL; + int currentPresenceField = 0; int tag = 0; int oldNumber = -1; int pos = 0; @@ -5200,11 +5212,30 @@ private int parseProto3Message( final int fieldType = type(typeAndOffset); final long fieldOffset = offset(typeAndOffset); if (fieldType <= 17) { + // Proto3 optional fields have has-bits. + final int presenceMaskAndOffset = buffer[pos + 2]; + final int presenceMask = 1 << (presenceMaskAndOffset >>> OFFSET_BITS); + final int presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK; + // We cache the 32-bit has-bits integer value and only write it back when parsing a field + // using a different has-bits integer. + // + // Note that for fields that do not have hasbits, we unconditionally write and discard + // the data. + if (presenceFieldOffset != currentPresenceFieldOffset) { + if (currentPresenceFieldOffset != NO_PRESENCE_SENTINEL) { + unsafe.putInt(message, (long) currentPresenceFieldOffset, currentPresenceField); + } + if (presenceFieldOffset != NO_PRESENCE_SENTINEL) { + currentPresenceField = unsafe.getInt(message, (long) presenceFieldOffset); + } + currentPresenceFieldOffset = presenceFieldOffset; + } switch (fieldType) { case 0: // DOUBLE: if (wireType == WireFormat.WIRETYPE_FIXED64) { UnsafeUtil.putDouble(message, fieldOffset, decodeDouble(data, position)); position += 8; + currentPresenceField |= presenceMask; continue; } break; @@ -5212,6 +5243,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_FIXED32) { UnsafeUtil.putFloat(message, fieldOffset, decodeFloat(data, position)); position += 4; + currentPresenceField |= presenceMask; continue; } break; @@ -5220,6 +5252,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_VARINT) { position = decodeVarint64(data, position, registers); unsafe.putLong(message, fieldOffset, registers.long1); + currentPresenceField |= presenceMask; continue; } break; @@ -5228,6 +5261,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_VARINT) { position = decodeVarint32(data, position, registers); unsafe.putInt(message, fieldOffset, registers.int1); + currentPresenceField |= presenceMask; continue; } break; @@ -5236,6 +5270,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_FIXED64) { unsafe.putLong(message, fieldOffset, decodeFixed64(data, position)); position += 8; + currentPresenceField |= presenceMask; continue; } break; @@ -5244,6 +5279,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_FIXED32) { unsafe.putInt(message, fieldOffset, decodeFixed32(data, position)); position += 4; + currentPresenceField |= presenceMask; continue; } break; @@ -5251,6 +5287,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_VARINT) { position = decodeVarint64(data, position, registers); UnsafeUtil.putBoolean(message, fieldOffset, registers.long1 != 0); + currentPresenceField |= presenceMask; continue; } break; @@ -5262,6 +5299,7 @@ private int parseProto3Message( position = decodeStringRequireUtf8(data, position, registers); } unsafe.putObject(message, fieldOffset, registers.object1); + currentPresenceField |= presenceMask; continue; } break; @@ -5277,6 +5315,7 @@ private int parseProto3Message( unsafe.putObject( message, fieldOffset, Internal.mergeMessage(oldValue, registers.object1)); } + currentPresenceField |= presenceMask; continue; } break; @@ -5284,6 +5323,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) { position = decodeBytes(data, position, registers); unsafe.putObject(message, fieldOffset, registers.object1); + currentPresenceField |= presenceMask; continue; } break; @@ -5291,6 +5331,7 @@ private int parseProto3Message( if (wireType == WireFormat.WIRETYPE_VARINT) { position = decodeVarint32(data, position, registers); unsafe.putInt(message, fieldOffset, registers.int1); + currentPresenceField |= presenceMask; continue; } break; @@ -5299,6 +5340,7 @@ private int parseProto3Message( position = decodeVarint32(data, position, registers); unsafe.putInt( message, fieldOffset, CodedInputStream.decodeZigZag32(registers.int1)); + currentPresenceField |= presenceMask; continue; } break; @@ -5307,6 +5349,7 @@ private int parseProto3Message( position = decodeVarint64(data, position, registers); unsafe.putLong( message, fieldOffset, CodedInputStream.decodeZigZag64(registers.long1)); + currentPresenceField |= presenceMask; continue; } break; @@ -5381,6 +5424,9 @@ private int parseProto3Message( position = decodeUnknownField( tag, data, position, limit, getMutableUnknownFields(message), registers); } + if (currentPresenceFieldOffset != NO_PRESENCE_SENTINEL) { + unsafe.putInt(message, (long) currentPresenceFieldOffset, currentPresenceField); + } if (position != limit) { throw InvalidProtocolBufferException.parseFailure(); } @@ -5502,28 +5548,26 @@ private final UB filterUnknownEnumMap( @Override public final boolean isInitialized(T message) { - int currentPresenceFieldOffset = -1; + int currentPresenceFieldOffset = NO_PRESENCE_SENTINEL; int currentPresenceField = 0; for (int i = 0; i < checkInitializedCount; i++) { final int pos = intArray[i]; final int number = numberAt(pos); - final int typeAndOffset = typeAndOffsetAt(pos); - int presenceMaskAndOffset = 0; - int presenceMask = 0; - if (!proto3) { - presenceMaskAndOffset = buffer[pos + 2]; - final int presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK; - presenceMask = 1 << (presenceMaskAndOffset >>> OFFSET_BITS); - if (presenceFieldOffset != currentPresenceFieldOffset) { - currentPresenceFieldOffset = presenceFieldOffset; + int presenceMaskAndOffset = buffer[pos + 2]; + final int presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK; + int presenceMask = 1 << (presenceMaskAndOffset >>> OFFSET_BITS); + if (presenceFieldOffset != currentPresenceFieldOffset) { + currentPresenceFieldOffset = presenceFieldOffset; + if (currentPresenceFieldOffset != NO_PRESENCE_SENTINEL) { currentPresenceField = UNSAFE.getInt(message, (long) presenceFieldOffset); } } if (isRequired(typeAndOffset)) { - if (!isFieldPresent(message, pos, currentPresenceField, presenceMask)) { + if (!isFieldPresent( + message, pos, currentPresenceFieldOffset, currentPresenceField, presenceMask)) { return false; } // If a required message field is set but has no required fields of it's own, we still @@ -5534,7 +5578,8 @@ public final boolean isInitialized(T message) { switch (type(typeAndOffset)) { case 9: // MESSAGE case 17: // GROUP - if (isFieldPresent(message, pos, currentPresenceField, presenceMask) + if (isFieldPresent( + message, pos, currentPresenceFieldOffset, currentPresenceField, presenceMask) && !isInitialized(message, typeAndOffset, getMessageFieldSchema(pos))) { return false; } @@ -5744,8 +5789,9 @@ private boolean arePresentForEquals(T message, T other, int pos) { return isFieldPresent(message, pos) == isFieldPresent(other, pos); } - private boolean isFieldPresent(T message, int pos, int presenceField, int presenceMask) { - if (proto3) { + private boolean isFieldPresent( + T message, int pos, int presenceFieldOffset, int presenceField, int presenceMask) { + if (presenceFieldOffset == NO_PRESENCE_SENTINEL) { return isFieldPresent(message, pos); } else { return (presenceField & presenceMask) != 0; @@ -5753,7 +5799,9 @@ private boolean isFieldPresent(T message, int pos, int presenceField, int presen } private boolean isFieldPresent(T message, int pos) { - if (proto3) { + final int presenceMaskAndOffset = presenceMaskAndOffsetAt(pos); + final long presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK; + if (presenceFieldOffset == NO_PRESENCE_SENTINEL) { final int typeAndOffset = typeAndOffsetAt(pos); final long offset = offset(typeAndOffset); switch (type(typeAndOffset)) { @@ -5804,20 +5852,18 @@ private boolean isFieldPresent(T message, int pos) { throw new IllegalArgumentException(); } } else { - int presenceMaskAndOffset = presenceMaskAndOffsetAt(pos); final int presenceMask = 1 << (presenceMaskAndOffset >>> OFFSET_BITS); return (UnsafeUtil.getInt(message, presenceMaskAndOffset & OFFSET_MASK) & presenceMask) != 0; } } private void setFieldPresent(T message, int pos) { - if (proto3) { - // Proto3 doesn't have presence fields + int presenceMaskAndOffset = presenceMaskAndOffsetAt(pos); + final long presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK; + if (presenceFieldOffset == NO_PRESENCE_SENTINEL) { return; } - int presenceMaskAndOffset = presenceMaskAndOffsetAt(pos); final int presenceMask = 1 << (presenceMaskAndOffset >>> OFFSET_BITS); - final long presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK; UnsafeUtil.putInt( message, presenceFieldOffset, diff --git a/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java b/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java index b9a3d2bb55bc..72f56ed88e5d 100755 --- a/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java +++ b/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java @@ -96,7 +96,7 @@ final class RawMessageInfo implements MessageInfo { * If the field is in an oneof: * *

    - *
  • [2]: oenof index + *
  • [2]: oneof index *
* * For other types, the field entry only has field number and field type. diff --git a/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java b/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java index f3b09fbacca4..f51436c83d23 100644 --- a/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java +++ b/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java @@ -346,9 +346,8 @@ public RepeatedFieldBuilder addAllMessages( // If we can inspect the size, we can more efficiently add messages. int size = -1; if (values instanceof Collection) { - @SuppressWarnings("unchecked") - final Collection collection = (Collection) values; - if (collection.size() == 0) { + final Collection collection = (Collection) values; + if (collection.isEmpty()) { return this; } size = collection.size(); @@ -408,8 +407,7 @@ public BType addBuilder(int index, MType message) { /** * Removes the element at the specified position in this list. Shifts any subsequent elements to - * the left (subtracts one from their indices). Returns the element that was removed from the - * list. + * the left (subtracts one from their indices). * * @param index the index at which to remove the message */ diff --git a/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java b/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java index fb1667c4c65b..91bc3e286dd0 100644 --- a/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java +++ b/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java @@ -346,9 +346,8 @@ public RepeatedFieldBuilderV3 addAllMessages( // If we can inspect the size, we can more efficiently add messages. int size = -1; if (values instanceof Collection) { - @SuppressWarnings("unchecked") - final Collection collection = (Collection) values; - if (collection.size() == 0) { + final Collection collection = (Collection) values; + if (collection.isEmpty()) { return this; } size = collection.size(); @@ -408,8 +407,7 @@ public BType addBuilder(int index, MType message) { /** * Removes the element at the specified position in this list. Shifts any subsequent elements to - * the left (subtracts one from their indices). Returns the element that was removed from the - * list. + * the left (subtracts one from their indices). * * @param index the index at which to remove the message */ diff --git a/java/core/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java index f3f1011a585f..673343d4ea05 100644 --- a/java/core/src/main/java/com/google/protobuf/TextFormat.java +++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java @@ -34,10 +34,12 @@ import com.google.protobuf.Descriptors.EnumDescriptor; import com.google.protobuf.Descriptors.EnumValueDescriptor; import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.MessageReflection.MergeTarget; import java.io.IOException; import java.math.BigInteger; import java.nio.CharBuffer; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Map; @@ -137,7 +139,7 @@ public static String shortDebugString(final UnknownFieldSet fields) { /** * Like {@code print()}, but writes directly to a {@code String} and returns it. * - * @deprecated Use {@link MessageOrBuilder#toString()} + * @deprecated Use {@code message.toString()} */ @Deprecated public static String printToString(final MessageOrBuilder message) { @@ -419,7 +421,17 @@ public void printField(final FieldDescriptor field, final Object value, final Ap private void printField( final FieldDescriptor field, final Object value, final TextGenerator generator) throws IOException { - if (field.isRepeated()) { + // Sort map field entries by key + if (field.isMapField()) { + List adapters = new ArrayList<>(); + for (Object entry : (List) value) { + adapters.add(new MapEntryAdapter(entry, field)); + } + Collections.sort(adapters); + for (MapEntryAdapter adapter : adapters) { + printSingleField(field, adapter.getEntry(), generator); + } + } else if (field.isRepeated()) { // Repeated field. Print each element. for (Object element : (List) value) { printSingleField(field, element, generator); @@ -429,6 +441,94 @@ private void printField( } } + /** + * An adapter class that can take a MapEntry or a MutableMapEntry and returns its key and entry. + * This class is created solely for the purpose of sorting map entries by its key and prevent + * duplicated logic by having a separate comparator for MapEntry and MutableMapEntry. + */ + private static class MapEntryAdapter implements Comparable { + private Object entry; + + @SuppressWarnings({"rawtypes"}) + private MapEntry mapEntry; + + + private final FieldDescriptor.JavaType fieldType; + + public MapEntryAdapter(Object entry, FieldDescriptor fieldDescriptor) { + if (entry instanceof MapEntry) { + this.mapEntry = (MapEntry) entry; + } else { + this.entry = entry; + } + this.fieldType = extractFieldType(fieldDescriptor); + } + + private static FieldDescriptor.JavaType extractFieldType(FieldDescriptor fieldDescriptor) { + return fieldDescriptor.getMessageType().getFields().get(0).getJavaType(); + } + + public Object getKey() { + if (mapEntry != null) { + return mapEntry.getKey(); + } + return null; + } + + public Object getEntry() { + if (mapEntry != null) { + return mapEntry; + } + return entry; + } + + @Override + public int compareTo(MapEntryAdapter b) { + if (getKey() == null || b.getKey() == null) { + logger.info("Invalid key for map field."); + return -1; + } + switch (fieldType) { + case BOOLEAN: + boolean aBoolean = (boolean) getKey(); + boolean bBoolean = (boolean) b.getKey(); + if (aBoolean == bBoolean) { + return 0; + } else if (aBoolean) { + return 1; + } else { + return -1; + } + case LONG: + long aLong = (long) getKey(); + long bLong = (long) b.getKey(); + if (aLong < bLong) { + return -1; + } else if (aLong > bLong) { + return 1; + } else { + return 0; + } + case INT: + return (int) getKey() - (int) b.getKey(); + case STRING: + String aString = (String) getKey(); + String bString = (String) b.getKey(); + if (aString == null && bString == null) { + return 0; + } else if (aString == null && bString != null) { + return -1; + } else if (aString != null && bString == null) { + return 1; + } else { + return aString.compareTo(bString); + } + default: + return 0; + } + } + } + /** * Outputs a textual representation of the value of given field value. * @@ -1708,6 +1808,12 @@ private void mergeField( final Descriptor type = target.getDescriptorForType(); ExtensionRegistry.ExtensionInfo extension = null; + if ("google.protobuf.Any".equals(type.getFullName()) && tokenizer.tryConsume("[")) { + mergeAnyFieldValue(tokenizer, extensionRegistry, target, parseTreeBuilder, unknownFields, + type); + return; + } + if (tokenizer.tryConsume("[")) { // An extension. final StringBuilder name = new StringBuilder(tokenizer.consumeIdentifier()); @@ -1928,9 +2034,13 @@ private void consumeFieldValue( // Try to parse human readable format of Any in the form: [type_url]: { ... } if (field.getMessageType().getFullName().equals("google.protobuf.Any") && tokenizer.tryConsume("[")) { - value = - consumeAnyFieldValue( - tokenizer, extensionRegistry, field, parseTreeBuilder, unknownFields); + // Use Proto reflection here since depending on Any would intoduce a cyclic dependency + // (java_proto_library for any_java_proto depends on the protobuf_impl). + Message anyBuilder = DynamicMessage.getDefaultInstance(field.getMessageType()); + MessageReflection.MergeTarget anyField = target.newMergeTargetForField(field, anyBuilder); + mergeAnyFieldValue(tokenizer, extensionRegistry, anyField, parseTreeBuilder, + unknownFields, field.getMessageType()); + value = anyField.finish(); tokenizer.consume(endToken); } else { Message defaultInstance = (extension == null) ? null : extension.defaultInstance; @@ -2052,12 +2162,13 @@ private void consumeFieldValue( } } - private Object consumeAnyFieldValue( + private void mergeAnyFieldValue( final Tokenizer tokenizer, final ExtensionRegistry extensionRegistry, - final FieldDescriptor field, + MergeTarget target, final TextFormatParseInfoTree.Builder parseTreeBuilder, - List unknownFields) + List unknownFields, + Descriptor anyDescriptor) throws ParseException { // Try to parse human readable format of Any in the form: [type_url]: { ... } StringBuilder typeUrlBuilder = new StringBuilder(); @@ -2105,21 +2216,13 @@ private Object consumeAnyFieldValue( mergeField(tokenizer, extensionRegistry, contentTarget, parseTreeBuilder, unknownFields); } - // Serialize the content and put it back into an Any. Note that we can't depend on Any here - // because of a cyclic dependency (java_proto_library for any_java_proto depends on the - // protobuf_impl), so we need to construct the Any using proto reflection. - Descriptor anyDescriptor = field.getMessageType(); - Message.Builder anyBuilder = - DynamicMessage.getDefaultInstance(anyDescriptor).newBuilderForType(); - anyBuilder.setField(anyDescriptor.findFieldByName("type_url"), typeUrlBuilder.toString()); - anyBuilder.setField( + target.setField(anyDescriptor.findFieldByName("type_url"), typeUrlBuilder.toString()); + target.setField( anyDescriptor.findFieldByName("value"), contentBuilder.build().toByteString()); - - return anyBuilder.build(); } /** Skips the next field including the field's name and value. */ - private void skipField(Tokenizer tokenizer) throws ParseException { + private static void skipField(Tokenizer tokenizer) throws ParseException { if (tokenizer.tryConsume("[")) { // Extension name. do { @@ -2151,7 +2254,7 @@ private void skipField(Tokenizer tokenizer) throws ParseException { /** * Skips the whole body of a message including the beginning delimiter and the ending delimiter. */ - private void skipFieldMessage(Tokenizer tokenizer) throws ParseException { + private static void skipFieldMessage(Tokenizer tokenizer) throws ParseException { final String delimiter; if (tokenizer.tryConsume("<")) { delimiter = ">"; @@ -2166,7 +2269,7 @@ private void skipFieldMessage(Tokenizer tokenizer) throws ParseException { } /** Skips a field value. */ - private void skipFieldValue(Tokenizer tokenizer) throws ParseException { + private static void skipFieldValue(Tokenizer tokenizer) throws ParseException { if (tokenizer.tryConsumeString()) { while (tokenizer.tryConsumeString()) {} return; diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java index 2f6315c80d4d..b2cb7be4baef 100644 --- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java +++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java @@ -301,7 +301,7 @@ public int getSerializedSize() { return size; } - private static boolean equals(int[] tags1, int[] tags2, int count) { + private static boolean tagsEquals(int[] tags1, int[] tags2, int count) { for (int i = 0; i < count; ++i) { if (tags1[i] != tags2[i]) { return false; @@ -310,7 +310,7 @@ private static boolean equals(int[] tags1, int[] tags2, int count) { return true; } - private static boolean equals(Object[] objects1, Object[] objects2, int count) { + private static boolean objectsEquals(Object[] objects1, Object[] objects2, int count) { for (int i = 0; i < count; ++i) { if (!objects1[i].equals(objects2[i])) { return false; @@ -335,8 +335,8 @@ public boolean equals(Object obj) { UnknownFieldSetLite other = (UnknownFieldSetLite) obj; if (count != other.count - || !equals(tags, other.tags, count) - || !equals(objects, other.objects, count)) { + || !tagsEquals(tags, other.tags, count) + || !objectsEquals(objects, other.objects, count)) { return false; } diff --git a/java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java b/java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java index ae50071398a3..805b7b042f25 100644 --- a/java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java +++ b/java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java @@ -140,6 +140,68 @@ public void testGetBoolean() { } } + public void testIndexOf_nullElement() { + assertEquals(-1, TERTIARY_LIST.indexOf(null)); + } + + public void testIndexOf_incompatibleElementType() { + assertEquals(-1, TERTIARY_LIST.indexOf(new Object())); + } + + public void testIndexOf_notInList() { + assertEquals(-1, UNARY_LIST.indexOf(false)); + } + + public void testIndexOf_notInListWithDuplicates() { + BooleanArrayList listWithDupes = newImmutableBooleanArrayList(true, true); + assertEquals(-1, listWithDupes.indexOf(false)); + } + + public void testIndexOf_inList() { + assertEquals(1, TERTIARY_LIST.indexOf(false)); + } + + public void testIndexOf_inListWithDuplicates_matchAtHead() { + BooleanArrayList listWithDupes = newImmutableBooleanArrayList(true, true, false); + assertEquals(0, listWithDupes.indexOf(true)); + } + + public void testIndexOf_inListWithDuplicates_matchMidList() { + BooleanArrayList listWithDupes = newImmutableBooleanArrayList(false, true, true, false); + assertEquals(1, listWithDupes.indexOf(true)); + } + + public void testContains_nullElement() { + assertEquals(false, TERTIARY_LIST.contains(null)); + } + + public void testContains_incompatibleElementType() { + assertEquals(false, TERTIARY_LIST.contains(new Object())); + } + + public void testContains_notInList() { + assertEquals(false, UNARY_LIST.contains(false)); + } + + public void testContains_notInListWithDuplicates() { + BooleanArrayList listWithDupes = newImmutableBooleanArrayList(true, true); + assertEquals(false, listWithDupes.contains(false)); + } + + public void testContains_inList() { + assertEquals(true, TERTIARY_LIST.contains(false)); + } + + public void testContains_inListWithDuplicates_matchAtHead() { + BooleanArrayList listWithDupes = newImmutableBooleanArrayList(true, true, false); + assertEquals(true, listWithDupes.contains(true)); + } + + public void testContains_inListWithDuplicates_matchMidList() { + BooleanArrayList listWithDupes = newImmutableBooleanArrayList(false, true, true, false); + assertEquals(true, listWithDupes.contains(true)); + } + public void testSize() { assertEquals(0, BooleanArrayList.emptyList().size()); assertEquals(1, UNARY_LIST.size()); diff --git a/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java b/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java index 3a8254aa69fb..019b5a14444f 100644 --- a/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java +++ b/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java @@ -139,6 +139,68 @@ public void testGetDouble() { } } + public void testIndexOf_nullElement() { + assertEquals(-1, TERTIARY_LIST.indexOf(null)); + } + + public void testIndexOf_incompatibleElementType() { + assertEquals(-1, TERTIARY_LIST.indexOf(new Object())); + } + + public void testIndexOf_notInList() { + assertEquals(-1, UNARY_LIST.indexOf(2D)); + } + + public void testIndexOf_notInListWithDuplicates() { + DoubleArrayList listWithDupes = newImmutableDoubleArrayList(1D, 1D); + assertEquals(-1, listWithDupes.indexOf(2D)); + } + + public void testIndexOf_inList() { + assertEquals(1, TERTIARY_LIST.indexOf(2D)); + } + + public void testIndexOf_inListWithDuplicates_matchAtHead() { + DoubleArrayList listWithDupes = newImmutableDoubleArrayList(1D, 1D, 2D); + assertEquals(0, listWithDupes.indexOf(1D)); + } + + public void testIndexOf_inListWithDuplicates_matchMidList() { + DoubleArrayList listWithDupes = newImmutableDoubleArrayList(2D, 1D, 1D, 2D); + assertEquals(1, listWithDupes.indexOf(1D)); + } + + public void testContains_nullElement() { + assertEquals(false, TERTIARY_LIST.contains(null)); + } + + public void testContains_incompatibleElementType() { + assertEquals(false, TERTIARY_LIST.contains(new Object())); + } + + public void testContains_notInList() { + assertEquals(false, UNARY_LIST.contains(2D)); + } + + public void testContains_notInListWithDuplicates() { + DoubleArrayList listWithDupes = newImmutableDoubleArrayList(1D, 1D); + assertEquals(false, listWithDupes.contains(2D)); + } + + public void testContains_inList() { + assertEquals(true, TERTIARY_LIST.contains(2D)); + } + + public void testContains_inListWithDuplicates_matchAtHead() { + DoubleArrayList listWithDupes = newImmutableDoubleArrayList(1D, 1D, 2D); + assertEquals(true, listWithDupes.contains(1D)); + } + + public void testContains_inListWithDuplicates_matchMidList() { + DoubleArrayList listWithDupes = newImmutableDoubleArrayList(2D, 1D, 1D, 2D); + assertEquals(true, listWithDupes.contains(1D)); + } + public void testSize() { assertEquals(0, DoubleArrayList.emptyList().size()); assertEquals(1, UNARY_LIST.size()); diff --git a/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java b/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java index db4ecfedaa04..53ec6fe68c54 100644 --- a/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java +++ b/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java @@ -34,6 +34,7 @@ import com.google.protobuf.Descriptors.EnumDescriptor; import com.google.protobuf.Descriptors.EnumValueDescriptor; import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.OneofDescriptor; import com.google.protobuf.FieldPresenceTestProto.TestAllTypes; import com.google.protobuf.FieldPresenceTestProto.TestOptionalFieldsOnly; import com.google.protobuf.FieldPresenceTestProto.TestRepeatedFieldsOnly; @@ -100,6 +101,7 @@ public void testHasMethod() { UnittestProto.TestAllTypes.Builder.class, TestAllTypes.Builder.class, "OneofBytes"); } + public void testOneofEquals() throws Exception { TestAllTypes.Builder builder = TestAllTypes.newBuilder(); TestAllTypes message1 = builder.build(); diff --git a/java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java b/java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java index 77a2839b90d7..091ac5bb784e 100644 --- a/java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java +++ b/java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java @@ -139,6 +139,68 @@ public void testGetFloat() { } } + public void testIndexOf_nullElement() { + assertEquals(-1, TERTIARY_LIST.indexOf(null)); + } + + public void testIndexOf_incompatibleElementType() { + assertEquals(-1, TERTIARY_LIST.indexOf(new Object())); + } + + public void testIndexOf_notInList() { + assertEquals(-1, UNARY_LIST.indexOf(2F)); + } + + public void testIndexOf_notInListWithDuplicates() { + FloatArrayList listWithDupes = newImmutableFloatArrayList(1F, 1F); + assertEquals(-1, listWithDupes.indexOf(2F)); + } + + public void testIndexOf_inList() { + assertEquals(1, TERTIARY_LIST.indexOf(2F)); + } + + public void testIndexOf_inListWithDuplicates_matchAtHead() { + FloatArrayList listWithDupes = newImmutableFloatArrayList(1F, 1F, 2F); + assertEquals(0, listWithDupes.indexOf(1F)); + } + + public void testIndexOf_inListWithDuplicates_matchMidList() { + FloatArrayList listWithDupes = newImmutableFloatArrayList(2F, 1F, 1F, 2F); + assertEquals(1, listWithDupes.indexOf(1F)); + } + + public void testContains_nullElement() { + assertEquals(false, TERTIARY_LIST.contains(null)); + } + + public void testContains_incompatibleElementType() { + assertEquals(false, TERTIARY_LIST.contains(new Object())); + } + + public void testContains_notInList() { + assertEquals(false, UNARY_LIST.contains(2F)); + } + + public void testContains_notInListWithDuplicates() { + FloatArrayList listWithDupes = newImmutableFloatArrayList(1F, 1F); + assertEquals(false, listWithDupes.contains(2F)); + } + + public void testContains_inList() { + assertEquals(true, TERTIARY_LIST.contains(2F)); + } + + public void testContains_inListWithDuplicates_matchAtHead() { + FloatArrayList listWithDupes = newImmutableFloatArrayList(1F, 1F, 2F); + assertEquals(true, listWithDupes.contains(1F)); + } + + public void testContains_inListWithDuplicates_matchMidList() { + FloatArrayList listWithDupes = newImmutableFloatArrayList(2F, 1F, 1F, 2F); + assertEquals(true, listWithDupes.contains(1F)); + } + public void testSize() { assertEquals(0, FloatArrayList.emptyList().size()); assertEquals(1, UNARY_LIST.size()); diff --git a/java/core/src/test/java/com/google/protobuf/IntArrayListTest.java b/java/core/src/test/java/com/google/protobuf/IntArrayListTest.java index 51ebc987d03d..2ad94f83de73 100644 --- a/java/core/src/test/java/com/google/protobuf/IntArrayListTest.java +++ b/java/core/src/test/java/com/google/protobuf/IntArrayListTest.java @@ -139,6 +139,68 @@ public void testGetInt() { } } + public void testIndexOf_nullElement() { + assertEquals(-1, TERTIARY_LIST.indexOf(null)); + } + + public void testIndexOf_incompatibleElementType() { + assertEquals(-1, TERTIARY_LIST.indexOf(new Object())); + } + + public void testIndexOf_notInList() { + assertEquals(-1, UNARY_LIST.indexOf(2)); + } + + public void testIndexOf_notInListWithDuplicates() { + IntArrayList listWithDupes = newImmutableIntArrayList(1, 1); + assertEquals(-1, listWithDupes.indexOf(2)); + } + + public void testIndexOf_inList() { + assertEquals(1, TERTIARY_LIST.indexOf(2)); + } + + public void testIndexOf_inListWithDuplicates_matchAtHead() { + IntArrayList listWithDupes = newImmutableIntArrayList(1, 1, 2); + assertEquals(0, listWithDupes.indexOf(1)); + } + + public void testIndexOf_inListWithDuplicates_matchMidList() { + IntArrayList listWithDupes = newImmutableIntArrayList(2, 1, 1, 2); + assertEquals(1, listWithDupes.indexOf(1)); + } + + public void testContains_nullElement() { + assertEquals(false, TERTIARY_LIST.contains(null)); + } + + public void testContains_incompatibleElementType() { + assertEquals(false, TERTIARY_LIST.contains(new Object())); + } + + public void testContains_notInList() { + assertEquals(false, UNARY_LIST.contains(2)); + } + + public void testContains_notInListWithDuplicates() { + IntArrayList listWithDupes = newImmutableIntArrayList(1, 1); + assertEquals(false, listWithDupes.contains(2)); + } + + public void testContains_inList() { + assertEquals(true, TERTIARY_LIST.contains(2)); + } + + public void testContains_inListWithDuplicates_matchAtHead() { + IntArrayList listWithDupes = newImmutableIntArrayList(1, 1, 2); + assertEquals(true, listWithDupes.contains(1)); + } + + public void testContains_inListWithDuplicates_matchMidList() { + IntArrayList listWithDupes = newImmutableIntArrayList(2, 1, 1, 2); + assertEquals(true, listWithDupes.contains(1)); + } + public void testSize() { assertEquals(0, IntArrayList.emptyList().size()); assertEquals(1, UNARY_LIST.size()); diff --git a/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java b/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java index 1935100503d6..d6fbaf9d9506 100644 --- a/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java +++ b/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java @@ -139,6 +139,68 @@ public void testGetLong() { } } + public void testIndexOf_nullElement() { + assertEquals(-1, TERTIARY_LIST.indexOf(null)); + } + + public void testIndexOf_incompatibleElementType() { + assertEquals(-1, TERTIARY_LIST.indexOf(new Object())); + } + + public void testIndexOf_notInList() { + assertEquals(-1, UNARY_LIST.indexOf(2L)); + } + + public void testIndexOf_notInListWithDuplicates() { + LongArrayList listWithDupes = newImmutableLongArrayList(1L, 1L); + assertEquals(-1, listWithDupes.indexOf(2L)); + } + + public void testIndexOf_inList() { + assertEquals(1, TERTIARY_LIST.indexOf(2L)); + } + + public void testIndexOf_inListWithDuplicates_matchAtHead() { + LongArrayList listWithDupes = newImmutableLongArrayList(1L, 1L, 2L); + assertEquals(0, listWithDupes.indexOf(1L)); + } + + public void testIndexOf_inListWithDuplicates_matchMidList() { + LongArrayList listWithDupes = newImmutableLongArrayList(2L, 1L, 1L, 2L); + assertEquals(1, listWithDupes.indexOf(1L)); + } + + public void testContains_nullElement() { + assertEquals(false, TERTIARY_LIST.contains(null)); + } + + public void testContains_incompatibleElementType() { + assertEquals(false, TERTIARY_LIST.contains(new Object())); + } + + public void testContains_notInList() { + assertEquals(false, UNARY_LIST.contains(2L)); + } + + public void testContains_notInListWithDuplicates() { + LongArrayList listWithDupes = newImmutableLongArrayList(1L, 1L); + assertEquals(false, listWithDupes.contains(2L)); + } + + public void testContains_inList() { + assertEquals(true, TERTIARY_LIST.contains(2L)); + } + + public void testContains_inListWithDuplicates_matchAtHead() { + LongArrayList listWithDupes = newImmutableLongArrayList(1L, 1L, 2L); + assertEquals(true, listWithDupes.contains(1L)); + } + + public void testContains_inListWithDuplicates_matchMidList() { + LongArrayList listWithDupes = newImmutableLongArrayList(2L, 1L, 1L, 2L); + assertEquals(true, listWithDupes.contains(1L)); + } + public void testSize() { assertEquals(0, LongArrayList.emptyList().size()); assertEquals(1, UNARY_LIST.size()); diff --git a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java index dd0e8c847cc8..50ba0168daa1 100644 --- a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java +++ b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java @@ -1536,4 +1536,42 @@ private void assertLocation( index, line, column)); } } + + public void testSortMapFields() throws Exception { + TestMap message = + TestMap.newBuilder() + .putStringToInt32Field("cherry", 30) + .putStringToInt32Field("banana", 20) + .putStringToInt32Field("apple", 10) + .putInt32ToStringField(30, "cherry") + .putInt32ToStringField(20, "banana") + .putInt32ToStringField(10, "apple") + .build(); + String text = + "int32_to_string_field {\n" + + " key: 10\n" + + " value: \"apple\"\n" + + "}\n" + + "int32_to_string_field {\n" + + " key: 20\n" + + " value: \"banana\"\n" + + "}\n" + + "int32_to_string_field {\n" + + " key: 30\n" + + " value: \"cherry\"\n" + + "}\n" + + "string_to_int32_field {\n" + + " key: \"apple\"\n" + + " value: 10\n" + + "}\n" + + "string_to_int32_field {\n" + + " key: \"banana\"\n" + + " value: 20\n" + + "}\n" + + "string_to_int32_field {\n" + + " key: \"cherry\"\n" + + " value: 30\n" + + "}\n"; + assertEquals(text, TextFormat.printer().printToString(message)); + } } diff --git a/java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java b/java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java index 4a1d89b93704..57e933f3a42e 100755 --- a/java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java +++ b/java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java @@ -177,16 +177,20 @@ private MessageInfo newRawMessageInfoForProto2MessageLite() { // To update this after a proto change, run protoc on proto2_message_lite.proto and copy over // the content of the generated buildMessageInfo() method here. java.lang.String info = - "\u0001U\u0001\u0002\u0001XU\u0000 \u0015\u0001\u0000\u0000\u0002\u0001\u0001\u0003" - + "\u0002\u0002\u0004\u0003\u0003\u0005\u0004\u0004\u0006\u0005\u0005\u0007\u0006\u0006" - + "\b\u0007\u0007\t\b\b\n\u0409\t\u000b\n\n\f\u000b\u000b\r\f\f\u000e\r\r\u000f\u000e" - + "\u000e\u0010\u000f\u000f\u0011\u0010\u0010\u0012\u0012\u0013\u0013\u0014\u0014\u0015" - + "\u0015\u0016\u0016\u0017\u0017\u0018\u0018\u0019\u0019\u001a\u001a\u001b\u041b\u001c" - + "\u001c\u001d\u001d\u001e\u001e\u001f\u001f !!\"\"##$$%%&&\'\'(())**++,,--..//00" - + "1\u0011\u00113153\u000064\u000075\u000086\u000097\u0000:8\u0000;9\u0000<:\u0000=" - + ";\u0000>\u043c\u0000?=\u0000@>\u0000A@\u0000BA\u0000CB\u0000DC\u0000ED\u0000G\u0500" - + "#H\u0501$I\u0502%J\u0503&K\u0504\'L\u0505(M\u0506)N\u0507*O\u0508+P\u0509,Q\u050a" - + "-R\u050b.S\u050c/T\u050d0U\u050e1V\u050f2W\u05103X\u05114"; + "\u0001U\u0001\u0002\u0001XU\u0000 \u0015\u0001\u1000\u0000\u0002\u1001\u0001\u0003" + + "\u1002\u0002\u0004\u1003\u0003\u0005\u1004\u0004\u0006\u1005\u0005\u0007\u1006\u0006\b\u1007\u0007" + + "\t\u1008\b\n" + + "\u1409\t\u000b\u100a\n" + + "\f\u100b\u000b\r" + + "\u100c\f\u000e\u100d\r" + + "\u000f\u100e\u000e\u0010\u100f\u000f\u0011\u1010\u0010\u0012\u0012\u0013\u0013" + + "\u0014\u0014\u0015\u0015\u0016\u0016\u0017\u0017\u0018\u0018\u0019\u0019\u001a\u001a\u001b\u041b\u001c\u001c\u001d\u001d\u001e\u001e\u001f\u001f" + + " !!\"\"##$$%%&&\'\'" + + "(())**++,,--..//001\u1011\u0011315\u1033\u00006\u1034\u00007\u1035\u00008\u1036\u0000" + + "9\u1037\u0000:\u1038\u0000;\u1039\u0000<\u103a\u0000=\u103b\u0000>\u143c\u0000?\u103d" + + "\u0000@\u103e\u0000A\u1040\u0000B\u1041\u0000C\u1042\u0000D\u1043\u0000E\u1044\u0000" + + "G\u1500#H\u1501$I\u1502%J\u1503&K\u1504\'L\u1505(M\u1506)N\u1507*O\u1508+P\u1509" + + ",Q\u150a-R\u150b.S\u150c/T\u150d0U\u150e1V\u150f2W\u15103X\u15114"; return new RawMessageInfo(Proto2MessageLite.getDefaultInstance(), info, objects); } diff --git a/java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java b/java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java index 92458226ab59..312d30fe2232 100644 --- a/java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java +++ b/java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java @@ -34,6 +34,7 @@ import com.google.common.base.CaseFormat; import com.google.common.base.Joiner; +import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.primitives.Ints; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -49,7 +50,7 @@ /** * Utility helper functions to work with {@link com.google.protobuf.FieldMask}. */ -public class FieldMaskUtil { +public final class FieldMaskUtil { private static final String FIELD_PATH_SEPARATOR = ","; private static final String FIELD_PATH_SEPARATOR_REGEX = ","; private static final String FIELD_SEPARATOR_REGEX = "\\."; @@ -83,7 +84,7 @@ public static String toString(FieldMask fieldMask) { */ public static FieldMask fromString(String value) { // TODO(xiaofeng): Consider using com.google.common.base.Splitter here instead. - return fromStringList(null, Arrays.asList(value.split(FIELD_PATH_SEPARATOR_REGEX))); + return fromStringList(Arrays.asList(value.split(FIELD_PATH_SEPARATOR_REGEX))); } /** @@ -103,14 +104,36 @@ public static FieldMask fromString(Class type, String value) */ // TODO(xiaofeng): Consider renaming fromStrings() public static FieldMask fromStringList(Class type, Iterable paths) { + return fromStringList(Internal.getDefaultInstance(type).getDescriptorForType(), paths); + } + + /** + * Constructs a FieldMask for a list of field paths in a certain type. + * + * @throws IllegalArgumentException if any of the field path is not valid. + */ + public static FieldMask fromStringList(Descriptor descriptor, Iterable paths) { + return fromStringList(Optional.of(descriptor), paths); + } + + /** + * Constructs a FieldMask for a list of field paths in a certain type. Does not validate the given + * paths. + */ + public static FieldMask fromStringList(Iterable paths) { + return fromStringList(Optional.absent(), paths); + } + + private static FieldMask fromStringList(Optional descriptor, Iterable paths) { FieldMask.Builder builder = FieldMask.newBuilder(); for (String path : paths) { if (path.isEmpty()) { // Ignore empty field paths. continue; } - if (type != null && !isValid(type, path)) { - throw new IllegalArgumentException(path + " is not a valid path for " + type); + if (descriptor.isPresent() && !isValid(descriptor.get(), path)) { + throw new IllegalArgumentException( + path + " is not a valid path for " + descriptor.get().getFullName()); } builder.addPaths(path); } diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java index d9bcf8970ac7..67981435d12d 100644 --- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java +++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java @@ -233,7 +233,7 @@ public Printer printingEnumsAsInts() { registry, oldRegistry, alwaysOutputDefaultValueFields, - Collections.emptySet(), + includingDefaultValueFields, preservingProtoFieldNames, omittingInsignificantWhitespace, true, diff --git a/java/util/src/main/java/com/google/protobuf/util/Values.java b/java/util/src/main/java/com/google/protobuf/util/Values.java index b3ade2ddfb7e..f03d70e0dcd3 100755 --- a/java/util/src/main/java/com/google/protobuf/util/Values.java +++ b/java/util/src/main/java/com/google/protobuf/util/Values.java @@ -71,8 +71,8 @@ public static Value of(ListValue value) { } /** - * Returns a Value with ListValue set to the appending the result of calling {@link #of(Object)} - * on each element in the iterable. + * Returns a Value with ListValue set to the appending the result of calling {@link #of} on each + * element in the iterable. */ public static Value of(Iterable values) { Value.Builder valueBuilder = Value.newBuilder(); diff --git a/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java b/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java index 1a998570532b..78b470eda7ec 100644 --- a/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java +++ b/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java @@ -30,10 +30,12 @@ package com.google.protobuf.util; +import static com.google.common.truth.Truth.assertThat; + +import com.google.common.collect.ImmutableList; import com.google.protobuf.FieldMask; import protobuf_unittest.UnittestProto.NestedTestAllTypes; import protobuf_unittest.UnittestProto.TestAllTypes; - import junit.framework.TestCase; /** Unit tests for {@link FieldMaskUtil}. */ @@ -172,6 +174,38 @@ public void testFromJsonString() throws Exception { assertEquals("bar_baz", mask.getPaths(1)); } + public void testFromStringList() throws Exception { + FieldMask mask = + FieldMaskUtil.fromStringList( + NestedTestAllTypes.class, ImmutableList.of("payload.repeated_nested_message", "child")); + assertThat(mask) + .isEqualTo( + FieldMask.newBuilder() + .addPaths("payload.repeated_nested_message") + .addPaths("child") + .build()); + + mask = + FieldMaskUtil.fromStringList( + NestedTestAllTypes.getDescriptor(), + ImmutableList.of("payload.repeated_nested_message", "child")); + assertThat(mask) + .isEqualTo( + FieldMask.newBuilder() + .addPaths("payload.repeated_nested_message") + .addPaths("child") + .build()); + + mask = + FieldMaskUtil.fromStringList(ImmutableList.of("payload.repeated_nested_message", "child")); + assertThat(mask) + .isEqualTo( + FieldMask.newBuilder() + .addPaths("payload.repeated_nested_message") + .addPaths("child") + .build()); + } + public void testUnion() throws Exception { // Only test a simple case here and expect // {@link FieldMaskTreeTest#testAddFieldPath} to cover all scenarios. diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java index a06483192fb0..f9358e522141 100644 --- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java +++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java @@ -30,6 +30,7 @@ package com.google.protobuf.util; +import com.google.common.collect.ImmutableSet; import com.google.protobuf.Any; import com.google.protobuf.BoolValue; import com.google.protobuf.ByteString; @@ -1784,4 +1785,16 @@ public void testSortedMapKeys() throws Exception { TestMap emptyMap = TestMap.getDefaultInstance(); assertEquals("{\n}", toSortedJsonString(emptyMap)); } + + public void testPrintingEnumsAsIntsChainedAfterIncludingDefaultValueFields() throws Exception { + TestAllTypes message = TestAllTypes.newBuilder().setOptionalBool(false).build(); + + assertEquals( + "{\n" + " \"optionalBool\": false\n" + "}", + JsonFormat.printer() + .includingDefaultValueFields( + ImmutableSet.of(message.getDescriptorForType().findFieldByName("optional_bool"))) + .printingEnumsAsInts() + .print(message)); + } } diff --git a/js/message_test.js b/js/message_test.js index 3cac4c668d9d..3db8716b8c52 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -1080,7 +1080,7 @@ describe('Message test suite', function() { it('testMessageWithLargeFieldNumbers', function() { var message = new proto.jspb.test.MessageWithLargeFieldNumbers; - + message.setAString('string'); assertEquals('string', message.getAString()); diff --git a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php index e6362f2bfb51..ea0edc55575a 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php @@ -72,6 +72,7 @@ public static function initOnce() { ->optional('oneof_index', \Google\Protobuf\Internal\GPBType::INT32, 9) ->optional('json_name', \Google\Protobuf\Internal\GPBType::STRING, 10) ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.FieldOptions') + ->optional('proto3_optional', \Google\Protobuf\Internal\GPBType::BOOL, 17) ->finalizeToPool(); $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Type', \Google\Protobuf\Internal\Type::class) diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index b231c9e1021e..e00488e12ea2 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -93,6 +93,20 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message */ protected $options = null; private $has_options = false; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * For message fields this doesn't create any semantic change, since + * non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + * + * Generated from protobuf field optional bool proto3_optional = 17; + */ + protected $proto3_optional = false; + private $has_proto3_optional = false; /** * Constructor. @@ -130,6 +144,15 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * will be used. Otherwise, it's deduced from the field's name by converting * it to camelCase. * @type \Google\Protobuf\Internal\FieldOptions $options + * @type bool $proto3_optional + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * For message fields this doesn't create any semantic change, since + * non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. * } */ public function __construct($data = NULL) { @@ -469,5 +492,51 @@ public function hasOptions() return $this->has_options; } + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * For message fields this doesn't create any semantic change, since + * non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + * + * Generated from protobuf field optional bool proto3_optional = 17; + * @return bool + */ + public function getProto3Optional() + { + return $this->proto3_optional; + } + + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * For message fields this doesn't create any semantic change, since + * non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + * + * Generated from protobuf field optional bool proto3_optional = 17; + * @param bool $var + * @return $this + */ + public function setProto3Optional($var) + { + GPBUtil::checkBool($var); + $this->proto3_optional = $var; + $this->has_proto3_optional = true; + + return $this; + } + + public function hasProto3Optional() + { + return $this->has_proto3_optional; + } + } diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 605d92bfda74..892a6a848238 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -127,7 +127,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * Enables the use of arenas for the proto messages in this file. This applies * only to generated classes for C++. * - * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; + * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = true]; */ protected $cc_enable_arenas = false; private $has_cc_enable_arenas = false; @@ -732,7 +732,7 @@ public function hasDeprecated() * Enables the use of arenas for the proto messages in this file. This applies * only to generated classes for C++. * - * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; + * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = true]; * @return bool */ public function getCcEnableArenas() @@ -744,7 +744,7 @@ public function getCcEnableArenas() * Enables the use of arenas for the proto messages in this file. This applies * only to generated classes for C++. * - * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; + * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = true]; * @param bool $var * @return $this */ diff --git a/python/google/protobuf/descriptor.py b/python/google/protobuf/descriptor.py index 204f89b254c1..5ef81a229835 100755 --- a/python/google/protobuf/descriptor.py +++ b/python/google/protobuf/descriptor.py @@ -35,6 +35,7 @@ __author__ = 'robinson@google.com (Will Robinson)' import threading +import warnings import six from google.protobuf.internal import api_implementation @@ -91,6 +92,25 @@ def __exit__(self, exc_type, exc_value, exc_tb): _lock = threading.Lock() +def _Deprecated(name): + if _Deprecated.count > 0: + _Deprecated.count -= 1 + warnings.warn( + 'Call to deprecated create function %s(). Note: Create unlinked ' + 'descriptors is going to go away. Please use get/find descriptors from ' + 'generated code or query the descriptor_pool.' + % name, + category=DeprecationWarning, stacklevel=3) + + +# Deprecated warnings will print 100 times at most which should be enough for +# users to notice and do not cause timeout. +_Deprecated.count = 100 + + +_internal_create_key = object() + + class DescriptorBase(six.with_metaclass(DescriptorMetaclass)): """Descriptors base class. @@ -271,7 +291,7 @@ def __new__(cls, name, full_name, filename, containing_type, fields, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, # pylint: disable=redefined-builtin - syntax=None): + syntax=None, create_key=None): _message.Message._CheckCalledFromGeneratedFile() return _message.default_pool.FindMessageTypeByName(full_name) @@ -283,13 +303,16 @@ def __init__(self, name, full_name, filename, containing_type, fields, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, # pylint: disable=redefined-builtin - syntax=None): + syntax=None, create_key=None): """Arguments to __init__() are as described in the description of Descriptor fields above. Note that filename is an obsolete argument, that is not used anymore. Please use file.name to access this as an attribute. """ + if create_key is not _internal_create_key: + _Deprecated('Descriptor') + super(Descriptor, self).__init__( options, 'MessageOptions', name, full_name, file, containing_type, serialized_start=serialized_start, @@ -515,7 +538,7 @@ def __new__(cls, name, full_name, index, number, type, cpp_type, label, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, - file=None): # pylint: disable=redefined-builtin + file=None, create_key=None): # pylint: disable=redefined-builtin _message.Message._CheckCalledFromGeneratedFile() if is_extension: return _message.default_pool.FindExtensionByName(full_name) @@ -527,7 +550,7 @@ def __init__(self, name, full_name, index, number, type, cpp_type, label, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, - file=None): # pylint: disable=redefined-builtin + file=None, create_key=None): # pylint: disable=redefined-builtin """The arguments are as described in the description of FieldDescriptor attributes above. @@ -535,6 +558,9 @@ def __init__(self, name, full_name, index, number, type, cpp_type, label, (to deal with circular references between message types, for example). Likewise for extension_scope. """ + if create_key is not _internal_create_key: + _Deprecated('FieldDescriptor') + super(FieldDescriptor, self).__init__( options, serialized_options, 'FieldOptions') self.name = name @@ -628,19 +654,22 @@ class EnumDescriptor(_NestedDescriptorBase): def __new__(cls, name, full_name, filename, values, containing_type=None, options=None, serialized_options=None, file=None, # pylint: disable=redefined-builtin - serialized_start=None, serialized_end=None): + serialized_start=None, serialized_end=None, create_key=None): _message.Message._CheckCalledFromGeneratedFile() return _message.default_pool.FindEnumTypeByName(full_name) def __init__(self, name, full_name, filename, values, containing_type=None, options=None, serialized_options=None, file=None, # pylint: disable=redefined-builtin - serialized_start=None, serialized_end=None): + serialized_start=None, serialized_end=None, create_key=None): """Arguments are as described in the attribute description above. Note that filename is an obsolete argument, that is not used anymore. Please use file.name to access this as an attribute. """ + if create_key is not _internal_create_key: + _Deprecated('EnumDescriptor') + super(EnumDescriptor, self).__init__( options, 'EnumOptions', name, full_name, file, containing_type, serialized_start=serialized_start, @@ -684,7 +713,7 @@ class EnumValueDescriptor(DescriptorBase): def __new__(cls, name, index, number, type=None, # pylint: disable=redefined-builtin - options=None, serialized_options=None): + options=None, serialized_options=None, create_key=None): _message.Message._CheckCalledFromGeneratedFile() # There is no way we can build a complete EnumValueDescriptor with the # given parameters (the name of the Enum is not known, for example). @@ -694,8 +723,11 @@ def __new__(cls, name, index, number, def __init__(self, name, index, number, type=None, # pylint: disable=redefined-builtin - options=None, serialized_options=None): + options=None, serialized_options=None, create_key=None): """Arguments are as described in the attribute description above.""" + if create_key is not _internal_create_key: + _Deprecated('EnumValueDescriptor') + super(EnumValueDescriptor, self).__init__( options, serialized_options, 'EnumValueOptions') self.name = name @@ -724,14 +756,17 @@ class OneofDescriptor(DescriptorBase): def __new__( cls, name, full_name, index, containing_type, fields, options=None, - serialized_options=None): + serialized_options=None, create_key=None): _message.Message._CheckCalledFromGeneratedFile() return _message.default_pool.FindOneofByName(full_name) def __init__( self, name, full_name, index, containing_type, fields, options=None, - serialized_options=None): + serialized_options=None, create_key=None): """Arguments are as described in the attribute description above.""" + if create_key is not _internal_create_key: + _Deprecated('OneofDescriptor') + super(OneofDescriptor, self).__init__( options, serialized_options, 'OneofOptions') self.name = name @@ -765,13 +800,16 @@ class ServiceDescriptor(_NestedDescriptorBase): def __new__(cls, name, full_name, index, methods, options=None, serialized_options=None, file=None, # pylint: disable=redefined-builtin - serialized_start=None, serialized_end=None): + serialized_start=None, serialized_end=None, create_key=None): _message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access return _message.default_pool.FindServiceByName(full_name) def __init__(self, name, full_name, index, methods, options=None, serialized_options=None, file=None, # pylint: disable=redefined-builtin - serialized_start=None, serialized_end=None): + serialized_start=None, serialized_end=None, create_key=None): + if create_key is not _internal_create_key: + _Deprecated('ServiceDescriptor') + super(ServiceDescriptor, self).__init__( options, 'ServiceOptions', name, full_name, file, None, serialized_start=serialized_start, @@ -826,17 +864,22 @@ class MethodDescriptor(DescriptorBase): _C_DESCRIPTOR_CLASS = _message.MethodDescriptor def __new__(cls, name, full_name, index, containing_service, - input_type, output_type, options=None, serialized_options=None): + input_type, output_type, options=None, serialized_options=None, + create_key=None): _message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access return _message.default_pool.FindMethodByName(full_name) def __init__(self, name, full_name, index, containing_service, - input_type, output_type, options=None, serialized_options=None): + input_type, output_type, options=None, serialized_options=None, + create_key=None): """The arguments are as described in the description of MethodDescriptor attributes above. Note that containing_service may be None, and may be set later if necessary. """ + if create_key is not _internal_create_key: + _Deprecated('MethodDescriptor') + super(MethodDescriptor, self).__init__( options, serialized_options, 'MethodOptions') self.name = name @@ -884,11 +927,11 @@ class FileDescriptor(DescriptorBase): def __new__(cls, name, package, options=None, serialized_options=None, serialized_pb=None, dependencies=None, public_dependencies=None, - syntax=None, pool=None): + syntax=None, pool=None, create_key=None): # FileDescriptor() is called from various places, not only from generated # files, to register dynamic proto files and messages. # pylint: disable=g-explicit-bool-comparison - if serialized_pb == '': + if serialized_pb == b'': # Cpp generated code must be linked in if serialized_pb is '' try: return _message.default_pool.FindFileByName(name) @@ -902,8 +945,11 @@ def __new__(cls, name, package, options=None, def __init__(self, name, package, options=None, serialized_options=None, serialized_pb=None, dependencies=None, public_dependencies=None, - syntax=None, pool=None): + syntax=None, pool=None, create_key=None): """Constructor.""" + if create_key is not _internal_create_key: + _Deprecated('FileDescriptor') + super(FileDescriptor, self).__init__( options, serialized_options, 'FileOptions') @@ -1042,9 +1088,11 @@ def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, for enum_proto in desc_proto.enum_type: full_name = '.'.join(full_message_name + [enum_proto.name]) enum_desc = EnumDescriptor( - enum_proto.name, full_name, None, [ - EnumValueDescriptor(enum_val.name, ii, enum_val.number) - for ii, enum_val in enumerate(enum_proto.value)]) + enum_proto.name, full_name, None, [ + EnumValueDescriptor(enum_val.name, ii, enum_val.number, + create_key=_internal_create_key) + for ii, enum_val in enumerate(enum_proto.value)], + create_key=_internal_create_key) enum_types[full_name] = enum_desc # Create Descriptors for nested types @@ -1083,10 +1131,11 @@ def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, FieldDescriptor.ProtoTypeToCppProtoType(field_proto.type), field_proto.label, None, nested_desc, enum_desc, None, False, None, options=_OptionsOrNone(field_proto), has_default_value=False, - json_name=json_name) + json_name=json_name, create_key=_internal_create_key) fields.append(field) desc_name = '.'.join(full_message_name) return Descriptor(desc_proto.name, desc_name, None, None, fields, list(nested_types.values()), list(enum_types.values()), [], - options=_OptionsOrNone(desc_proto)) + options=_OptionsOrNone(desc_proto), + create_key=_internal_create_key) diff --git a/python/google/protobuf/descriptor_pool.py b/python/google/protobuf/descriptor_pool.py index 078d39a9f5ec..de9100b09ca5 100644 --- a/python/google/protobuf/descriptor_pool.py +++ b/python/google/protobuf/descriptor_pool.py @@ -619,7 +619,7 @@ def FindExtensionByNumber(self, message_descriptor, number): def FindAllExtensions(self, message_descriptor): """Gets all the known extensions of a given message. - Extensions have to be registered to this pool by calling + Extensions have to be registered to this pool by build related :func:`Add` or :func:`AddExtensionDescriptor`. Args: @@ -662,18 +662,7 @@ def _TryLoadExtensionFromDB(self, message_descriptor, number): return try: - file_desc = self._ConvertFileProtoToFileDescriptor(file_proto) - for extension in file_desc.extensions_by_name.values(): - self._extensions_by_number[extension.containing_type][ - extension.number] = extension - self._extensions_by_name[extension.containing_type][ - extension.full_name] = extension - for message_type in file_desc.message_types_by_name.values(): - for extension in message_type.extensions: - self._extensions_by_number[extension.containing_type][ - extension.number] = extension - self._extensions_by_name[extension.containing_type][ - extension.full_name] = extension + self._ConvertFileProtoToFileDescriptor(file_proto) except: warn_msg = ('Unable to load proto file %s for extension number %d.' % (file_proto.name, number)) @@ -761,7 +750,9 @@ def _ConvertFileProtoToFileDescriptor(self, file_proto): options=_OptionsOrNone(file_proto), serialized_pb=file_proto.SerializeToString(), dependencies=direct_deps, - public_dependencies=public_deps) + public_dependencies=public_deps, + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) scope = {} # This loop extracts all the message and enum types from all the @@ -820,7 +811,15 @@ def _ConvertFileProtoToFileDescriptor(self, file_proto): self.Add(file_proto) self._file_descriptors[file_proto.name] = file_descriptor - return self._file_descriptors[file_proto.name] + # Add extensions to the pool + file_desc = self._file_descriptors[file_proto.name] + for extension in file_desc.extensions_by_name.values(): + self._AddExtensionDescriptor(extension) + for message_type in file_desc.message_types_by_name.values(): + for extension in message_type.extensions: + self._AddExtensionDescriptor(extension) + + return file_desc def _ConvertMessageDescriptor(self, desc_proto, package=None, file_desc=None, scope=None, syntax=None): @@ -865,8 +864,11 @@ def _ConvertMessageDescriptor(self, desc_proto, package=None, file_desc=None, is_extension=True) for index, extension in enumerate(desc_proto.extension)] oneofs = [ + # pylint: disable=g-complex-comprehension descriptor.OneofDescriptor(desc.name, '.'.join((desc_name, desc.name)), - index, None, [], desc.options) + index, None, [], desc.options, + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) for index, desc in enumerate(desc_proto.oneof_decl)] extension_ranges = [(r.start, r.end) for r in desc_proto.extension_range] if extension_ranges: @@ -889,7 +891,9 @@ def _ConvertMessageDescriptor(self, desc_proto, package=None, file_desc=None, file=file_desc, serialized_start=None, serialized_end=None, - syntax=syntax) + syntax=syntax, + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) for nested in desc.nested_types: nested.containing_type = desc for enum in desc.enum_types: @@ -940,7 +944,9 @@ def _ConvertEnumDescriptor(self, enum_proto, package=None, file_desc=None, file=file_desc, values=values, containing_type=containing_type, - options=_OptionsOrNone(enum_proto)) + options=_OptionsOrNone(enum_proto), + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) scope['.%s' % enum_name] = desc self._CheckConflictRegister(desc, desc.full_name, desc.file.name) self._enum_descriptors[enum_name] = desc @@ -997,7 +1003,9 @@ def _MakeFieldDescriptor(self, field_proto, message_name, index, is_extension=is_extension, extension_scope=None, options=_OptionsOrNone(field_proto), - file=file_desc) + file=file_desc, + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) def _SetAllFieldTypes(self, package, desc_proto, scope): """Sets all the descriptor's fields's types. @@ -1121,7 +1129,9 @@ def _MakeEnumValueDescriptor(self, value_proto, index): index=index, number=value_proto.number, options=_OptionsOrNone(value_proto), - type=None) + type=None, + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) def _MakeServiceDescriptor(self, service_proto, service_index, scope, package, file_desc): @@ -1146,12 +1156,15 @@ def _MakeServiceDescriptor(self, service_proto, service_index, scope, methods = [self._MakeMethodDescriptor(method_proto, service_name, package, scope, index) for index, method_proto in enumerate(service_proto.method)] - desc = descriptor.ServiceDescriptor(name=service_proto.name, - full_name=service_name, - index=service_index, - methods=methods, - options=_OptionsOrNone(service_proto), - file=file_desc) + desc = descriptor.ServiceDescriptor( + name=service_proto.name, + full_name=service_name, + index=service_index, + methods=methods, + options=_OptionsOrNone(service_proto), + file=file_desc, + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) self._CheckConflictRegister(desc, desc.full_name, desc.file.name) self._service_descriptors[service_name] = desc return desc @@ -1175,13 +1188,16 @@ def _MakeMethodDescriptor(self, method_proto, service_name, package, scope, package, method_proto.input_type, scope) output_type = self._GetTypeFromScope( package, method_proto.output_type, scope) - return descriptor.MethodDescriptor(name=method_proto.name, - full_name=full_name, - index=index, - containing_service=None, - input_type=input_type, - output_type=output_type, - options=_OptionsOrNone(method_proto)) + return descriptor.MethodDescriptor( + name=method_proto.name, + full_name=full_name, + index=index, + containing_service=None, + input_type=input_type, + output_type=output_type, + options=_OptionsOrNone(method_proto), + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) def _ExtractSymbols(self, descriptors): """Pulls out all the symbols from descriptor protos. diff --git a/python/google/protobuf/internal/decoder.py b/python/google/protobuf/internal/decoder.py index c04df8e294a1..092dab5862a2 100755 --- a/python/google/protobuf/internal/decoder.py +++ b/python/google/protobuf/internal/decoder.py @@ -816,8 +816,12 @@ def DecodeItem(buffer, pos, end, message, field_dict): if extension is not None: value = field_dict.get(extension) if value is None: + message_type = extension.message_type + if not hasattr(message_type, '_concrete_class'): + # pylint: disable=protected-access + message._FACTORY.GetPrototype(message_type) value = field_dict.setdefault( - extension, extension.message_type._concrete_class()) + extension, message_type._concrete_class()) if value._InternalParse(buffer, message_start,message_end) != message_end: # The only reason _InternalParse would return early is if it encountered # an end-group tag. diff --git a/python/google/protobuf/internal/descriptor_pool_test.py b/python/google/protobuf/internal/descriptor_pool_test.py index ad1eb653fd78..fed82bfc7ab7 100644 --- a/python/google/protobuf/internal/descriptor_pool_test.py +++ b/python/google/protobuf/internal/descriptor_pool_test.py @@ -36,6 +36,7 @@ import copy import os +import warnings try: import unittest2 as unittest #PY26 @@ -63,6 +64,9 @@ +warnings.simplefilter('error', DeprecationWarning) + + class DescriptorPoolTestBase(object): def testFindFileByName(self): @@ -336,12 +340,10 @@ def testFindAllExtensions(self): 'google.protobuf.python.internal.Factory2Message') # An extension defined in a message. one_more_field = factory2_message.extensions_by_name['one_more_field'] - self.pool.AddExtensionDescriptor(one_more_field) # An extension defined at file scope. factory_test2 = self.pool.FindFileByName( 'google/protobuf/internal/factory_test2.proto') another_field = factory_test2.extensions_by_name['another_field'] - self.pool.AddExtensionDescriptor(another_field) extensions = self.pool.FindAllExtensions(factory1_message) expected_extension_numbers = set([one_more_field, another_field]) @@ -356,16 +358,9 @@ def testFindAllExtensions(self): def testFindExtensionByNumber(self): factory1_message = self.pool.FindMessageTypeByName( 'google.protobuf.python.internal.Factory1Message') - factory2_message = self.pool.FindMessageTypeByName( - 'google.protobuf.python.internal.Factory2Message') - # An extension defined in a message. - one_more_field = factory2_message.extensions_by_name['one_more_field'] - self.pool.AddExtensionDescriptor(one_more_field) - # An extension defined at file scope. - factory_test2 = self.pool.FindFileByName( + # Build factory_test2.proto which will put extensions to the pool + self.pool.FindFileByName( 'google/protobuf/internal/factory_test2.proto') - another_field = factory_test2.extensions_by_name['another_field'] - self.pool.AddExtensionDescriptor(another_field) # An extension defined in a message. extension = self.pool.FindExtensionByNumber(factory1_message, 1001) @@ -533,13 +528,13 @@ def testConflictRegister(self): else: pool = copy.deepcopy(self.pool) file_descriptor = unittest_pb2.DESCRIPTOR - pool.AddDescriptor( + pool._AddDescriptor( file_descriptor.message_types_by_name['TestAllTypes']) - pool.AddEnumDescriptor( + pool._AddEnumDescriptor( file_descriptor.enum_types_by_name['ForeignEnum']) - pool.AddServiceDescriptor( + pool._AddServiceDescriptor( file_descriptor.services_by_name['TestService']) - pool.AddExtensionDescriptor( + pool._AddExtensionDescriptor( file_descriptor.extensions_by_name['optional_int32_extension']) pool.Add(unittest_fd) pool.Add(conflict_fd) @@ -873,7 +868,7 @@ class AddDescriptorTest(unittest.TestCase): def _TestMessage(self, prefix): pool = descriptor_pool.DescriptorPool() - pool.AddDescriptor(unittest_pb2.TestAllTypes.DESCRIPTOR) + pool._AddDescriptor(unittest_pb2.TestAllTypes.DESCRIPTOR) self.assertEqual( 'protobuf_unittest.TestAllTypes', pool.FindMessageTypeByName( @@ -884,7 +879,7 @@ def _TestMessage(self, prefix): pool.FindMessageTypeByName( prefix + 'protobuf_unittest.TestAllTypes.NestedMessage') - pool.AddDescriptor(unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR) + pool._AddDescriptor(unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR) self.assertEqual( 'protobuf_unittest.TestAllTypes.NestedMessage', pool.FindMessageTypeByName( @@ -909,7 +904,10 @@ def testMessage(self): def _TestEnum(self, prefix): pool = descriptor_pool.DescriptorPool() - pool.AddEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR) + if api_implementation.Type() == 'cpp': + pool.AddEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR) + else: + pool._AddEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR) self.assertEqual( 'protobuf_unittest.ForeignEnum', pool.FindEnumTypeByName( @@ -920,7 +918,10 @@ def _TestEnum(self, prefix): pool.FindEnumTypeByName( prefix + 'protobuf_unittest.ForeignEnum.NestedEnum') - pool.AddEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR) + if api_implementation.Type() == 'cpp': + pool.AddEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR) + else: + pool._AddEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR) self.assertEqual( 'protobuf_unittest.TestAllTypes.NestedEnum', pool.FindEnumTypeByName( @@ -949,7 +950,7 @@ def testService(self): pool = descriptor_pool.DescriptorPool() with self.assertRaises(KeyError): pool.FindServiceByName('protobuf_unittest.TestService') - pool.AddServiceDescriptor(unittest_pb2._TESTSERVICE) + pool._AddServiceDescriptor(unittest_pb2._TESTSERVICE) self.assertEqual( 'protobuf_unittest.TestService', pool.FindServiceByName('protobuf_unittest.TestService').full_name) @@ -958,7 +959,7 @@ def testService(self): 'With the cpp implementation, Add() must be called first') def testFile(self): pool = descriptor_pool.DescriptorPool() - pool.AddFileDescriptor(unittest_pb2.DESCRIPTOR) + pool._AddFileDescriptor(unittest_pb2.DESCRIPTOR) self.assertEqual( 'google/protobuf/unittest.proto', pool.FindFileByName( @@ -1032,16 +1033,28 @@ def testFileDescriptorOptionsWithCustomDescriptorPool(self): def testAddTypeError(self): pool = descriptor_pool.DescriptorPool() - with self.assertRaises(TypeError): - pool.AddDescriptor(0) - with self.assertRaises(TypeError): - pool.AddEnumDescriptor(0) - with self.assertRaises(TypeError): - pool.AddServiceDescriptor(0) - with self.assertRaises(TypeError): - pool.AddExtensionDescriptor(0) - with self.assertRaises(TypeError): - pool.AddFileDescriptor(0) + if api_implementation.Type() == 'cpp': + with self.assertRaises(TypeError): + pool.AddDescriptor(0) + with self.assertRaises(TypeError): + pool.AddEnumDescriptor(0) + with self.assertRaises(TypeError): + pool.AddServiceDescriptor(0) + with self.assertRaises(TypeError): + pool.AddExtensionDescriptor(0) + with self.assertRaises(TypeError): + pool.AddFileDescriptor(0) + else: + with self.assertRaises(TypeError): + pool._AddDescriptor(0) + with self.assertRaises(TypeError): + pool._AddEnumDescriptor(0) + with self.assertRaises(TypeError): + pool._AddServiceDescriptor(0) + with self.assertRaises(TypeError): + pool._AddExtensionDescriptor(0) + with self.assertRaises(TypeError): + pool._AddFileDescriptor(0) TEST1_FILE = ProtoFile( diff --git a/python/google/protobuf/internal/descriptor_test.py b/python/google/protobuf/internal/descriptor_test.py index bff2d5f54881..5e3b0a9b4c9a 100755 --- a/python/google/protobuf/internal/descriptor_test.py +++ b/python/google/protobuf/internal/descriptor_test.py @@ -35,6 +35,7 @@ __author__ = 'robinson@google.com (Will Robinson)' import sys +import warnings try: import unittest2 as unittest #PY26 @@ -58,6 +59,9 @@ """ +warnings.simplefilter('error', DeprecationWarning) + + class DescriptorTest(unittest.TestCase): def setUp(self): diff --git a/python/google/protobuf/internal/extension_dict.py b/python/google/protobuf/internal/extension_dict.py index d08df4a8f97d..b346cf283e2c 100644 --- a/python/google/protobuf/internal/extension_dict.py +++ b/python/google/protobuf/internal/extension_dict.py @@ -87,6 +87,10 @@ def __getitem__(self, extension_handle): if extension_handle.label == FieldDescriptor.LABEL_REPEATED: result = extension_handle._default_constructor(self._extended_message) elif extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE: + message_type = extension_handle.message_type + if not hasattr(message_type, '_concrete_class'): + # pylint: disable=protected-access + self._extended_message._FACTORY.GetPrototype(message_type) assert getattr(extension_handle.message_type, '_concrete_class', None), ( 'Uninitialized concrete class found for field %r (message type %r)' % (extension_handle.full_name, diff --git a/python/google/protobuf/internal/json_format_test.py b/python/google/protobuf/internal/json_format_test.py index e3992f99ba26..d5245f478611 100644 --- a/python/google/protobuf/internal/json_format_test.py +++ b/python/google/protobuf/internal/json_format_test.py @@ -821,6 +821,10 @@ def testParseDoubleToFloat(self): def testFloatPrecision(self): message = json_format_proto3_pb2.TestMessage() message.float_value = 1.123456789 + # Default to 8 valid digits. + text = '{\n "floatValue": 1.1234568\n}' + self.assertEqual( + json_format.MessageToJson(message), text) # Set to 7 valid digits. text = '{\n "floatValue": 1.123457\n}' self.assertEqual( diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py index f12b531f8b2e..097c082c8061 100755 --- a/python/google/protobuf/internal/message_test.py +++ b/python/google/protobuf/internal/message_test.py @@ -106,6 +106,9 @@ def IsNegInf(val): return isinf(val) and (val < 0) +warnings.simplefilter('error', DeprecationWarning) + + @_parameterized.named_parameters( ('_proto2', unittest_pb2), ('_proto3', unittest_proto3_arena_pb2)) @@ -438,12 +441,19 @@ def testFloatPrinting(self, message_module): self.assertEqual(str(message), 'optional_float: 2.0\n') def testHighPrecisionFloatPrinting(self, message_module): - message = message_module.TestAllTypes() - message.optional_double = 0.12345678912345678 + msg = message_module.TestAllTypes() + msg.optional_float = 0.12345678912345678 + old_float = msg.optional_float + msg.ParseFromString(msg.SerializeToString()) + self.assertEqual(old_float, msg.optional_float) + + def testHighPrecisionDoublePrinting(self, message_module): + msg = message_module.TestAllTypes() + msg.optional_double = 0.12345678912345678 if sys.version_info >= (3,): - self.assertEqual(str(message), 'optional_double: 0.12345678912345678\n') + self.assertEqual(str(msg), 'optional_double: 0.12345678912345678\n') else: - self.assertEqual(str(message), 'optional_double: 0.123456789123\n') + self.assertEqual(str(msg), 'optional_double: 0.123456789123\n') def testUnknownFieldPrinting(self, message_module): populated = message_module.TestAllTypes() @@ -885,11 +895,13 @@ def testOneofGetCaseNonexistingField(self, message_module): def testOneofDefaultValues(self, message_module): m = message_module.TestAllTypes() self.assertIs(None, m.WhichOneof('oneof_field')) + self.assertFalse(m.HasField('oneof_field')) self.assertFalse(m.HasField('oneof_uint32')) # Oneof is set even when setting it to a default value. m.oneof_uint32 = 0 self.assertEqual('oneof_uint32', m.WhichOneof('oneof_field')) + self.assertTrue(m.HasField('oneof_field')) self.assertTrue(m.HasField('oneof_uint32')) self.assertFalse(m.HasField('oneof_string')) diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py index 8fb19460272c..0691a4c94e3d 100755 --- a/python/google/protobuf/internal/python_message.py +++ b/python/google/protobuf/internal/python_message.py @@ -124,9 +124,16 @@ def __new__(cls, name, bases, dictionary): Returns: Newly-allocated class. + + Raises: + RuntimeError: Generated code only work with python cpp extension. """ descriptor = dictionary[GeneratedProtocolMessageType._DESCRIPTOR_KEY] + if isinstance(descriptor, str): + raise RuntimeError('The generated code only work with python cpp ' + 'extension, but it is using pure python runtime.') + # If a concrete class already exists for this descriptor, don't try to # create another. Doing so will break any messages that already exist with # the existing class. @@ -838,10 +845,9 @@ def _AddHasFieldMethod(message_descriptor, cls): continue hassable_fields[field.name] = field - if not is_proto3: - # Fields inside oneofs are never repeated (enforced by the compiler). - for oneof in message_descriptor.oneofs: - hassable_fields[oneof.name] = oneof + # Has methods are supported for oneof descriptors. + for oneof in message_descriptor.oneofs: + hassable_fields[oneof.name] = oneof def HasField(self, field_name): try: diff --git a/python/google/protobuf/internal/reflection_test.py b/python/google/protobuf/internal/reflection_test.py index dace15447cdd..e67248fa620f 100755 --- a/python/google/protobuf/internal/reflection_test.py +++ b/python/google/protobuf/internal/reflection_test.py @@ -40,6 +40,7 @@ import operator import six import struct +import warnings try: import unittest2 as unittest #PY26 @@ -70,6 +71,9 @@ long = int # pylint: disable=redefined-builtin,invalid-name +warnings.simplefilter('error', DeprecationWarning) + + class _MiniDecoder(object): """Decodes a stream of values from a string. @@ -1433,12 +1437,16 @@ def testHandWrittenReflection(self): label=FieldDescriptor.LABEL_OPTIONAL, default_value=0, containing_type=None, message_type=None, enum_type=None, is_extension=False, extension_scope=None, - options=descriptor_pb2.FieldOptions()) + options=descriptor_pb2.FieldOptions(), + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) mydescriptor = descriptor.Descriptor( name='MyProto', full_name='MyProto', filename='ignored', containing_type=None, nested_types=[], enum_types=[], fields=[foo_field_descriptor], extensions=[], - options=descriptor_pb2.MessageOptions()) + options=descriptor_pb2.MessageOptions(), + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) class MyProtoClass(six.with_metaclass(reflection.GeneratedProtocolMessageType, message.Message)): DESCRIPTOR = mydescriptor myproto_instance = MyProtoClass() @@ -3168,22 +3176,34 @@ class ClassAPITest(unittest.TestCase): 'C++ implementation requires a call to MakeDescriptor()') @testing_refleaks.SkipReferenceLeakChecker('MakeClass is not repeatable') def testMakeClassWithNestedDescriptor(self): - leaf_desc = descriptor.Descriptor('leaf', 'package.parent.child.leaf', '', - containing_type=None, fields=[], - nested_types=[], enum_types=[], - extensions=[]) - child_desc = descriptor.Descriptor('child', 'package.parent.child', '', - containing_type=None, fields=[], - nested_types=[leaf_desc], enum_types=[], - extensions=[]) - sibling_desc = descriptor.Descriptor('sibling', 'package.parent.sibling', - '', containing_type=None, fields=[], - nested_types=[], enum_types=[], - extensions=[]) - parent_desc = descriptor.Descriptor('parent', 'package.parent', '', - containing_type=None, fields=[], - nested_types=[child_desc, sibling_desc], - enum_types=[], extensions=[]) + leaf_desc = descriptor.Descriptor( + 'leaf', 'package.parent.child.leaf', '', + containing_type=None, fields=[], + nested_types=[], enum_types=[], + extensions=[], + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) + child_desc = descriptor.Descriptor( + 'child', 'package.parent.child', '', + containing_type=None, fields=[], + nested_types=[leaf_desc], enum_types=[], + extensions=[], + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) + sibling_desc = descriptor.Descriptor( + 'sibling', 'package.parent.sibling', + '', containing_type=None, fields=[], + nested_types=[], enum_types=[], + extensions=[], + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) + parent_desc = descriptor.Descriptor( + 'parent', 'package.parent', '', + containing_type=None, fields=[], + nested_types=[child_desc, sibling_desc], + enum_types=[], extensions=[], + # pylint: disable=protected-access + create_key=descriptor._internal_create_key) reflection.MakeClass(parent_desc) def _GetSerializedFileDescriptor(self, name): @@ -3305,4 +3325,3 @@ def testParsingNestedClass(self): if __name__ == '__main__': unittest.main() - diff --git a/python/google/protobuf/internal/text_format_test.py b/python/google/protobuf/internal/text_format_test.py index 89520887ae83..b7d2333b3182 100755 --- a/python/google/protobuf/internal/text_format_test.py +++ b/python/google/protobuf/internal/text_format_test.py @@ -2194,5 +2194,23 @@ def testPrintFieldValue(self): }""")) +class OptionalColonMessageToStringTest(unittest.TestCase): + + def testForcePrintOptionalColon(self): + packed_message = unittest_pb2.OneString() + packed_message.data = 'string' + message = any_test_pb2.TestAny() + message.any_value.Pack(packed_message) + output = text_format.MessageToString( + message, + force_colon=True) + expected = ('any_value: {\n' + ' [type.googleapis.com/protobuf_unittest.OneString]: {\n' + ' data: "string"\n' + ' }\n' + '}\n') + self.assertEqual(expected, output) + + if __name__ == '__main__': unittest.main() diff --git a/python/google/protobuf/internal/type_checkers.py b/python/google/protobuf/internal/type_checkers.py index 8deba47507c6..f7690085f7a7 100755 --- a/python/google/protobuf/internal/type_checkers.py +++ b/python/google/protobuf/internal/type_checkers.py @@ -45,6 +45,11 @@ __author__ = 'robinson@google.com (Will Robinson)' +try: + import ctypes +except Exception: # pylint: disable=broad-except + ctypes = None + import struct import numbers import six @@ -257,9 +262,10 @@ def CheckValue(self, proposed_value): if converted_value < _FLOAT_MIN: return _NEG_INF - return converted_value - # TODO(jieluo): convert to 4 bytes float (c style float) at setters: - # return struct.unpack('f', struct.pack('f', converted_value)) + if ctypes: + return ctypes.c_float(converted_value).value + else: + return struct.unpack('file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { - // HasField() for a oneof *itself* isn't supported. - if (in_oneof) { - PyErr_Format(PyExc_ValueError, - "Can't test oneof field \"%s.%s\" for presence in proto3, " - "use WhichOneof instead.", message_name.c_str(), - field_descriptor->containing_oneof()->name().c_str()); - return false; - } - - // ...but HasField() for fields *in* a oneof is supported. + // HasField() is supported for oneof fields. if (field_descriptor->containing_oneof() != NULL) { return true; } diff --git a/python/google/protobuf/pyext/message_module.cc b/python/google/protobuf/pyext/message_module.cc index 4bb35b31936b..63d60b70e7b3 100644 --- a/python/google/protobuf/pyext/message_module.cc +++ b/python/google/protobuf/pyext/message_module.cc @@ -107,9 +107,12 @@ PyMODINIT_FUNC INITFUNC() { } // Adds the C++ API - if (PyObject* api = - PyCapsule_New(new ApiImplementation(), - google::protobuf::python::PyProtoAPICapsuleName(), NULL)) { + if (PyObject* api = PyCapsule_New( + new ApiImplementation(), google::protobuf::python::PyProtoAPICapsuleName(), + [](PyObject* o) { + delete (ApiImplementation*)PyCapsule_GetPointer( + o, google::protobuf::python::PyProtoAPICapsuleName()); + })) { PyModule_AddObject(m, "proto_API", api); } else { return INITFUNC_ERRORVAL; diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py index bc9060bcfa33..9c2b26720e61 100755 --- a/python/google/protobuf/text_format.py +++ b/python/google/protobuf/text_format.py @@ -132,7 +132,8 @@ def MessageToString(message, descriptor_pool=None, indent=0, message_formatter=None, - print_unknown_fields=False): + print_unknown_fields=False, + force_colon=False): # type: (...) -> str """Convert protobuf message to text format. @@ -170,17 +171,28 @@ def MessageToString(message, Custom formatter for selected sub-messages (usually based on message type). Use to pretty print parts of the protobuf for easier diffing. print_unknown_fields: If True, unknown fields will be printed. + force_colon: If set, a colon will be added after the field name even if the + field is a proto message. Returns: str: A string of the text formatted protocol buffer message. """ out = TextWriter(as_utf8) - printer = _Printer(out, indent, as_utf8, as_one_line, - use_short_repeated_primitives, pointy_brackets, - use_index_order, float_format, double_format, - use_field_number, - descriptor_pool, message_formatter, - print_unknown_fields=print_unknown_fields) + printer = _Printer( + out, + indent, + as_utf8, + as_one_line, + use_short_repeated_primitives, + pointy_brackets, + use_index_order, + float_format, + double_format, + use_field_number, + descriptor_pool, + message_formatter, + print_unknown_fields=print_unknown_fields, + force_colon=force_colon) printer.PrintMessage(message) result = out.getvalue() out.close() @@ -218,7 +230,8 @@ def PrintMessage(message, use_field_number=False, descriptor_pool=None, message_formatter=None, - print_unknown_fields=False): + print_unknown_fields=False, + force_colon=False): printer = _Printer( out=out, indent=indent, as_utf8=as_utf8, as_one_line=as_one_line, @@ -230,7 +243,8 @@ def PrintMessage(message, use_field_number=use_field_number, descriptor_pool=descriptor_pool, message_formatter=message_formatter, - print_unknown_fields=print_unknown_fields) + print_unknown_fields=print_unknown_fields, + force_colon=force_colon) printer.PrintMessage(message) @@ -246,13 +260,15 @@ def PrintField(field, float_format=None, double_format=None, message_formatter=None, - print_unknown_fields=False): + print_unknown_fields=False, + force_colon=False): """Print a single field name/value pair.""" printer = _Printer(out, indent, as_utf8, as_one_line, use_short_repeated_primitives, pointy_brackets, use_index_order, float_format, double_format, message_formatter=message_formatter, - print_unknown_fields=print_unknown_fields) + print_unknown_fields=print_unknown_fields, + force_colon=force_colon) printer.PrintField(field, value) @@ -268,13 +284,15 @@ def PrintFieldValue(field, float_format=None, double_format=None, message_formatter=None, - print_unknown_fields=False): + print_unknown_fields=False, + force_colon=False): """Print a single field value (not including name).""" printer = _Printer(out, indent, as_utf8, as_one_line, use_short_repeated_primitives, pointy_brackets, use_index_order, float_format, double_format, message_formatter=message_formatter, - print_unknown_fields=print_unknown_fields) + print_unknown_fields=print_unknown_fields, + force_colon=force_colon) printer.PrintFieldValue(field, value) @@ -324,7 +342,8 @@ def __init__(self, use_field_number=False, descriptor_pool=None, message_formatter=None, - print_unknown_fields=False): + print_unknown_fields=False, + force_colon=False): """Initialize the Printer. Double values can be formatted compactly with 15 digits of precision @@ -358,6 +377,8 @@ def __init__(self, to custom format selected sub-messages (usually based on message type). Use to pretty print parts of the protobuf for easier diffing. print_unknown_fields: If True, unknown fields will be printed. + force_colon: If set, a colon will be added after the field name even if + the field is a proto message. """ self.out = out self.indent = indent @@ -375,6 +396,7 @@ def __init__(self, self.descriptor_pool = descriptor_pool self.message_formatter = message_formatter self.print_unknown_fields = print_unknown_fields + self.force_colon = force_colon def _TryPrintAsAnyMessage(self, message): """Serializes if message is a google.protobuf.Any field.""" @@ -384,7 +406,8 @@ def _TryPrintAsAnyMessage(self, message): self.descriptor_pool) if packed_message: packed_message.MergeFromString(message.value) - self.out.write('%s[%s] ' % (self.indent * ' ', message.type_url)) + colon = ':' if self.force_colon else '' + self.out.write('%s[%s]%s ' % (self.indent * ' ', message.type_url, colon)) self._PrintMessageFieldValue(packed_message) self.out.write(' ' if self.as_one_line else '\n') return True @@ -518,9 +541,11 @@ def _PrintFieldName(self, field): else: out.write(field.name) - if field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE: + if (self.force_colon or + field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE): # The colon is optional in this case, but our cross-language golden files - # don't include it. + # don't include it. Here, the colon is only included if force_colon is + # set to True out.write(':') def PrintField(self, field, value): @@ -531,6 +556,7 @@ def PrintField(self, field, value): self.out.write(' ' if self.as_one_line else '\n') def _PrintShortRepeatedPrimitivesValue(self, field, value): + """"Prints short repeated primitives value.""" # Note: this is called only when value has at least one element. self._PrintFieldName(field) self.out.write(' [') @@ -539,6 +565,8 @@ def _PrintShortRepeatedPrimitivesValue(self, field, value): 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): diff --git a/python/setup.py b/python/setup.py index 327658a48412..9aabbf7aaa1b 100755 --- a/python/setup.py +++ b/python/setup.py @@ -19,23 +19,17 @@ from distutils.command.clean import clean as _clean from distutils.spawn import find_executable - -current_dir = (os.path.dirname(__file__) or os.curdir) -current_dir_relative = os.path.relpath(current_dir) -src_dir = os.path.abspath(os.path.join(current_dir, "..", "src")) -vsprojects_dir = os.path.abspath(os.path.join(current_dir, "..", "vsprojects")) - # Find the Protocol Compiler. if 'PROTOC' in os.environ and os.path.exists(os.environ['PROTOC']): protoc = os.environ['PROTOC'] -elif os.path.exists(os.path.join(src_dir, "protoc")): - protoc = os.path.join(src_dir, "protoc") -elif os.path.exists(os.path.join(src_dir, "protoc.exe")): - protoc = os.path.join(src_dir, "protoc.exe") -elif os.path.exists(os.path.join(vsprojects_dir, "Debug", "protoc.exe")): - protoc = os.path.join(vsprojects_dir, "Debug", "protoc.exe") -elif os.path.exists(os.path.join(vsprojects_dir, "Release", "protoc.exe")): - protoc = os.path.join(vsprojects_dir, "Release", "protoc.exe") +elif os.path.exists("../src/protoc"): + protoc = "../src/protoc" +elif os.path.exists("../src/protoc.exe"): + protoc = "../src/protoc.exe" +elif os.path.exists("../vsprojects/Debug/protoc.exe"): + protoc = "../vsprojects/Debug/protoc.exe" +elif os.path.exists("../vsprojects/Release/protoc.exe"): + protoc = "../vsprojects/Release/protoc.exe" else: protoc = find_executable("protoc") @@ -46,7 +40,7 @@ def GetVersion(): Do not import google.protobuf.__init__ directly, because an installed protobuf library may be loaded instead.""" - with open(os.path.join(current_dir, 'google', 'protobuf', '__init__.py')) as version_file: + with open(os.path.join('google', 'protobuf', '__init__.py')) as version_file: exec(version_file.read(), globals()) global __version__ return __version__ @@ -57,21 +51,15 @@ def generate_proto(source, require = True): .proto file. Does nothing if the output already exists and is newer than the input.""" - original_source = source - source = source.replace("../src", src_dir) - if not require and not os.path.exists(source): return - output = os.path.join( - current_dir, - original_source.replace(".proto", "_pb2.py").replace("../src/", "") - ) + output = source.replace(".proto", "_pb2.py").replace("../src/", "") if (not os.path.exists(output) or (os.path.exists(source) and os.path.getmtime(source) > os.path.getmtime(output))): - print("Generating %s..." % os.path.relpath(output)) + print("Generating %s..." % output) if not os.path.exists(source): sys.stderr.write("Can't find required file: %s\n" % source) @@ -83,13 +71,7 @@ def generate_proto(source, require = True): "or install the binary package.\n") sys.exit(-1) - protoc_command = [ - protoc, - "-I{}".format(src_dir), - "-I{}".format(current_dir), - "--python_out={}".format(current_dir), - source, - ] + protoc_command = [ protoc, "-I../src", "-I.", "--python_out=.", source ] if subprocess.call(protoc_command) != 0: sys.exit(-1) @@ -134,7 +116,7 @@ def GenerateUnittestProtos(): class clean(_clean): def run(self): # Delete generated files in the code tree. - for (dirpath, dirnames, filenames) in os.walk(current_dir): + for (dirpath, dirnames, filenames) in os.walk("."): for filename in filenames: filepath = os.path.join(dirpath, filename) if filepath.endswith("_pb2.py") or filepath.endswith(".pyc") or \ @@ -287,14 +269,7 @@ def get_option_from_sys_argv(option_str): "Programming Language :: Python :: 3.7", ], namespace_packages=['google'], - # package_dir is required when setup.py is not run from the python/ - # directory (such as from the ReadTheDocs build). See - # https://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages - # package_dir must be a relative path. See: - # https://stackoverflow.com/a/53547931/101923 - package_dir={"": current_dir_relative}, packages=find_packages( - where=current_dir, exclude=[ 'import_test_package', ], diff --git a/src/Makefile.am b/src/Makefile.am index 7d5e779ceecb..3212a505ae6c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -510,6 +510,7 @@ protoc_inputs = \ google/protobuf/unittest_proto3_arena.proto \ google/protobuf/unittest_proto3_arena_lite.proto \ google/protobuf/unittest_proto3_lite.proto \ + google/protobuf/unittest_proto3_optional.proto \ google/protobuf/unittest_well_known_types.proto \ google/protobuf/util/internal/testdata/anys.proto \ google/protobuf/util/internal/testdata/books.proto \ @@ -643,6 +644,8 @@ protoc_outputs = \ google/protobuf/unittest_proto3_arena_lite.pb.h \ google/protobuf/unittest_proto3_lite.pb.cc \ google/protobuf/unittest_proto3_lite.pb.h \ + google/protobuf/unittest_proto3_optional.pb.cc \ + google/protobuf/unittest_proto3_optional.pb.h \ google/protobuf/unittest_well_known_types.pb.cc \ google/protobuf/unittest_well_known_types.pb.h \ google/protobuf/util/internal/testdata/anys.pb.cc \ @@ -686,7 +689,7 @@ else # relative to srcdir, which may not be the same as the current directory when # building out-of-tree. unittest_proto_middleman: protoc$(EXEEXT) $(protoc_inputs) - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/protoc$(EXEEXT) -I. --cpp_out=$$oldpwd $(protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/protoc$(EXEEXT) -I. --cpp_out=$$oldpwd $(protoc_inputs) --experimental_allow_proto3_optional ) touch unittest_proto_middleman endif diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 5d7ea1ccba76..1eba999eba20 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -69,9 +69,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Any_google_2fprotobuf_2fany_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fany_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = { - &descriptor_table_google_2fprotobuf_2fany_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", 205, + false, false, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", 205, &descriptor_table_google_2fprotobuf_2fany_2eproto_once, descriptor_table_google_2fprotobuf_2fany_2eproto_sccs, descriptor_table_google_2fprotobuf_2fany_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fany_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, @@ -102,23 +101,26 @@ class Any::_Internal { public: }; -Any::Any() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr), _any_metadata_(&type_url_, &value_) { +Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + _any_metadata_(&type_url_, &value_) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Any) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Any) } Any::Any(const Any& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _any_metadata_(&type_url_, &value_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_type_url().empty()) { - type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_url_); + type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type_url(), + GetArena()); } value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_value().empty()) { - value_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value_); + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_value(), + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } @@ -132,13 +134,21 @@ void Any::SharedCtor() { Any::~Any() { // @@protoc_insertion_point(destructor:google.protobuf.Any) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Any::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void Any::ArenaDtor(void* object) { + Any* _this = reinterpret_cast< Any* >(object); + (void)_this; +} +void Any::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void Any::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -154,13 +164,14 @@ void Any::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - type_url_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - value_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - _internal_metadata_.Clear(); + type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -189,7 +200,9 @@ const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -227,7 +240,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Any::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any) return target; @@ -282,17 +295,15 @@ void Any::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Any::MergeFrom(const Any& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.type_url().size() > 0) { - - type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_url_); + _internal_set_type_url(from._internal_type_url()); } if (from.value().size() > 0) { - - value_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value_); + _internal_set_value(from._internal_value()); } } @@ -316,11 +327,9 @@ bool Any::IsInitialized() const { void Any::InternalSwap(Any* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const { @@ -332,7 +341,7 @@ ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const { PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::Any >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::Any >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 0ff9341b04de..1b7dca0bddb1 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -66,10 +66,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Any : +class PROTOBUF_EXPORT Any PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ { public: - Any(); + inline Any() : Any(nullptr) {}; virtual ~Any(); Any(const Any& from); @@ -83,7 +83,7 @@ class PROTOBUF_EXPORT Any : return *this; } inline Any& operator=(Any&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -148,6 +148,15 @@ class PROTOBUF_EXPORT Any : } inline void Swap(Any* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Any* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -182,13 +191,11 @@ class PROTOBUF_EXPORT Any : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.Any"; } + protected: + explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -218,6 +225,15 @@ class PROTOBUF_EXPORT Any : std::string* mutable_type_url(); std::string* release_type_url(); void set_allocated_type_url(std::string* type_url); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_type_url(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_type_url( + std::string* type_url); private: const std::string& _internal_type_url() const; void _internal_set_type_url(const std::string& value); @@ -234,6 +250,15 @@ class PROTOBUF_EXPORT Any : std::string* mutable_value(); std::string* release_value(); void set_allocated_value(std::string* value); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_value(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_value( + std::string* value); private: const std::string& _internal_value() const; void _internal_set_value(const std::string& value); @@ -244,7 +269,9 @@ class PROTOBUF_EXPORT Any : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; @@ -264,7 +291,7 @@ class PROTOBUF_EXPORT Any : // string type_url = 1; inline void Any::clear_type_url() { - type_url_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) @@ -279,38 +306,40 @@ inline std::string* Any::mutable_type_url() { return _internal_mutable_type_url(); } inline const std::string& Any::_internal_type_url() const { - return type_url_.GetNoArena(); + return type_url_.Get(); } inline void Any::_internal_set_type_url(const std::string& value) { - type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Any::set_type_url(std::string&& value) { - type_url_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + type_url_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url) } inline void Any::set_type_url(const char* value) { GOOGLE_DCHECK(value != nullptr); - type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url) } -inline void Any::set_type_url(const char* value, size_t size) { +inline void Any::set_type_url(const char* value, + size_t size) { - type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url) } inline std::string* Any::_internal_mutable_type_url() { - return type_url_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return type_url_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Any::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url) - return type_url_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Any::set_allocated_type_url(std::string* type_url) { if (type_url != nullptr) { @@ -318,13 +347,33 @@ inline void Any::set_allocated_type_url(std::string* type_url) { } else { } - type_url_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url); + type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) } +inline std::string* Any::unsafe_arena_release_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Any.type_url) + GOOGLE_DCHECK(GetArena() != nullptr); + + return type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Any::unsafe_arena_set_allocated_type_url( + std::string* type_url) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (type_url != nullptr) { + + } else { + + } + type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + type_url, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Any.type_url) +} // bytes value = 2; inline void Any::clear_value() { - value_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) @@ -339,38 +388,40 @@ inline std::string* Any::mutable_value() { return _internal_mutable_value(); } inline const std::string& Any::_internal_value() const { - return value_.GetNoArena(); + return value_.Get(); } inline void Any::_internal_set_value(const std::string& value) { - value_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Any::set_value(std::string&& value) { - value_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + value_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value) } inline void Any::set_value(const char* value) { GOOGLE_DCHECK(value != nullptr); - value_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value) } -inline void Any::set_value(const void* value, size_t size) { +inline void Any::set_value(const void* value, + size_t size) { - value_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value) } inline std::string* Any::_internal_mutable_value() { - return value_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Any::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Any.value) - return value_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Any::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -378,9 +429,29 @@ inline void Any::set_allocated_value(std::string* value) { } else { } - value_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } +inline std::string* Any::unsafe_arena_release_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Any.value) + GOOGLE_DCHECK(GetArena() != nullptr); + + return value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Any::unsafe_arena_set_allocated_value( + std::string* value) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (value != nullptr) { + + } else { + + } + value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + value, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Any.value) +} #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 0951c5243678..816df1201ca9 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -159,9 +159,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Mixin_google_2fprotobuf_2fapi_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fapi_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = { - &descriptor_table_google_2fprotobuf_2fapi_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", 750, + false, false, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", 750, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_sccs, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 3, 2, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fapi_2eproto, 3, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto, @@ -190,30 +189,35 @@ void Api::clear_options() { options_.Clear(); } void Api::clear_source_context() { - if (GetArenaNoVirtual() == nullptr && source_context_ != nullptr) { + if (GetArena() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; } -Api::Api() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +Api::Api(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + methods_(arena), + options_(arena), + mixins_(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Api) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Api) } Api::Api(const Api& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), methods_(from.methods_), options_(from.options_), mixins_(from.mixins_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), + GetArena()); } version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_version().empty()) { - version_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.version_); + version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_version(), + GetArena()); } if (from._internal_has_source_context()) { source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); @@ -236,14 +240,22 @@ void Api::SharedCtor() { Api::~Api() { // @@protoc_insertion_point(destructor:google.protobuf.Api) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Api::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete source_context_; } +void Api::ArenaDtor(void* object) { + Api* _this = reinterpret_cast< Api* >(object); + (void)_this; +} +void Api::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void Api::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -262,18 +274,19 @@ void Api::Clear() { methods_.Clear(); options_.Clear(); mixins_.Clear(); - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - version_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (GetArenaNoVirtual() == nullptr && source_context_ != nullptr) { + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + version_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + if (GetArena() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; syntax_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -354,7 +367,9 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -435,7 +450,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Api::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Api) return target; @@ -524,7 +539,7 @@ void Api::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Api::MergeFrom(const Api& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -532,12 +547,10 @@ void Api::MergeFrom(const Api& from) { options_.MergeFrom(from.options_); mixins_.MergeFrom(from.mixins_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + _internal_set_name(from._internal_name()); } if (from.version().size() > 0) { - - version_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.version_); + _internal_set_version(from._internal_version()); } if (from.has_source_context()) { _internal_mutable_source_context()->PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom(from._internal_source_context()); @@ -567,16 +580,18 @@ bool Api::IsInitialized() const { void Api::InternalSwap(Api* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); methods_.InternalSwap(&other->methods_); options_.InternalSwap(&other->options_); mixins_.InternalSwap(&other->mixins_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - version_.Swap(&other->version_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(source_context_, other->source_context_); - swap(syntax_, other->syntax_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + version_.Swap(&other->version_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Api, syntax_) + + sizeof(Api::syntax_) + - PROTOBUF_FIELD_OFFSET(Api, source_context_)>( + reinterpret_cast(&source_context_), + reinterpret_cast(&other->source_context_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const { @@ -595,27 +610,31 @@ class Method::_Internal { void Method::clear_options() { options_.Clear(); } -Method::Method() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +Method::Method(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + options_(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Method) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Method) } Method::Method(const Method& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), options_(from.options_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), + GetArena()); } request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_request_type_url().empty()) { - request_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); + request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_request_type_url(), + GetArena()); } response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_response_type_url().empty()) { - response_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); + response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_response_type_url(), + GetArena()); } ::memcpy(&request_streaming_, &from.request_streaming_, static_cast(reinterpret_cast(&syntax_) - @@ -636,14 +655,22 @@ void Method::SharedCtor() { Method::~Method() { // @@protoc_insertion_point(destructor:google.protobuf.Method) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Method::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); request_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); response_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void Method::ArenaDtor(void* object) { + Method* _this = reinterpret_cast< Method* >(object); + (void)_this; +} +void Method::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void Method::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -660,17 +687,18 @@ void Method::Clear() { (void) cached_has_bits; options_.Clear(); - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - request_type_url_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - response_type_url_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + request_type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + response_type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::memset(&request_streaming_, 0, static_cast( reinterpret_cast(&syntax_) - reinterpret_cast(&request_streaming_)) + sizeof(syntax_)); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -743,7 +771,9 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -822,7 +852,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Method::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Method) return target; @@ -907,22 +937,19 @@ void Method::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Method::MergeFrom(const Method& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + _internal_set_name(from._internal_name()); } if (from.request_type_url().size() > 0) { - - request_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); + _internal_set_request_type_url(from._internal_request_type_url()); } if (from.response_type_url().size() > 0) { - - response_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); + _internal_set_response_type_url(from._internal_response_type_url()); } if (from.request_streaming() != 0) { _internal_set_request_streaming(from._internal_request_streaming()); @@ -955,17 +982,17 @@ bool Method::IsInitialized() const { void Method::InternalSwap(Method* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - request_type_url_.Swap(&other->request_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - response_type_url_.Swap(&other->response_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(request_streaming_, other->request_streaming_); - swap(response_streaming_, other->response_streaming_); - swap(syntax_, other->syntax_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + request_type_url_.Swap(&other->request_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + response_type_url_.Swap(&other->response_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Method, syntax_) + + sizeof(Method::syntax_) + - PROTOBUF_FIELD_OFFSET(Method, request_streaming_)>( + reinterpret_cast(&request_streaming_), + reinterpret_cast(&other->request_streaming_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const { @@ -981,22 +1008,24 @@ class Mixin::_Internal { public: }; -Mixin::Mixin() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +Mixin::Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Mixin) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin) } Mixin::Mixin(const Mixin& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), + GetArena()); } root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_root().empty()) { - root_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.root_); + root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_root(), + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } @@ -1010,13 +1039,21 @@ void Mixin::SharedCtor() { Mixin::~Mixin() { // @@protoc_insertion_point(destructor:google.protobuf.Mixin) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Mixin::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void Mixin::ArenaDtor(void* object) { + Mixin* _this = reinterpret_cast< Mixin* >(object); + (void)_this; +} +void Mixin::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void Mixin::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -1032,13 +1069,14 @@ void Mixin::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - root_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - _internal_metadata_.Clear(); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + root_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1068,7 +1106,9 @@ const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1110,7 +1150,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Mixin::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Mixin) return target; @@ -1165,17 +1205,15 @@ void Mixin::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Mixin::MergeFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.name().size() > 0) { - - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + _internal_set_name(from._internal_name()); } if (from.root().size() > 0) { - - root_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.root_); + _internal_set_root(from._internal_root()); } } @@ -1199,11 +1237,9 @@ bool Mixin::IsInitialized() const { void Mixin::InternalSwap(Mixin* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - root_.Swap(&other->root_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + root_.Swap(&other->root_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const { @@ -1215,13 +1251,13 @@ ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const { PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::Api* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Api >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::Api >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::Api >(arena); } template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::Method* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Method >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::Method >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::Method >(arena); } template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::Mixin* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::Mixin >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::Mixin >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index ed49df1b1f52..0d0ce4ab748b 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -76,10 +76,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Api : +class PROTOBUF_EXPORT Api PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ { public: - Api(); + inline Api() : Api(nullptr) {}; virtual ~Api(); Api(const Api& from); @@ -93,7 +93,7 @@ class PROTOBUF_EXPORT Api : return *this; } inline Api& operator=(Api&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -125,6 +125,15 @@ class PROTOBUF_EXPORT Api : } inline void Swap(Api* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Api* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -159,13 +168,11 @@ class PROTOBUF_EXPORT Api : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.Api"; } + protected: + explicit Api(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -254,6 +261,15 @@ class PROTOBUF_EXPORT Api : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_name(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + std::string* name); private: const std::string& _internal_name() const; void _internal_set_name(const std::string& value); @@ -270,6 +286,15 @@ class PROTOBUF_EXPORT Api : std::string* mutable_version(); std::string* release_version(); void set_allocated_version(std::string* version); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_version(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_version( + std::string* version); private: const std::string& _internal_version() const; void _internal_set_version(const std::string& value); @@ -290,6 +315,9 @@ class PROTOBUF_EXPORT Api : const PROTOBUF_NAMESPACE_ID::SourceContext& _internal_source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* _internal_mutable_source_context(); public: + void unsafe_arena_set_allocated_source_context( + PROTOBUF_NAMESPACE_ID::SourceContext* source_context); + PROTOBUF_NAMESPACE_ID::SourceContext* unsafe_arena_release_source_context(); // .google.protobuf.Syntax syntax = 7; void clear_syntax(); @@ -304,7 +332,9 @@ class PROTOBUF_EXPORT Api : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Method > methods_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option > options_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Mixin > mixins_; @@ -317,10 +347,10 @@ class PROTOBUF_EXPORT Api : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Method : +class PROTOBUF_EXPORT Method PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ { public: - Method(); + inline Method() : Method(nullptr) {}; virtual ~Method(); Method(const Method& from); @@ -334,7 +364,7 @@ class PROTOBUF_EXPORT Method : return *this; } inline Method& operator=(Method&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -366,6 +396,15 @@ class PROTOBUF_EXPORT Method : } inline void Swap(Method* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Method* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -400,13 +439,11 @@ class PROTOBUF_EXPORT Method : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.Method"; } + protected: + explicit Method(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -459,6 +496,15 @@ class PROTOBUF_EXPORT Method : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_name(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + std::string* name); private: const std::string& _internal_name() const; void _internal_set_name(const std::string& value); @@ -475,6 +521,15 @@ class PROTOBUF_EXPORT Method : std::string* mutable_request_type_url(); std::string* release_request_type_url(); void set_allocated_request_type_url(std::string* request_type_url); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_request_type_url(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_request_type_url( + std::string* request_type_url); private: const std::string& _internal_request_type_url() const; void _internal_set_request_type_url(const std::string& value); @@ -491,6 +546,15 @@ class PROTOBUF_EXPORT Method : std::string* mutable_response_type_url(); std::string* release_response_type_url(); void set_allocated_response_type_url(std::string* response_type_url); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_response_type_url(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_response_type_url( + std::string* response_type_url); private: const std::string& _internal_response_type_url() const; void _internal_set_response_type_url(const std::string& value); @@ -528,7 +592,9 @@ class PROTOBUF_EXPORT Method : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option > options_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr request_type_url_; @@ -541,10 +607,10 @@ class PROTOBUF_EXPORT Method : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Mixin : +class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ { public: - Mixin(); + inline Mixin() : Mixin(nullptr) {}; virtual ~Mixin(); Mixin(const Mixin& from); @@ -558,7 +624,7 @@ class PROTOBUF_EXPORT Mixin : return *this; } inline Mixin& operator=(Mixin&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -590,6 +656,15 @@ class PROTOBUF_EXPORT Mixin : } inline void Swap(Mixin* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Mixin* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -624,13 +699,11 @@ class PROTOBUF_EXPORT Mixin : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.Mixin"; } + protected: + explicit Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -660,6 +733,15 @@ class PROTOBUF_EXPORT Mixin : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_name(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + std::string* name); private: const std::string& _internal_name() const; void _internal_set_name(const std::string& value); @@ -676,6 +758,15 @@ class PROTOBUF_EXPORT Mixin : std::string* mutable_root(); std::string* release_root(); void set_allocated_root(std::string* root); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_root(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_root( + std::string* root); private: const std::string& _internal_root() const; void _internal_set_root(const std::string& value); @@ -686,7 +777,9 @@ class PROTOBUF_EXPORT Mixin : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr root_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; @@ -705,7 +798,7 @@ class PROTOBUF_EXPORT Mixin : // string name = 1; inline void Api::clear_name() { - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) @@ -720,38 +813,40 @@ inline std::string* Api::mutable_name() { return _internal_mutable_name(); } inline const std::string& Api::_internal_name() const { - return name_.GetNoArena(); + return name_.Get(); } inline void Api::_internal_set_name(const std::string& value) { - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Api::set_name(std::string&& value) { - name_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name) } inline void Api::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name) } -inline void Api::set_name(const char* value, size_t size) { +inline void Api::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name) } inline std::string* Api::_internal_mutable_name() { - return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Api::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Api.name) - return name_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Api::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -759,9 +854,29 @@ inline void Api::set_allocated_name(std::string* name) { } else { } - name_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name) } +inline std::string* Api::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Api.name) + GOOGLE_DCHECK(GetArena() != nullptr); + + return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Api::unsafe_arena_set_allocated_name( + std::string* name) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (name != nullptr) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + name, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Api.name) +} // repeated .google.protobuf.Method methods = 2; inline int Api::_internal_methods_size() const { @@ -840,7 +955,7 @@ Api::options() const { // string version = 4; inline void Api::clear_version() { - version_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + version_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) @@ -855,38 +970,40 @@ inline std::string* Api::mutable_version() { return _internal_mutable_version(); } inline const std::string& Api::_internal_version() const { - return version_.GetNoArena(); + return version_.Get(); } inline void Api::_internal_set_version(const std::string& value) { - version_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Api::set_version(std::string&& value) { - version_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + version_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version) } inline void Api::set_version(const char* value) { GOOGLE_DCHECK(value != nullptr); - version_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version) } -inline void Api::set_version(const char* value, size_t size) { +inline void Api::set_version(const char* value, + size_t size) { - version_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version) } inline std::string* Api::_internal_mutable_version() { - return version_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return version_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Api::release_version() { // @@protoc_insertion_point(field_release:google.protobuf.Api.version) - return version_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Api::set_allocated_version(std::string* version) { if (version != nullptr) { @@ -894,9 +1011,29 @@ inline void Api::set_allocated_version(std::string* version) { } else { } - version_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version); + version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) } +inline std::string* Api::unsafe_arena_release_version() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Api.version) + GOOGLE_DCHECK(GetArena() != nullptr); + + return version_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Api::unsafe_arena_set_allocated_version( + std::string* version) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (version != nullptr) { + + } else { + + } + version_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + version, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Api.version) +} // .google.protobuf.SourceContext source_context = 5; inline bool Api::_internal_has_source_context() const { @@ -914,7 +1051,27 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) return _internal_source_context(); } +inline void Api::unsafe_arena_set_allocated_source_context( + PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Api.source_context) +} inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() { + auto temp = unsafe_arena_release_source_context(); + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::unsafe_arena_release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Api.source_context) PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; @@ -924,7 +1081,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() { inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::_internal_mutable_source_context() { if (source_context_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); source_context_ = p; } return source_context_; @@ -934,12 +1091,13 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::mutable_source_context() { return _internal_mutable_source_context(); } inline void Api::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); } if (source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr; + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena(); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, source_context, submessage_arena); @@ -1017,7 +1175,7 @@ inline void Api::set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value) { // string name = 1; inline void Method::clear_name() { - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) @@ -1032,38 +1190,40 @@ inline std::string* Method::mutable_name() { return _internal_mutable_name(); } inline const std::string& Method::_internal_name() const { - return name_.GetNoArena(); + return name_.Get(); } inline void Method::_internal_set_name(const std::string& value) { - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Method::set_name(std::string&& value) { - name_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name) } inline void Method::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name) } -inline void Method::set_name(const char* value, size_t size) { +inline void Method::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name) } inline std::string* Method::_internal_mutable_name() { - return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Method::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Method.name) - return name_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Method::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1071,13 +1231,33 @@ inline void Method::set_allocated_name(std::string* name) { } else { } - name_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) } +inline std::string* Method::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Method.name) + GOOGLE_DCHECK(GetArena() != nullptr); + + return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Method::unsafe_arena_set_allocated_name( + std::string* name) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (name != nullptr) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + name, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Method.name) +} // string request_type_url = 2; inline void Method::clear_request_type_url() { - request_type_url_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + request_type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Method::request_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) @@ -1092,38 +1272,40 @@ inline std::string* Method::mutable_request_type_url() { return _internal_mutable_request_type_url(); } inline const std::string& Method::_internal_request_type_url() const { - return request_type_url_.GetNoArena(); + return request_type_url_.Get(); } inline void Method::_internal_set_request_type_url(const std::string& value) { - request_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Method::set_request_type_url(std::string&& value) { - request_type_url_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + request_type_url_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url) } inline void Method::set_request_type_url(const char* value) { GOOGLE_DCHECK(value != nullptr); - request_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url) } -inline void Method::set_request_type_url(const char* value, size_t size) { +inline void Method::set_request_type_url(const char* value, + size_t size) { - request_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url) } inline std::string* Method::_internal_mutable_request_type_url() { - return request_type_url_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return request_type_url_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Method::release_request_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url) - return request_type_url_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Method::set_allocated_request_type_url(std::string* request_type_url) { if (request_type_url != nullptr) { @@ -1131,9 +1313,29 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url } else { } - request_type_url_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url); + request_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) } +inline std::string* Method::unsafe_arena_release_request_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Method.request_type_url) + GOOGLE_DCHECK(GetArena() != nullptr); + + return request_type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Method::unsafe_arena_set_allocated_request_type_url( + std::string* request_type_url) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (request_type_url != nullptr) { + + } else { + + } + request_type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + request_type_url, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Method.request_type_url) +} // bool request_streaming = 3; inline void Method::clear_request_streaming() { @@ -1157,7 +1359,7 @@ inline void Method::set_request_streaming(bool value) { // string response_type_url = 4; inline void Method::clear_response_type_url() { - response_type_url_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + response_type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Method::response_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) @@ -1172,38 +1374,40 @@ inline std::string* Method::mutable_response_type_url() { return _internal_mutable_response_type_url(); } inline const std::string& Method::_internal_response_type_url() const { - return response_type_url_.GetNoArena(); + return response_type_url_.Get(); } inline void Method::_internal_set_response_type_url(const std::string& value) { - response_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Method::set_response_type_url(std::string&& value) { - response_type_url_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + response_type_url_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url) } inline void Method::set_response_type_url(const char* value) { GOOGLE_DCHECK(value != nullptr); - response_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url) } -inline void Method::set_response_type_url(const char* value, size_t size) { +inline void Method::set_response_type_url(const char* value, + size_t size) { - response_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url) } inline std::string* Method::_internal_mutable_response_type_url() { - return response_type_url_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return response_type_url_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Method::release_response_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url) - return response_type_url_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Method::set_allocated_response_type_url(std::string* response_type_url) { if (response_type_url != nullptr) { @@ -1211,9 +1415,29 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u } else { } - response_type_url_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url); + response_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) } +inline std::string* Method::unsafe_arena_release_response_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Method.response_type_url) + GOOGLE_DCHECK(GetArena() != nullptr); + + return response_type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Method::unsafe_arena_set_allocated_response_type_url( + std::string* response_type_url) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (response_type_url != nullptr) { + + } else { + + } + response_type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + response_type_url, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Method.response_type_url) +} // bool response_streaming = 5; inline void Method::clear_response_streaming() { @@ -1297,7 +1521,7 @@ inline void Method::set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value) { // string name = 1; inline void Mixin::clear_name() { - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) @@ -1312,38 +1536,40 @@ inline std::string* Mixin::mutable_name() { return _internal_mutable_name(); } inline const std::string& Mixin::_internal_name() const { - return name_.GetNoArena(); + return name_.Get(); } inline void Mixin::_internal_set_name(const std::string& value) { - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Mixin::set_name(std::string&& value) { - name_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name) } inline void Mixin::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name) } -inline void Mixin::set_name(const char* value, size_t size) { +inline void Mixin::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name) } inline std::string* Mixin::_internal_mutable_name() { - return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Mixin::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name) - return name_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Mixin::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1351,13 +1577,33 @@ inline void Mixin::set_allocated_name(std::string* name) { } else { } - name_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) } +inline std::string* Mixin::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Mixin.name) + GOOGLE_DCHECK(GetArena() != nullptr); + + return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Mixin::unsafe_arena_set_allocated_name( + std::string* name) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (name != nullptr) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + name, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Mixin.name) +} // string root = 2; inline void Mixin::clear_root() { - root_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + root_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) @@ -1372,38 +1618,40 @@ inline std::string* Mixin::mutable_root() { return _internal_mutable_root(); } inline const std::string& Mixin::_internal_root() const { - return root_.GetNoArena(); + return root_.Get(); } inline void Mixin::_internal_set_root(const std::string& value) { - root_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Mixin::set_root(std::string&& value) { - root_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + root_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root) } inline void Mixin::set_root(const char* value) { GOOGLE_DCHECK(value != nullptr); - root_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root) } -inline void Mixin::set_root(const char* value, size_t size) { +inline void Mixin::set_root(const char* value, + size_t size) { - root_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root) } inline std::string* Mixin::_internal_mutable_root() { - return root_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return root_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Mixin::release_root() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root) - return root_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Mixin::set_allocated_root(std::string* root) { if (root != nullptr) { @@ -1411,9 +1659,29 @@ inline void Mixin::set_allocated_root(std::string* root) { } else { } - root_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root); + root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } +inline std::string* Mixin::unsafe_arena_release_root() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Mixin.root) + GOOGLE_DCHECK(GetArena() != nullptr); + + return root_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Mixin::unsafe_arena_set_allocated_root( + std::string* root) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (root != nullptr) { + + } else { + + } + root_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + root, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Mixin.root) +} #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 2dcf8179833a..a67d47897639 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -338,10 +338,8 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { template PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena, size_t num_elements) { -#ifndef __INTEL_COMPILER // icc mis-evaluates some types as non-pod static_assert(std::is_pod::value, "CreateArray requires a trivially constructible type"); -#endif static_assert(std::is_trivially_destructible::value, "CreateArray requires a trivially destructible type"); GOOGLE_CHECK_LE(num_elements, std::numeric_limits::max() / sizeof(T)) @@ -455,7 +453,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { return new (ptr) T(std::forward(args)...); } - static Arena* GetArena(const T* p) { return p->GetArenaNoVirtual(); } + static Arena* GetArena(const T* p) { return p->GetArena(); } friend class Arena; }; @@ -534,6 +532,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // the cookie is not null. template PROTOBUF_ALWAYS_INLINE void* AllocateInternal(bool skip_explicit_ownership) { + static_assert(alignof(T) <= 8, "T is overaligned, see b/151247138"); const size_t n = internal::AlignUpTo8(sizeof(T)); AllocHook(RTTI_TYPE_ID(T), n); // Monitor allocation if needed. @@ -618,24 +617,25 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // CreateInArenaStorage is used to implement map field. Without it, // Map need to call generated message's protected arena constructor, // which needs to declare Map as friend of generated message. - template - static void CreateInArenaStorage(T* ptr, Arena* arena) { + template + static void CreateInArenaStorage(T* ptr, Arena* arena, Args&&... args) { CreateInArenaStorageInternal(ptr, arena, - typename is_arena_constructable::type()); + typename is_arena_constructable::type(), + std::forward(args)...); RegisterDestructorInternal( ptr, arena, typename InternalHelper::is_destructor_skippable::type()); } - template + template static void CreateInArenaStorageInternal(T* ptr, Arena* arena, - std::true_type) { - InternalHelper::Construct(ptr, arena); + std::true_type, Args&&... args) { + InternalHelper::Construct(ptr, arena, std::forward(args)...); } - template + template static void CreateInArenaStorageInternal(T* ptr, Arena* /* arena */, - std::false_type) { - new (ptr) T(); + std::false_type, Args&&... args) { + new (ptr) T(std::forward(args)...); } template @@ -667,7 +667,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // Implementation for GetArena(). Only message objects with // InternalArenaConstructable_ tags can be associated with an arena, and such - // objects must implement a GetArenaNoVirtual() method. + // objects must implement a GetArena() method. template ::value, int>::type = 0> PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) { @@ -694,6 +694,17 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { AllocHook(NULL, n); return AllocateAlignedNoHook(internal::AlignUpTo8(n)); } + template + void* AllocateAlignedTo(size_t n) { + static_assert(Align > 0, "Alignment must be greater than 0"); + static_assert((Align & (Align - 1)) == 0, "Alignment must be power of two"); + if (Align <= 8) return AllocateAligned(n); + // TODO(b/151247138): if the pointer would have been aligned already, + // this is wasting space. We should pass the alignment down. + uintptr_t ptr = reinterpret_cast(AllocateAligned(n + Align - 8)); + ptr = (ptr + Align - 1) & -Align; + return reinterpret_cast(ptr); + } void* AllocateAlignedNoHook(size_t n); diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index 528dc76428a2..1bc8dfca537e 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -102,6 +102,16 @@ class PROTOC_EXPORT CodeGenerator { GeneratorContext* generator_context, std::string* error) const; + // Sync with plugin.proto. + enum Feature { + FEATURE_PROTO3_OPTIONAL = 1, + }; + + // Implement this to indicate what features this code generator supports. + // This should be a bitwise OR of features from the Features enum in + // plugin.proto. + virtual uint64 GetSupportedFeatures() const { return 0; } + // This is no longer used, but this class is part of the opensource protobuf // library, so it has to remain to keep vtables the same for the current // version of the library. When protobufs does a api breaking change, the diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index fd64d0f4a01c..ab7a7d4bbd6d 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -773,16 +773,9 @@ const char* const CommandLineInterface::kPathSeparator = ":"; #endif CommandLineInterface::CommandLineInterface() - : mode_(MODE_COMPILE), - print_mode_(PRINT_NONE), - error_format_(ERROR_FORMAT_GCC), - direct_dependencies_explicitly_set_(false), - direct_dependencies_violation_msg_( - kDefaultDirectDependenciesViolationMsg), - imports_in_descriptor_set_(false), - source_info_in_descriptor_set_(false), - disallow_services_(false) { -} + : direct_dependencies_violation_msg_( + kDefaultDirectDependenciesViolationMsg) {} + CommandLineInterface::~CommandLineInterface() {} void CommandLineInterface::RegisterGenerator(const std::string& flag_name, @@ -811,6 +804,39 @@ void CommandLineInterface::AllowPlugins(const std::string& exe_name_prefix) { plugin_prefix_ = exe_name_prefix; } +namespace { + +bool ContainsProto3Optional(const Descriptor* desc) { + for (int i = 0; i < desc->field_count(); i++) { + if (desc->field(i)->has_optional_keyword()) { + return true; + } + } + for (int i = 0; i < desc->nested_type_count(); i++) { + if (ContainsProto3Optional(desc->nested_type(i))) { + return true; + } + } + return false; +} + +bool ContainsProto3Optional(const FileDescriptor* file) { + if (file->syntax() == FileDescriptor::SYNTAX_PROTO3) { + for (int i = 0; i < file->message_type_count(); i++) { + if (ContainsProto3Optional(file->message_type(i))) { + return true; + } + } + } + return false; +} + +} // namespace + +namespace { +std::unique_ptr +PopulateSingleSimpleDescriptorDatabase(const std::string& descriptor_set_name); +} int CommandLineInterface::Run(int argc, const char* const argv[]) { Clear(); @@ -827,16 +853,38 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { std::unique_ptr disk_source_tree; std::unique_ptr error_collector; std::unique_ptr descriptor_pool; - std::unique_ptr descriptor_set_in_database; + + // The SimpleDescriptorDatabases here are the constituents of the + // MergedDescriptorDatabase descriptor_set_in_database, so this vector is for + // managing their lifetimes. Its scope should match descriptor_set_in_database + std::vector> + databases_per_descriptor_set; + std::unique_ptr descriptor_set_in_database; + std::unique_ptr source_tree_database; // Any --descriptor_set_in FileDescriptorSet objects will be used as a // fallback to input_files on command line, so create that db first. if (!descriptor_set_in_names_.empty()) { - descriptor_set_in_database.reset(new SimpleDescriptorDatabase()); - if (!PopulateSimpleDescriptorDatabase(descriptor_set_in_database.get())) { - return 1; + for (const std::string& name : descriptor_set_in_names_) { + std::unique_ptr database_for_descriptor_set = + PopulateSingleSimpleDescriptorDatabase(name); + if (!database_for_descriptor_set) { + return EXIT_FAILURE; + } + databases_per_descriptor_set.push_back( + std::move(database_for_descriptor_set)); + } + + std::vector raw_databases_per_descriptor_set; + raw_databases_per_descriptor_set.reserve( + databases_per_descriptor_set.size()); + for (const std::unique_ptr& db : + databases_per_descriptor_set) { + raw_databases_per_descriptor_set.push_back(db.get()); } + descriptor_set_in_database.reset( + new MergedDescriptorDatabase(raw_databases_per_descriptor_set)); } if (proto_path_.empty()) { @@ -876,6 +924,16 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } + for (auto fd : parsed_files) { + if (!AllowProto3Optional(*fd) && ContainsProto3Optional(fd)) { + std::cerr << fd->name() + << ": This file contains proto3 optional fields, but " + "--experimental_allow_proto3_optional was not set." + << std::endl; + return 1; + } + } + // We construct a separate GeneratorContext for each output location. Note // that two code generators may output to the same location, in which case // they should share a single GeneratorContext so that OpenForInsert() works. @@ -1000,46 +1058,57 @@ bool CommandLineInterface::InitializeDiskSourceTree( return true; } -bool CommandLineInterface::PopulateSimpleDescriptorDatabase( - SimpleDescriptorDatabase* database) { - for (int i = 0; i < descriptor_set_in_names_.size(); i++) { - int fd; - do { - fd = open(descriptor_set_in_names_[i].c_str(), O_RDONLY | O_BINARY); - } while (fd < 0 && errno == EINTR); - if (fd < 0) { - std::cerr << descriptor_set_in_names_[i] << ": " << strerror(ENOENT) - << std::endl; - return false; - } +namespace { +std::unique_ptr +PopulateSingleSimpleDescriptorDatabase(const std::string& descriptor_set_name) { + int fd; + do { + fd = open(descriptor_set_name.c_str(), O_RDONLY | O_BINARY); + } while (fd < 0 && errno == EINTR); + if (fd < 0) { + std::cerr << descriptor_set_name << ": " << strerror(ENOENT) << std::endl; + return nullptr; + } - FileDescriptorSet file_descriptor_set; - bool parsed = file_descriptor_set.ParseFromFileDescriptor(fd); - if (close(fd) != 0) { - std::cerr << descriptor_set_in_names_[i] << ": close: " << strerror(errno) - << std::endl; - return false; - } + FileDescriptorSet file_descriptor_set; + bool parsed = file_descriptor_set.ParseFromFileDescriptor(fd); + if (close(fd) != 0) { + std::cerr << descriptor_set_name << ": close: " << strerror(errno) + << std::endl; + return nullptr; + } - if (!parsed) { - std::cerr << descriptor_set_in_names_[i] << ": Unable to parse." - << std::endl; - return false; - } + if (!parsed) { + std::cerr << descriptor_set_name << ": Unable to parse." << std::endl; + return nullptr; + } - for (int j = 0; j < file_descriptor_set.file_size(); j++) { - FileDescriptorProto previously_added_file_descriptor_proto; - if (database->FindFileByName(file_descriptor_set.file(j).name(), - &previously_added_file_descriptor_proto)) { - // already present - skip - continue; - } - if (!database->Add(file_descriptor_set.file(j))) { - return false; - } + std::unique_ptr database{ + new SimpleDescriptorDatabase()}; + + for (int j = 0; j < file_descriptor_set.file_size(); j++) { + FileDescriptorProto previously_added_file_descriptor_proto; + if (database->FindFileByName(file_descriptor_set.file(j).name(), + &previously_added_file_descriptor_proto)) { + // already present - skip + continue; + } + if (!database->Add(file_descriptor_set.file(j))) { + return nullptr; } } - return true; + return database; +} + +} // namespace + +bool CommandLineInterface::AllowProto3Optional( + const FileDescriptor& file) const { + if (allow_proto3_optional_) return true; + if (file.name() == "google/protobuf/unittest_proto3_optional.proto") { + return true; + } + return false; } bool CommandLineInterface::VerifyInputFilesInDescriptors( @@ -1068,10 +1137,26 @@ bool CommandLineInterface::ParseInputFiles( DescriptorPool* descriptor_pool, DiskSourceTree* source_tree, std::vector* parsed_files) { - // Track unused imports in all source files - for (const auto& input_file : input_files_) { - descriptor_pool->AddUnusedImportTrackFile(input_file); + if (!proto_path_.empty()) { + // Track unused imports in all source files that were loaded from the + // filesystem. We do not track unused imports for files loaded from + // descriptor sets as they may be programmatically generated in which case + // exerting this level of rigor is less desirable. We're also making the + // assumption that the initial parse of the proto from the filesystem + // was rigorous in checking unused imports and that the descriptor set + // being parsed was produced then and that it was subsequent mutations + // of that descriptor set that left unused imports. + // + // Note that relying on proto_path exclusively is limited in that we may + // be loading descriptors from both the filesystem and descriptor sets + // depending on the invocation. At least for invocations that are + // exclusively reading from descriptor sets, we can eliminate this failure + // condition. + for (const auto& input_file : input_files_) { + descriptor_pool->AddUnusedImportTrackFile(input_file); + } } + bool result = true; // Parse each file. for (const auto& input_file : input_files_) { @@ -1139,6 +1224,7 @@ void CommandLineInterface::Clear() { source_info_in_descriptor_set_ = false; disallow_services_ = false; direct_dependencies_explicitly_set_ = false; + allow_proto3_optional_ = false; } bool CommandLineInterface::MakeProtoProtoPathRelative( @@ -1414,7 +1500,8 @@ bool CommandLineInterface::ParseArgument(const char* arg, std::string* name, if (*name == "-h" || *name == "--help" || *name == "--disallow_services" || *name == "--include_imports" || *name == "--include_source_info" || *name == "--version" || *name == "--decode_raw" || - *name == "--print_free_field_numbers") { + *name == "--print_free_field_numbers" || + *name == "--experimental_allow_proto3_optional") { // HACK: These are the only flags that don't take a value. // They probably should not be hard-coded like this but for now it's // not worth doing better. @@ -1621,6 +1708,9 @@ CommandLineInterface::InterpretArgument(const std::string& name, } else if (name == "--disallow_services") { disallow_services_ = true; + } else if (name == "--experimental_allow_proto3_optional") { + allow_proto3_optional_ = true; + } else if (name == "--encode" || name == "--decode" || name == "--decode_raw") { if (mode_ != MODE_COMPILE) { @@ -1921,6 +2011,28 @@ void CommandLineInterface::PrintHelpText() { << std::endl; } +bool CommandLineInterface::EnforceProto3OptionalSupport( + const std::string& codegen_name, uint64 supported_features, + const std::vector& parsed_files) const { + bool supports_proto3_optional = + supported_features & CodeGenerator::FEATURE_PROTO3_OPTIONAL; + if (!supports_proto3_optional) { + for (const auto fd : parsed_files) { + if (ContainsProto3Optional(fd)) { + std::cerr << fd->name() + << ": is a proto3 file that contains optional fields, but " + "code generator " + << codegen_name + << " hasn't been updated to support optional fields in " + "proto3. Please ask the owner of this code generator to " + "support proto3 optional."; + return false; + } + } + } + return true; +} + bool CommandLineInterface::GenerateOutput( const std::vector& parsed_files, const OutputDirective& output_directive, @@ -1955,6 +2067,12 @@ bool CommandLineInterface::GenerateOutput( } parameters.append(generator_parameters_[output_directive.name]); } + if (!EnforceProto3OptionalSupport( + output_directive.name, + output_directive.generator->GetSupportedFeatures(), parsed_files)) { + return false; + } + if (!output_directive.generator->GenerateAll(parsed_files, parameters, generator_context, &error)) { // Generator returned an error. @@ -2119,6 +2237,9 @@ bool CommandLineInterface::GeneratePluginOutput( // Generator returned an error. *error = response.error(); return false; + } else if (!EnforceProto3OptionalSupport( + plugin_name, response.supported_features(), parsed_files)) { + return false; } return true; diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index a05c32ec9016..3c95cd6ee9c7 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -226,6 +226,17 @@ class PROTOC_EXPORT CommandLineInterface { bool MakeInputsBeProtoPathRelative(DiskSourceTree* source_tree, DescriptorDatabase* fallback_database); + // Is this .proto file whitelisted, or do we have a command-line flag allowing + // us to use proto3 optional? This is a temporary control to avoid people from + // using proto3 optional until code generators have implemented it. + bool AllowProto3Optional(const FileDescriptor& file) const; + + // 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::vector& parsed_files) const; + // Return status for ParseArguments() and InterpretArgument(). enum ParseArgumentStatus { @@ -269,9 +280,6 @@ class PROTOC_EXPORT CommandLineInterface { // Verify that all the input files exist in the given database. bool VerifyInputFilesInDescriptors(DescriptorDatabase* fallback_database); - // Loads descriptor_set_in into the provided database - bool PopulateSimpleDescriptorDatabase(SimpleDescriptorDatabase* database); - // Parses input_files_ into parsed_files bool ParseInputFiles(DescriptorPool* descriptor_pool, DiskSourceTree* source_tree, @@ -373,21 +381,21 @@ class PROTOC_EXPORT CommandLineInterface { MODE_PRINT, // Print mode: print info of the given .proto files and exit. }; - Mode mode_; + Mode mode_ = MODE_COMPILE; enum PrintMode { PRINT_NONE, // Not in MODE_PRINT PRINT_FREE_FIELDS, // --print_free_fields }; - PrintMode print_mode_; + PrintMode print_mode_ = PRINT_NONE; enum ErrorFormat { ERROR_FORMAT_GCC, // GCC error output format (default). ERROR_FORMAT_MSVS // Visual Studio output (--error_format=msvs). }; - ErrorFormat error_format_; + ErrorFormat error_format_ = ERROR_FORMAT_GCC; std::vector > proto_path_; // Search path for proto files. @@ -396,7 +404,7 @@ class PROTOC_EXPORT CommandLineInterface { // Names of proto files which are allowed to be imported. Used by build // systems to enforce depend-on-what-you-import. std::set direct_dependencies_; - bool direct_dependencies_explicitly_set_; + bool direct_dependencies_explicitly_set_ = false; // If there's a violation of depend-on-what-you-import, this string will be // presented to the user. "%s" will be replaced with the violating import. @@ -435,10 +443,13 @@ class PROTOC_EXPORT CommandLineInterface { // True if --include_source_info was given, meaning that we should not strip // SourceCodeInfo from the DescriptorSet. - bool source_info_in_descriptor_set_; + bool source_info_in_descriptor_set_ = false; // Was the --disallow_services flag used? - bool disallow_services_; + bool disallow_services_ = false; + + // Was the --experimental_allow_proto3_optional flag used? + bool allow_proto3_optional_ = false; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface); }; diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index a934d7a606b3..a51ad92d1582 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -205,6 +205,17 @@ class CommandLineInterfaceTest : public testing::Test { void ExpectFileContent(const std::string& filename, const std::string& content); + // The default code generators support all features. Use this to create a + // code generator that omits the given feature(s). + void CreateGeneratorWithMissingFeatures(const std::string& name, + const std::string& description, + uint64 features) { + MockCodeGenerator* generator = new MockCodeGenerator(name); + generator->SuppressFeatures(features); + mock_generators_to_delete_.push_back(generator); + cli_.RegisterGenerator(name, generator, description); + } + private: // The object we are testing. CommandLineInterface cli_; @@ -913,6 +924,58 @@ TEST_F(CommandLineInterfaceTest, ExpectErrorSubstring("bar.proto: \"Baz\" is not defined."); } +TEST_F(CommandLineInterfaceTest, + InputsOnlyFromDescriptorSetIn_UnusedImportIsNotReported) { + FileDescriptorSet file_descriptor_set; + + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("unused.proto"); + file_descriptor_proto->add_message_type()->set_name("Unused"); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bar.proto"); + file_descriptor_proto->add_dependency("unused.proto"); + file_descriptor_proto->add_message_type()->set_name("Bar"); + + WriteDescriptorSet("unused_and_bar.bin", &file_descriptor_set); + + Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " + "--descriptor_set_in=$tmpdir/unused_and_bar.bin unused.proto bar.proto"); + ExpectNoErrors(); +} + +TEST_F(CommandLineInterfaceTest, + InputsFromDescriptorSetInAndFileSystem_UnusedImportIsReported) { + FileDescriptorSet file_descriptor_set; + + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("unused.proto"); + file_descriptor_proto->add_message_type()->set_name("Unused"); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bar.proto"); + file_descriptor_proto->add_dependency("unused.proto"); + file_descriptor_proto->add_message_type()->set_name("Bar"); + + WriteDescriptorSet("unused_and_bar.bin", &file_descriptor_set); + + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo {\n" + " optional Bar bar = 1;\n" + "}\n"); + + Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " + "--descriptor_set_in=$tmpdir/unused_and_bar.bin " + "--proto_path=$tmpdir unused.proto bar.proto foo.proto"); + // Reporting unused imports here is unfair, since it's unactionable. Notice + // the lack of a line number. + // TODO(b/144853061): If the file with unused import is from the descriptor + // set and not from the file system, suppress the warning. + ExpectWarningSubstring("bar.proto: warning: Import unused.proto is unused."); +} + TEST_F(CommandLineInterfaceTest, OnlyReportsUnusedImportsForFilesBeingGenerated) { CreateTempFile("unused.proto", @@ -975,7 +1038,6 @@ TEST_F(CommandLineInterfaceTest, ReportsTransitiveMisingImports_LeafLast) { ExpectWarningSubstring( "bar.proto:2:1: warning: Import unused.proto is unused."); } - TEST_F(CommandLineInterfaceTest, CreateDirectory) { // Test that when we output to a sub-directory, it is created. @@ -2310,6 +2372,78 @@ TEST_F(CommandLineInterfaceTest, MissingValueAtEndError) { ExpectErrorText("Missing value for flag: --test_out\n"); } +TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowed) { + CreateTempFile("foo.proto", + "syntax = \"proto3\";\n" + "message Foo {\n" + " optional int32 i = 1;\n" + "}\n"); + + Run("protocol_compiler --proto_path=$tmpdir foo.proto -odescriptor.pb"); + + ExpectErrorSubstring("--experimental_allow_proto3_optional was not set"); +} + +TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowedDescriptor) { + CreateTempFile("foo.proto", + "syntax = \"proto3\";\n" + "message Foo {\n" + " optional int32 i = 1;\n" + "}\n"); + + Run("protocol_compiler --experimental_allow_proto3_optional " + "--proto_path=$tmpdir foo.proto " + " -o$tmpdir/descriptor.pb"); + ExpectNoErrors(); + + Run("protocol_compiler --descriptor_set_in=$tmpdir/descriptor.pb foo.proto " + "--test_out=$tmpdir"); + ExpectErrorSubstring("--experimental_allow_proto3_optional was not set"); +} + +TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowedGenCode) { + CreateTempFile("foo.proto", + "syntax = \"proto3\";\n" + "message Foo {\n" + " optional int32 i = 1;\n" + "}\n"); + + Run("protocol_compiler --proto_path=$tmpdir foo.proto --test_out=$tmpdir"); + + ExpectErrorSubstring("--experimental_allow_proto3_optional was not set"); +} + +TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowedNoCodegenSupport) { + CreateTempFile("foo.proto", + "syntax = \"proto3\";\n" + "message Foo {\n" + " optional int32 i = 1;\n" + "}\n"); + + CreateGeneratorWithMissingFeatures("--no_proto3_optional_out", + "Doesn't support proto3 optional", + CodeGenerator::FEATURE_PROTO3_OPTIONAL); + + Run("protocol_compiler --experimental_allow_proto3_optional " + "--proto_path=$tmpdir foo.proto --no_proto3_optional_out=$tmpdir"); + + ExpectErrorSubstring( + "code generator --no_proto3_optional_out hasn't been updated to support " + "optional fields in proto3"); +} + +TEST_F(CommandLineInterfaceTest, Proto3OptionalAllowWithFlag) { + CreateTempFile("foo.proto", + "syntax = \"proto3\";\n" + "message Foo {\n" + " optional int32 i = 1;\n" + "}\n"); + + Run("protocol_compiler --experimental_allow_proto3_optional " + "--proto_path=$tmpdir foo.proto --test_out=$tmpdir"); + ExpectNoErrors(); +} + TEST_F(CommandLineInterfaceTest, PrintFreeFieldNumbers) { CreateTempFile("foo.proto", "syntax = \"proto2\";\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc index dbef8559278e..31fe5a684128 100755 --- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc @@ -76,8 +76,8 @@ class MockErrorCollector : public MultiFileErrorCollector { // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, int line, int column, const std::string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, - column, message); + strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, column, + message); } }; diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc index 8a661ea7c954..06da3f37c496 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -94,7 +94,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, variables_["constant_name"] = FieldConstantName(descriptor_); variables_["field_type"] = StrCat(static_cast(descriptor_->type())); - variables_["packed"] = descriptor_->options().packed() ? "true" : "false"; + variables_["packed"] = descriptor_->is_packed() ? "true" : "false"; std::string scope = IsScoped() ? ClassName(descriptor_->extension_scope(), false) + "::" : ""; @@ -157,6 +157,11 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { StringReplace(variables_["scoped_name"], "::", "_", true) + "_default"; format("const std::string $1$($2$);\n", default_str, DefaultValue(options_, descriptor_)); + } else if (descriptor_->message_type()) { + // We have to initialize the default instance for extensions at registration + // time. + default_str = + FieldMessageTypeName(descriptor_, options_) + "::default_instance()"; } else { default_str = DefaultValue(options_, descriptor_); } diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 7b08cdd7af0e..61f81429ca07 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -411,11 +411,6 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { IncludeFile("net/proto2/public/reflection_ops.h", printer); IncludeFile("net/proto2/public/wire_format.h", printer); } - if (IsProto2MessageSetFile(file_, options_)) { - format( - // Implementation of proto1 MessageSet API methods. - "#include \"net/proto2/internal/message_set_util.h\"\n"); - } if (options_.proto_h) { // Use the smaller .proto.h files. @@ -898,18 +893,21 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format("};\n"); // The DescriptorTable itself. + // Should be "bool eager = NeedsEagerDescriptorAssignment(file_, options_);" + // however this might cause a tsan failure in superroot b/148382879, + // so disable for now. + bool eager = false; format( "static ::$proto_ns$::internal::once_flag $desc_table$_once;\n" - "static bool $desc_table$_initialized = false;\n" "const ::$proto_ns$::internal::DescriptorTable $desc_table$ = {\n" - " &$desc_table$_initialized, $1$, \"$filename$\", $2$,\n" - " &$desc_table$_once, $desc_table$_sccs, $desc_table$_deps, $3$, $4$,\n" + " false, $1$, $2$, \"$filename$\", $3$,\n" + " &$desc_table$_once, $desc_table$_sccs, $desc_table$_deps, $4$, $5$,\n" " schemas, file_default_instances, $tablename$::offsets,\n" - " $file_level_metadata$, $5$, $file_level_enum_descriptors$, " + " $file_level_metadata$, $6$, $file_level_enum_descriptors$, " "$file_level_service_descriptors$,\n" "};\n\n", - protodef_name, file_data.size(), sccs_.size(), num_deps, - message_generators_.size()); + eager ? "true" : "false", protodef_name, file_data.size(), sccs_.size(), + num_deps, message_generators_.size()); // For descriptor.proto we want to avoid doing any dynamic initialization, // because in some situations that would otherwise pull in a lot of @@ -1297,12 +1295,10 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { IncludeFile("net/proto2/public/generated_message_table_driven.h", printer); IncludeFile("net/proto2/public/generated_message_util.h", printer); IncludeFile("net/proto2/public/inlined_string_field.h", printer); + IncludeFile("net/proto2/public/metadata_lite.h", printer); if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/metadata.h", printer); IncludeFile("net/proto2/public/generated_message_reflection.h", printer); - } else { - IncludeFile("net/proto2/public/metadata_lite.h", printer); } if (!message_generators_.empty()) { diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc index 0d80ea2799bd..2c45ca8fa289 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -93,6 +93,8 @@ bool CppGenerator::Generate(const FileDescriptor* file, file_options.annotation_guard_name = options[i].second; } else if (options[i].first == "speed") { file_options.enforce_mode = EnforceOptimizeMode::kSpeed; + } else if (options[i].first == "code_size") { + file_options.enforce_mode = EnforceOptimizeMode::kCodeSize; } else if (options[i].first == "lite") { file_options.enforce_mode = EnforceOptimizeMode::kLiteRuntime; } else if (options[i].first == "lite_implicit_weak_fields") { diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.h b/src/google/protobuf/compiler/cpp/cpp_generator.h index c5ff28a70ed4..85a5aab1ec37 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.h +++ b/src/google/protobuf/compiler/cpp/cpp_generator.h @@ -81,7 +81,14 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator { // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, std::string* error) const; + GeneratorContext* generator_context, + std::string* error) const override; + + uint64 GetSupportedFeatures() const override { + // We don't fully support this yet, but this is needed to unblock the tests, + // and we will have full support before the experimental flag is removed. + return FEATURE_PROTO3_OPTIONAL; + } private: bool opensource_runtime_ = true; diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index e15cd3a0c343..c3cd80829595 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -43,10 +43,13 @@ #include #include +#include +#include #include #include #include #include +#include #include #include #include @@ -244,6 +247,31 @@ void SetCommonVars(const Options& options, (*variables)["string"] = "std::string"; } +void SetUnknkownFieldsVariable(const Descriptor* descriptor, + const Options& options, + std::map* variables) { + std::string proto_ns = ProtobufNamespace(options); + std::string unknown_fields_type; + if (UseUnknownFieldSet(descriptor->file(), options)) { + unknown_fields_type = "::" + proto_ns + "::UnknownFieldSet"; + (*variables)["unknown_fields"] = + "_internal_metadata_.unknown_fields<" + unknown_fields_type + ">(" + + unknown_fields_type + "::default_instance)"; + } else { + unknown_fields_type = + PrimitiveTypeName(options, FieldDescriptor::CPPTYPE_STRING); + (*variables)["unknown_fields"] = "_internal_metadata_.unknown_fields<" + + unknown_fields_type + ">(::" + proto_ns + + "::internal::GetEmptyString)"; + } + (*variables)["unknown_fields_type"] = unknown_fields_type; + (*variables)["have_unknown_fields"] = + "_internal_metadata_.have_unknown_fields()"; + (*variables)["mutable_unknown_fields"] = + "_internal_metadata_.mutable_unknown_fields<" + unknown_fields_type + + ">()"; +} + std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter) { std::string result; @@ -334,6 +362,16 @@ std::string QualifiedClassName(const EnumDescriptor* d) { return QualifiedClassName(d, Options()); } +std::string QualifiedExtensionName(const FieldDescriptor* d, + const Options& options) { + GOOGLE_DCHECK(d->is_extension()); + return QualifiedFileLevelSymbol(d->file(), FieldName(d), options); +} + +std::string QualifiedExtensionName(const FieldDescriptor* d) { + return QualifiedExtensionName(d, Options()); +} + std::string Namespace(const std::string& package) { if (package.empty()) return ""; return "::" + DotsToColons(package); @@ -1345,11 +1383,14 @@ class ParseLoopGenerator { format_.Set("GOOGLE_PROTOBUF", MacroPrefix(options_)); std::map vars; SetCommonVars(options_, &vars); + SetUnknkownFieldsVariable(descriptor, options_, &vars); format_.AddMap(vars); std::vector ordered_fields; for (auto field : FieldRange(descriptor)) { - ordered_fields.push_back(field); + if (IsFieldUsed(field, options_)) { + ordered_fields.push_back(field); + } } std::sort(ordered_fields.begin(), ordered_fields.end(), [](const FieldDescriptor* a, const FieldDescriptor* b) { @@ -1375,12 +1416,13 @@ class ParseLoopGenerator { } if (descriptor->file()->options().cc_enable_arenas()) { - format_("$p_ns$::Arena* arena = GetArenaNoVirtual(); (void)arena;\n"); + format_("$p_ns$::Arena* arena = GetArena(); (void)arena;\n"); } GenerateParseLoop(descriptor, ordered_fields); format_.Outdent(); format_("success:\n"); if (hasbits_size) format_(" _has_bits_.Or(has_bits);\n"); + format_( " return ptr;\n" "failure:\n" @@ -1495,12 +1537,20 @@ class ParseLoopGenerator { enum_validator = StrCat(", ", QualifiedClassName(field->enum_type(), options_), "_IsValid, &_internal_metadata_, ", field->number()); + format_( + "ptr = " + "$pi_ns$::Packed$1$Parser<$unknown_fields_type$>(_internal_mutable_" + "$2$(), ptr, " + "ctx$3$);\n", + DeclaredTypeMethodName(field->type()), FieldName(field), + enum_validator); + } else { + format_( + "ptr = $pi_ns$::Packed$1$Parser(_internal_mutable_$2$(), ptr, " + "ctx$3$);\n", + DeclaredTypeMethodName(field->type()), FieldName(field), + enum_validator); } - format_( - "ptr = $pi_ns$::Packed$1$Parser(_internal_mutable_$2$(), ptr, " - "ctx$3$);\n", - DeclaredTypeMethodName(field->type()), FieldName(field), - enum_validator); } else { auto field_type = field->type(); switch (field_type) { @@ -1518,7 +1568,9 @@ class ParseLoopGenerator { if (HasFieldPresence(field->file()) && val->type() == FieldDescriptor::TYPE_ENUM) { format_( - "auto object = ::$proto_ns$::internal::InitEnumParseWrapper(" + "auto object = " + "::$proto_ns$::internal::InitEnumParseWrapper<$unknown_" + "fields_type$>(" "&$1$_, $2$_IsValid, $3$, &_internal_metadata_);\n" "ptr = ctx->ParseMessage(&object, ptr);\n", FieldName(field), QualifiedClassName(val->enum_type()), @@ -1533,8 +1585,7 @@ class ParseLoopGenerator { "if (!_internal_has_$1$()) {\n" " clear_$2$();\n" " $2$_.$1$_ = ::$proto_ns$::Arena::CreateMessage<\n" - " $pi_ns$::LazyField>(" - "GetArenaNoVirtual());\n" + " $pi_ns$::LazyField>(GetArena());\n" " set_has_$1$();\n" "}\n" "ptr = ctx->ParseMessage($2$_.$1$_, ptr);\n", @@ -1624,7 +1675,10 @@ class ParseLoopGenerator { field->number()); } } else { - std::string size = (field->type() == FieldDescriptor::TYPE_SINT32 || field->type() == FieldDescriptor::TYPE_UINT32) ? "32" : "64"; + std::string size = (field->type() == FieldDescriptor::TYPE_SINT32 || + field->type() == FieldDescriptor::TYPE_UINT32) + ? "32" + : "64"; std::string zigzag; if ((field->type() == FieldDescriptor::TYPE_SINT32 || field->type() == FieldDescriptor::TYPE_SINT64)) { @@ -1807,7 +1861,10 @@ class ParseLoopGenerator { "}\n"); } format_( - " ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);\n" + " ptr = UnknownFieldParse(tag,\n" + " _internal_metadata_.mutable_unknown_fields<$unknown_" + "fields_type$>(),\n" + " ptr, ctx);\n" " CHK_(ptr != nullptr);\n" " continue;\n"); } @@ -1827,6 +1884,130 @@ void GenerateParserLoop(const Descriptor* descriptor, int num_hasbits, generator.GenerateParserLoop(descriptor); } +static bool HasExtensionFromFile(const Message& msg, const FileDescriptor* file, + const Options& options, + bool* has_opt_codesize_extension) { + std::vector fields; + auto reflection = msg.GetReflection(); + reflection->ListFields(msg, &fields); + for (auto field : fields) { + const auto* field_msg = field->message_type(); + if (field_msg == nullptr) { + // It so happens that enums Is_Valid are still generated so enums work. + // Only messages have potential problems. + continue; + } + // If this option has an extension set AND that extension is defined in the + // same file we have bootstrap problem. + if (field->is_extension()) { + const auto* msg_extension_file = field->message_type()->file(); + if (msg_extension_file == file) return true; + if (has_opt_codesize_extension && + GetOptimizeFor(msg_extension_file, options) == + FileOptions::CODE_SIZE) { + *has_opt_codesize_extension = true; + } + } + // Recurse in this field to see if there is a problem in there + if (field->is_repeated()) { + for (int i = 0; i < reflection->FieldSize(msg, field); i++) { + if (HasExtensionFromFile(reflection->GetRepeatedMessage(msg, field, i), + file, options, has_opt_codesize_extension)) { + return true; + } + } + } else { + if (HasExtensionFromFile(reflection->GetMessage(msg, field), file, + options, has_opt_codesize_extension)) { + return true; + } + } + } + return false; +} + +static bool HasBootstrapProblem(const FileDescriptor* file, + const Options& options, + bool* has_opt_codesize_extension) { + static auto& cache = *new std::unordered_map; + auto it = cache.find(file); + if (it != cache.end()) return it->second; + // In order to build the data structures for the reflective parse, it needs + // to parse the serialized descriptor describing all the messages defined in + // this file. Obviously this presents a bootstrap problem for descriptor + // messages. + if (file->name() == "net/proto2/proto/descriptor.proto" || + file->name() == "google/protobuf/descriptor.proto") { + return true; + } + // Unfortunately we're not done yet. The descriptor option messages allow + // for extensions. So we need to be able to parse these extensions in order + // to parse the file descriptor for a file that has custom options. This is a + // problem when these custom options extensions are defined in the same file. + FileDescriptorProto linkedin_fd_proto; + const DescriptorPool* pool = file->pool(); + const Descriptor* fd_proto_descriptor = + pool->FindMessageTypeByName(linkedin_fd_proto.GetTypeName()); + // Not all pools have descriptor.proto in them. In these cases there for sure + // are no custom options. + if (fd_proto_descriptor == nullptr) return false; + + // It's easier to inspect file as a proto, because we can use reflection on + // the proto to iterate over all content. + file->CopyTo(&linkedin_fd_proto); + + // linkedin_fd_proto is a generated proto linked in the proto compiler. As + // such it doesn't know the extensions that are potentially present in the + // descriptor pool constructed from the protos that are being compiled. These + // custom options are therefore in the unknown fields. + // By building the corresponding FileDescriptorProto in the pool constructed + // by the protos that are being compiled, ie. file's pool, the unknown fields + // are converted to extensions. + DynamicMessageFactory factory(pool); + Message* fd_proto = factory.GetPrototype(fd_proto_descriptor)->New(); + fd_proto->ParseFromString(linkedin_fd_proto.SerializeAsString()); + + bool& res = cache[file]; + res = HasExtensionFromFile(*fd_proto, file, options, + has_opt_codesize_extension); + delete fd_proto; + return res; +} + +FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, + const Options& options, + bool* has_opt_codesize_extension) { + if (has_opt_codesize_extension) *has_opt_codesize_extension = false; + switch (options.enforce_mode) { + case EnforceOptimizeMode::kSpeed: + return FileOptions::SPEED; + case EnforceOptimizeMode::kLiteRuntime: + return FileOptions::LITE_RUNTIME; + case EnforceOptimizeMode::kCodeSize: + if (file->options().optimize_for() == FileOptions::LITE_RUNTIME) { + return FileOptions::LITE_RUNTIME; + } + if (HasBootstrapProblem(file, options, has_opt_codesize_extension)) { + return FileOptions::SPEED; + } + return FileOptions::CODE_SIZE; + case EnforceOptimizeMode::kNoEnforcement: + if (file->options().optimize_for() == FileOptions::CODE_SIZE) { + if (HasBootstrapProblem(file, options, has_opt_codesize_extension)) { + GOOGLE_LOG(WARNING) << "Proto states optimize_for = CODE_SIZE, but we " + "cannot honor that because it contains custom option " + "extensions defined in the same proto."; + return FileOptions::SPEED; + } + } + return file->options().optimize_for(); + } + + GOOGLE_LOG(FATAL) << "Unknown optimization enforcement requested."; + // The phony return below serves to silence a warning from GCC 8. + return FileOptions::SPEED; +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 28cf78e7e625..072d94955e49 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -83,6 +83,10 @@ extern const char kThinSeparator[]; void SetCommonVars(const Options& options, std::map* variables); +void SetUnknkownFieldsVariable(const Descriptor* descriptor, + const Options& options, + std::map* variables); + bool GetBootstrapBasename(const Options& options, const std::string& basename, std::string* bootstrap_basename); bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context, @@ -130,6 +134,10 @@ inline std::string ClassName(const EnumDescriptor* descriptor, bool qualified) { : ClassName(descriptor); } +std::string QualifiedExtensionName(const FieldDescriptor* d, + const Options& options); +std::string QualifiedExtensionName(const FieldDescriptor* d); + // Type name of default instance. std::string DefaultInstanceType(const Descriptor* descriptor, const Options& options); @@ -339,6 +347,12 @@ inline bool IsLazy(const FieldDescriptor* field, const Options& options) { !options.opensource_runtime; } +// Returns true if "field" is used. +inline bool IsFieldUsed(const FieldDescriptor* /*field*/, + const Options& /*options*/) { + return true; +} + // Does the file contain any definitions that need extension_set.h? bool HasExtensionsOrExtendableMessage(const FileDescriptor* file); @@ -414,6 +428,12 @@ inline bool HasFieldPresence(const FileDescriptor* file) { return file->syntax() != FileDescriptor::SYNTAX_PROTO3; } +inline bool HasHasbit(const FieldDescriptor* field) { + // TODO(haberman): remove, and give some proto3 fields hasbits. + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) return false; + return field->is_singular_with_presence(); +} + // Returns true if 'enum' semantics are such that unknown values are preserved // in the enum field itself, rather than going to the UnknownFieldSet. inline bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) { @@ -475,16 +495,32 @@ inline std::string IncludeGuard(const FileDescriptor* file, bool pb_h, } } +// Returns the OptimizeMode for this file, furthermore it updates a status +// bool if has_opt_codesize_extension is non-null. If this status bool is true +// it means this file contains an extension that itself is defined as +// optimized_for = CODE_SIZE. +FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, + const Options& options, + bool* has_opt_codesize_extension); inline FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, const Options& options) { - switch (options.enforce_mode) { - case EnforceOptimizeMode::kSpeed: - return FileOptions::SPEED; - case EnforceOptimizeMode::kLiteRuntime: - return FileOptions::LITE_RUNTIME; - case EnforceOptimizeMode::kNoEnforcement: - default: - return file->options().optimize_for(); + return GetOptimizeFor(file, options, nullptr); +} +inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file, + const Options& options) { + bool has_opt_codesize_extension; + if (GetOptimizeFor(file, options, &has_opt_codesize_extension) == + FileOptions::CODE_SIZE && + has_opt_codesize_extension) { + // If this filedescriptor contains an extension from another file which + // is optimized_for = CODE_SIZE. We need to be careful in the ordering so + // we eagerly build the descriptors in the dependencies before building + // the descriptors of this file. + return true; + } else { + // If we have a generated code based parser we never need eager + // initialization of descriptors of our deps. + return false; } } diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index cc54f43e11dc..da4a38768e1d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -68,14 +69,38 @@ using internal::WireFormatLite; namespace { +// Create an expression that evaluates to +// "for all i, (_has_bits_[i] & masks[i]) == masks[i]" +// 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& masks, bool return_success = true, + StringPiece has_bits_var = "_has_bits_") { + std::vector parts; + for (int i = 0; i < masks.size(); i++) { + if (masks[i] == 0) continue; + std::string m = StrCat("0x", strings::Hex(masks[i], strings::ZERO_PAD_8)); + // Each xor evaluates to 0 if the expected bits are present. + parts.push_back( + StrCat("((", has_bits_var, "[", i, "] & ", m, ") ^ ", m, ")")); + } + GOOGLE_CHECK(!parts.empty()); + // If we have multiple parts, each expected to be 0, then bitwise-or them. + std::string result = + parts.size() == 1 + ? parts[0] + : StrCat("(", Join(parts, "\n | "), ")"); + return result + (return_success ? " == 0" : " != 0"); +} + void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field, const std::vector& has_bit_indices, - io::Printer* printer, int* cached_has_bit_index) { + io::Printer* printer, int* cached_has_word_index) { if (!field->options().weak()) { int has_bit_index = has_bit_indices[field->index()]; - if (*cached_has_bit_index != (has_bit_index / 32)) { - *cached_has_bit_index = (has_bit_index / 32); - format("cached_has_bits = _has_bits_[$1$];\n", *cached_has_bit_index); + if (*cached_has_word_index != (has_bit_index / 32)) { + *cached_has_word_index = (has_bit_index / 32); + format("cached_has_bits = _has_bits_[$1$];\n", *cached_has_word_index); } const std::string mask = StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); @@ -132,19 +157,45 @@ bool IsPOD(const FieldDescriptor* field) { } } -// Helper for the code that emits the SharedCtor() method. -bool CanConstructByZeroing(const FieldDescriptor* field, - const Options& options) { +// Helper for the code that emits the SharedCtor() and InternalSwap() methods. +// Anything that is a POD or a "normal" message (represented by a pointer) can +// be manipulated as raw bytes. +bool CanBeManipulatedAsRawBytes(const FieldDescriptor* field, + const Options& options) { bool ret = CanInitializeByZeroing(field); // Non-repeated, non-lazy message fields are simply raw pointers, so we can - // use memset to initialize these in SharedCtor. We cannot use this in - // Clear, as we need to potentially delete the existing value. + // swap them or use memset to initialize these in SharedCtor. We cannot use + // this in Clear, as we need to potentially delete the existing value. ret = ret || (!field->is_repeated() && !IsLazy(field, options) && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); return ret; } +// Finds runs of fields for which `predicate` is true. +// RunMap maps from fields that start each run to the number of fields in that +// run. This is optimized for the common case that there are very few runs in +// a message and that most of the eligible fields appear together. +using RunMap = std::unordered_map; +RunMap FindRuns(const std::vector& fields, + const std::function& predicate) { + RunMap runs; + const FieldDescriptor* last_start = nullptr; + + for (auto field : fields) { + if (predicate(field)) { + if (last_start == nullptr) { + last_start = field; + } + + runs[last_start]++; + } else { + last_start = nullptr; + } + } + return runs; +} + // Emits an if-statement with a condition that evaluates to true if |field| is // considered non-default (will be sent over the wire), for message types // without true field presence. Should only be called if @@ -236,7 +287,7 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) { bool ShouldMarkClassAsFinal(const Descriptor* descriptor, const Options& options) { - return false; + return true; } bool ShouldMarkClearAsFinal(const Descriptor* descriptor, @@ -320,23 +371,6 @@ bool TableDrivenParsingEnabled(const Descriptor* descriptor, return true; } -void SetUnknkownFieldsVariable(const Descriptor* descriptor, - const Options& options, - std::map* variables) { - std::string proto_ns = ProtobufNamespace(options); - if (UseUnknownFieldSet(descriptor->file(), options)) { - (*variables)["unknown_fields_type"] = "::" + proto_ns + "::UnknownFieldSet"; - } else { - (*variables)["unknown_fields_type"] = - PrimitiveTypeName(options, FieldDescriptor::CPPTYPE_STRING); - } - (*variables)["have_unknown_fields"] = - "_internal_metadata_.have_unknown_fields()"; - (*variables)["unknown_fields"] = "_internal_metadata_.unknown_fields()"; - (*variables)["mutable_unknown_fields"] = - "_internal_metadata_.mutable_unknown_fields()"; -} - bool IsCrossFileMapField(const FieldDescriptor* field) { if (!field->is_map()) { return false; @@ -360,82 +394,17 @@ bool IsRequired(const std::vector& v) { return v.front()->is_required(); } -// Allows chunking repeated fields together and non-repeated fields if the -// fields share the same has_byte index. -// TODO(seongkim): use lambda with capture instead of functor. -class MatchRepeatedAndHasByte { - public: - MatchRepeatedAndHasByte(const std::vector* has_bit_indices, - bool has_field_presence) - : has_bit_indices_(*has_bit_indices), - has_field_presence_(has_field_presence) {} - - // Returns true if the following conditions are met: - // --both fields are repeated fields - // --both fields are non-repeated fields with either has_field_presence is - // false or have the same has_byte index. - bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const { - return a->is_repeated() == b->is_repeated() && - (!has_field_presence_ || a->is_repeated() || - has_bit_indices_[a->index()] / 8 == - has_bit_indices_[b->index()] / 8); - } - - private: - const std::vector& has_bit_indices_; - const bool has_field_presence_; -}; - -// Allows chunking required fields separately after chunking with -// MatchRepeatedAndHasByte. -class MatchRepeatedAndHasByteAndRequired : public MatchRepeatedAndHasByte { - public: - MatchRepeatedAndHasByteAndRequired(const std::vector* has_bit_indices, - bool has_field_presence) - : MatchRepeatedAndHasByte(has_bit_indices, has_field_presence) {} - - bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const { - return MatchRepeatedAndHasByte::operator()(a, b) && - a->is_required() == b->is_required(); - } -}; - -// Allows chunking zero-initializable fields separately after chunking with -// MatchRepeatedAndHasByte. -class MatchRepeatedAndHasByteAndZeroInits : public MatchRepeatedAndHasByte { - public: - MatchRepeatedAndHasByteAndZeroInits(const std::vector* has_bit_indices, - bool has_field_presence) - : MatchRepeatedAndHasByte(has_bit_indices, has_field_presence) {} - - bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const { - return MatchRepeatedAndHasByte::operator()(a, b) && - CanInitializeByZeroing(a) == CanInitializeByZeroing(b); - } -}; - // Collects neighboring fields based on a given criteria (equivalent predicate). template std::vector> CollectFields( const std::vector& fields, const Predicate& equivalent) { std::vector> chunks; - if (fields.empty()) { - return chunks; - } - - const FieldDescriptor* last_field = fields.front(); - std::vector chunk; for (auto field : fields) { - if (!equivalent(last_field, field) && !chunk.empty()) { - chunks.push_back(chunk); - chunk.clear(); + if (chunks.empty() || !equivalent(chunks.back().back(), field)) { + chunks.emplace_back(); } - chunk.push_back(field); - last_field = field; - } - if (!chunk.empty()) { - chunks.push_back(chunk); + chunks.back().push_back(field); } return chunks; } @@ -475,20 +444,18 @@ class ColdChunkSkipper { ColdChunkSkipper( const Options& options, const std::vector>& chunks, - const std::vector& has_bit_indices, const double cold_threshold, - bool has_field_presence) + const std::vector& has_bit_indices, const double cold_threshold) : chunks_(chunks), has_bit_indices_(has_bit_indices), access_info_map_(options.access_info_map), - cold_threshold_(cold_threshold), - has_field_presence_(has_field_presence) { + cold_threshold_(cold_threshold) { SetCommonVars(options, &variables_); } // May open an external if check for a batch of cold fields. "from" is the // prefix to _has_bits_ to allow MergeFrom to use "from._has_bits_". // Otherwise, it should be "". - void OnStartChunk(int chunk, int cached_has_bit_index, + void OnStartChunk(int chunk, int cached_has_word_index, const std::string& from, io::Printer* printer); bool OnEndChunk(int chunk, io::Printer* printer); @@ -505,7 +472,6 @@ class ColdChunkSkipper { const double cold_threshold_; std::map variables_; int limit_chunk_ = -1; - bool has_field_presence_; }; // Tuning parameters for ColdChunkSkipper. @@ -518,11 +484,11 @@ bool ColdChunkSkipper::IsColdChunk(int chunk) { } -void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_bit_index, +void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index, const std::string& from, io::Printer* printer) { Formatter format(printer, variables_); - if (!access_info_map_ || !has_field_presence_) { + if (!access_info_map_ || has_bit_indices_.empty()) { return; } else if (chunk < limit_chunk_) { // We are already inside a run of cold chunks. @@ -564,7 +530,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_bit_index, format(" ||\n "); } format.Set("mask", strings::Hex(mask, strings::ZERO_PAD_8)); - if (this_word == cached_has_bit_index) { + if (this_word == cached_has_word_index) { format("(cached_has_bits & 0x$mask$u) != 0"); } else { format("($1$_has_bits_[$2$] & 0x$mask$u) != 0", from, this_word); @@ -616,6 +582,10 @@ MessageGenerator::MessageGenerator( // Compute optimized field order to be used for layout and initialization // purposes. for (auto field : FieldRange(descriptor_)) { + if (!IsFieldUsed(field, options_)) { + continue; + } + if (IsWeak(field, options_)) { num_weak_fields_++; } else if (!field->containing_oneof()) { @@ -664,6 +634,20 @@ size_t MessageGenerator::HasBitsSize() const { return sizeof_has_bits; } +int MessageGenerator::HasBitIndex(const FieldDescriptor* field) const { + return has_bit_indices_.empty() ? -1 : has_bit_indices_[field->index()]; +} + +int MessageGenerator::HasByteIndex(const FieldDescriptor* field) const { + int hasbit = HasBitIndex(field); + return hasbit == -1 ? -1 : hasbit / 8; +} + +int MessageGenerator::HasWordIndex(const FieldDescriptor* field) const { + int hasbit = HasBitIndex(field); + return hasbit == -1 ? -1 : hasbit / 32; +} + void MessageGenerator::AddGenerators( std::vector>* enum_generators, std::vector>* extension_generators) { @@ -694,7 +678,8 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { ordered_fields.insert(ordered_fields.begin(), optimized_order_.begin(), optimized_order_.end()); for (auto field : FieldRange(descriptor_)) { - if (field->containing_oneof() == NULL && !field->options().weak()) { + if (field->containing_oneof() == nullptr && !field->options().weak() && + IsFieldUsed(field, options_)) { continue; } ordered_fields.push_back(field); @@ -722,28 +707,35 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { format.AddMap(vars); if (field->is_repeated()) { - format( - "$deprecated_attr$int ${1$$name$_size$}$() const;\n" - "private:\n" - "int ${1$_internal_$name$_size$}$() const;\n" - "public:\n", - field); + format("$deprecated_attr$int ${1$$name$_size$}$() const$2$\n", field, + IsFieldUsed(field, options_) ? ";" : " {__builtin_trap();}"); + if (IsFieldUsed(field, options_)) { + format( + "private:\n" + "int ${1$_internal_$name$_size$}$() const;\n" + "public:\n", + field); + } } else if (HasHasMethod(field)) { - format( - "$deprecated_attr$bool ${1$has_$name$$}$() const;\n" - "private:\n" - "bool _internal_has_$name$() const;\n" - "public:\n", - field); + format("$deprecated_attr$bool ${1$has_$name$$}$() const$2$\n", field, + IsFieldUsed(field, options_) ? ";" : " {__builtin_trap();}"); + if (IsFieldUsed(field, options_)) { + format( + "private:\n" + "bool _internal_has_$name$() const;\n" + "public:\n"); + } } else if (HasPrivateHasMethod(field)) { - format( - "private:\n" - "bool ${1$_internal_has_$name$$}$() const;\n" - "public:\n", - field); + if (IsFieldUsed(field, options_)) { + format( + "private:\n" + "bool ${1$_internal_has_$name$$}$() const;\n" + "public:\n", + field); + } } - - format("$deprecated_attr$void ${1$clear_$name$$}$();\n", field); + format("$deprecated_attr$void ${1$clear_$name$$}$()$2$\n", field, + IsFieldUsed(field, options_) ? ";" : "{__builtin_trap();}"); // Generate type-specific accessor declarations. field_generators_.get(field).GenerateAccessorDeclarations(printer); @@ -778,6 +770,12 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { void MessageGenerator::GenerateSingularFieldHasBits( const FieldDescriptor* field, Formatter format) { + if (!IsFieldUsed(field, options_)) { + format( + "inline bool $classname$::has_$name$() const { " + "__builtin_trap(); }\n"); + return; + } if (field->options().weak()) { format( "inline bool $classname$::has_$name$() const {\n" @@ -857,6 +855,17 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) { void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field, const Formatter& format) { + if (!IsFieldUsed(field, options_)) { + if (HasHasMethod(field)) { + format( + "inline bool $classname$::has_$name$() const { " + "__builtin_trap(); }\n"); + } + format( + "inline void $classname$::set_has_$name$() { __builtin_trap(); " + "}\n"); + return; + } // Singular field in a oneof // N.B.: Without field presence, we do not use has-bits or generate // has_$name$() methods, but oneofs still have set_has_$name$(). @@ -891,6 +900,11 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field, void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field, bool is_inline, Formatter format) { + if (!IsFieldUsed(field, options_)) { + format("void $classname$::clear_$name$() { __builtin_trap(); }\n"); + return; + } + // Generate clear_$name$(). if (is_inline) { format("inline "); @@ -936,6 +950,10 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { for (auto field : FieldRange(descriptor_)) { PrintFieldComment(format, field); + if (!IsFieldUsed(field, options_)) { + continue; + } + std::map vars; SetCommonFieldVariables(field, &vars, options_); @@ -944,18 +962,24 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { // Generate has_$name$() or $name$_size(). if (field->is_repeated()) { - format( - "inline int $classname$::_internal_$name$_size() const {\n" - " return $name$_$1$.size();\n" - "}\n" - "inline int $classname$::$name$_size() const {\n" - "$annotate_accessor$" - " return _internal_$name$_size();\n" - "}\n", - IsImplicitWeakField(field, options_, scc_analyzer_) && - field->message_type() - ? ".weak" - : ""); + if (!IsFieldUsed(field, options_)) { + format( + "inline int $classname$::$name$_size() const { " + "__builtin_trap(); }\n"); + } else { + format( + "inline int $classname$::_internal_$name$_size() const {\n" + " return $name$_$1$.size();\n" + "}\n" + "inline int $classname$::$name$_size() const {\n" + "$annotate_accessor$" + " return _internal_$name$_size();\n" + "}\n", + IsImplicitWeakField(field, options_, scc_analyzer_) && + field->message_type() + ? ".weak" + : ""); + } } else if (field->containing_oneof()) { format.Set("field_name", UnderscoresToCamelCase(field->name(), true)); format.Set("oneof_name", field->containing_oneof()->name()); @@ -972,7 +996,9 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { } // Generate type-specific accessors. - field_generators_.get(field).GenerateInlineAccessorDefinitions(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GenerateInlineAccessorDefinitions(printer); + } format("\n"); } @@ -983,8 +1009,9 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { Formatter format(printer, variables_); - format.Set("class_final", - ShouldMarkClassAsFinal(descriptor_, options_) ? "final" : ""); + format.Set("class_final", ShouldMarkClassAsFinal(descriptor_, options_) + ? "PROTOBUF_FINAL" + : ""); if (IsMapEntryMessage(descriptor_)) { std::map vars; @@ -1093,8 +1120,13 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format(" public:\n"); format.Indent(); + if (SupportsArenas(descriptor_)) { + format("inline $classname$() : $classname$(nullptr) {};\n"); + } else { + format("$classname$();\n"); + } + format( - "$classname$();\n" "virtual ~$classname$();\n" "\n" "$classname$(const $classname$& from);\n" @@ -1108,7 +1140,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " return *this;\n" "}\n" "inline $classname$& operator=($classname$&& from) noexcept {\n" - " if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {\n" + " if (GetArena() == from.GetArena()) {\n" " if (this != &from) InternalSwap(&from);\n" " } else {\n" " CopyFrom(from);\n" @@ -1139,21 +1171,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n"); } - // N.B.: We exclude GetArena() when arena support is disabled, falling back on - // MessageLite's implementation which returns NULL rather than generating our - // own method which returns NULL, in order to reduce code size. - if (SupportsArenas(descriptor_)) { - // virtual method version of GetArenaNoVirtual(), required for generic - // dispatch given a MessageLite* (e.g., in RepeatedField::AddAllocated()). - format( - "inline ::$proto_ns$::Arena* GetArena() const final {\n" - " return GetArenaNoVirtual();\n" - "}\n" - "inline void* GetMaybeArenaPointer() const final {\n" - " return MaybeArenaPtr();\n" - "}\n"); - } - // Only generate this member if it's not disabled. if (HasDescriptorMethods(descriptor_->file(), options_) && !descriptor_->options().no_standard_descriptor_accessor()) { @@ -1290,7 +1307,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format( "inline void Swap($classname$* other) {\n" " if (other == this) return;\n" - " if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n" + " if (GetArena() == other->GetArena()) {\n" " InternalSwap(other);\n" " } else {\n" " ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n" @@ -1298,7 +1315,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "}\n" "void UnsafeArenaSwap($classname$* other) {\n" " if (other == this) return;\n" - " $DCHK$(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n" + " $DCHK$(GetArena() == other->GetArena());\n" " InternalSwap(other);\n" "}\n"); } else { @@ -1393,26 +1410,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "inline void RegisterArenaDtor(::$proto_ns$::Arena* arena);\n"); } - if (SupportsArenas(descriptor_)) { - format( - "private:\n" - "inline ::$proto_ns$::Arena* GetArenaNoVirtual() const {\n" - " return _internal_metadata_.arena();\n" - "}\n" - "inline void* MaybeArenaPtr() const {\n" - " return _internal_metadata_.raw_arena_ptr();\n" - "}\n"); - } else { - format( - "private:\n" - "inline ::$proto_ns$::Arena* GetArenaNoVirtual() const {\n" - " return nullptr;\n" - "}\n" - "inline void* MaybeArenaPtr() const {\n" - " return nullptr;\n" - "}\n"); - } - format( "public:\n" "\n"); @@ -1482,7 +1479,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { // TODO(seongkim): Remove hack to track field access and remove this class. format("class _Internal;\n"); - for (auto field : FieldRange(descriptor_)) { // set_has_***() generated in all oneofs. if (!field->is_repeated() && !field->options().weak() && @@ -1536,16 +1532,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n"); } - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - format( - "::$proto_ns$::internal::InternalMetadataWithArena " - "_internal_metadata_;\n"); - } else { - format( - "::$proto_ns$::internal::InternalMetadataWithArenaLite " - "_internal_metadata_;\n"); - } - if (SupportsArenas(descriptor_)) { format( "template friend class " @@ -1584,12 +1570,16 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { camel_oneof_name); format.Indent(); for (auto field : FieldRange(oneof)) { - field_generators_.get(field).GeneratePrivateMembers(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GeneratePrivateMembers(printer); + } } format.Outdent(); format("} $1$_;\n", oneof->name()); for (auto field : FieldRange(oneof)) { - field_generators_.get(field).GenerateStaticMembers(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GenerateStaticMembers(printer); + } } } @@ -1652,6 +1642,9 @@ void MessageGenerator::GenerateExtraDefaultFields(io::Printer* printer) { if (descriptor_->oneof_decl_count() > 0 || num_weak_fields_ > 0) { for (auto oneof : OneOfRange(descriptor_)) { for (auto field : FieldRange(oneof)) { + if (!IsFieldUsed(field, options_)) { + continue; + } if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING && EffectiveStringCType(field, options_) != FieldOptions::STRING)) { @@ -1661,7 +1654,7 @@ void MessageGenerator::GenerateExtraDefaultFields(io::Printer* printer) { } } for (auto field : FieldRange(descriptor_)) { - if (field->options().weak()) { + if (field->options().weak() && IsFieldUsed(field, options_)) { format(" const ::$proto_ns$::Message* $1$_;\n", FieldName(field)); } } @@ -1974,6 +1967,9 @@ void MessageGenerator::GenerateDefaultInstanceInitializer( // TODO(kenton): Maybe all message fields (even for non-default messages) // should be initialized to point at default instances rather than NULL? for (auto field : FieldRange(descriptor_)) { + if (!IsFieldUsed(field, options_)) { + continue; + } Formatter::SaveState saver(&format); if (!field->is_repeated() && !IsLazy(field, options_) && @@ -2083,6 +2079,9 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } for (auto field : FieldRange(descriptor_)) { field_generators_.get(field).GenerateInternalAccessorDeclarations(printer); + if (!IsFieldUsed(field, options_)) { + continue; + } if (HasFieldPresence(descriptor_->file()) && !field->is_repeated() && !field->options().weak() && !field->containing_oneof()) { int has_bit_index = has_bit_indices_[field->index()]; @@ -2094,14 +2093,29 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { FieldName(field), has_bit_index / 32, (1u << (has_bit_index % 32))); } } + if (num_required_fields_ > 0 && HasFieldPresence(descriptor_->file())) { + const std::vector masks_for_has_bits = RequiredFieldsBitMask(); + format( + "static bool MissingRequiredFields(const HasBits& has_bits) " + "{\n" + " return $1$;\n" + "}\n", + ConditionalToCheckBitmasks(masks_for_has_bits, false, "has_bits")); + } + format.Outdent(); format("};\n\n"); for (auto field : FieldRange(descriptor_)) { - field_generators_.get(field).GenerateInternalAccessorDefinitions(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GenerateInternalAccessorDefinitions(printer); + } } // Generate non-inline field definitions. for (auto field : FieldRange(descriptor_)) { + if (!IsFieldUsed(field, options_)) { + continue; + } field_generators_.get(field).GenerateNonInlineAccessorDefinitions(printer); if (IsCrossFileMaybeMap(field)) { Formatter::SaveState saver(&format); @@ -2139,6 +2153,9 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { GenerateMergeFrom(printer); format("\n"); + GenerateClassSpecificMergeFrom(printer); + format("\n"); + GenerateCopyFrom(printer); format("\n"); @@ -2396,11 +2413,20 @@ std::pair MessageGenerator::GenerateOffsets( } else { format("~0u, // no _weak_field_map_\n"); } + int num_stripped = 0; + for (auto field : FieldRange(descriptor_)) { + if (!IsFieldUsed(field, options_)) { + num_stripped++; + } + } const int kNumGenericOffsets = 5; // the number of fixed offsets above const size_t offsets = kNumGenericOffsets + descriptor_->field_count() + - descriptor_->oneof_decl_count(); + descriptor_->oneof_decl_count() - num_stripped; size_t entries = offsets; for (auto field : FieldRange(descriptor_)) { + if (!IsFieldUsed(field, options_)) { + continue; + } if (field->containing_oneof() || field->options().weak()) { format("offsetof($classtype$DefaultTypeInternal, $1$_)", FieldName(field)); @@ -2426,8 +2452,11 @@ std::pair MessageGenerator::GenerateOffsets( "0,\n" "1,\n"); } else if (HasFieldPresence(descriptor_->file())) { - entries += has_bit_indices_.size(); + entries += has_bit_indices_.size() - num_stripped; for (int i = 0; i < has_bit_indices_.size(); i++) { + if (!IsFieldUsed(descriptor_->field(i), options_)) { + continue; + } const std::string index = has_bit_indices_[i] >= 0 ? StrCat(has_bit_indices_[i]) : "~0u"; format("$1$,\n", index); @@ -2465,7 +2494,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { format("void $classname$::SharedDtor() {\n"); format.Indent(); if (SupportsArenas(descriptor_)) { - format("$DCHK$(GetArenaNoVirtual() == nullptr);\n"); + format("$DCHK$(GetArena() == nullptr);\n"); } // Write the destructors for each field except oneof members. // optimized_order_ does not contain oneof fields. @@ -2522,7 +2551,8 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) { // and returns false for oneof fields. for (auto oneof : OneOfRange(descriptor_)) { for (auto field : FieldRange(oneof)) { - if (field_generators_.get(field).GenerateArenaDestructorCode(printer)) { + if (IsFieldUsed(field, options_) && + field_generators_.get(field).GenerateArenaDestructorCode(printer)) { need_registration = true; } } @@ -2556,25 +2586,13 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, std::vector processed, bool copy_constructor) const { Formatter format(printer, variables_); - const FieldDescriptor* last_start = NULL; - // RunMap maps from fields that start each run to the number of fields in that - // run. This is optimized for the common case that there are very few runs in - // a message and that most of the eligible fields appear together. - typedef std::unordered_map RunMap; - RunMap runs; - for (auto field : optimized_order_) { - if ((copy_constructor && IsPOD(field)) || - (!copy_constructor && CanConstructByZeroing(field, options_))) { - if (last_start == NULL) { - last_start = field; - } - - runs[last_start]++; - } else { - last_start = NULL; - } - } + const RunMap runs = FindRuns( + optimized_order_, [copy_constructor, this](const FieldDescriptor* field) { + return (copy_constructor && IsPOD(field)) || + (!copy_constructor && + CanBeManipulatedAsRawBytes(field, options_)); + }); std::string pod_template; if (copy_constructor) { @@ -2595,7 +2613,7 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, } const FieldDescriptor* field = optimized_order_[i]; - RunMap::const_iterator it = runs.find(field); + const auto it = runs.find(field); // We only apply the memset technique to runs of more than one field, as // assignment is better than memset for generated code clarity. @@ -2628,16 +2646,15 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { std::string superclass; superclass = SuperClassName(descriptor_, options_); - std::string initializer_with_arena = superclass + "()"; + std::string initializer_with_arena = superclass + "(arena)"; if (descriptor_->extension_range_count() > 0) { initializer_with_arena += ",\n _extensions_(arena)"; } - initializer_with_arena += ",\n _internal_metadata_(arena)"; - // Initialize member variables with arena constructor. for (auto field : optimized_order_) { + GOOGLE_DCHECK(IsFieldUsed(field, options_)); bool has_arena_constructor = field->is_repeated(); if (field->containing_oneof() == NULL && (IsLazy(field, options_) || IsStringPiece(field, options_))) { @@ -2656,8 +2673,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { initializer_with_arena += ", _weak_field_map_(arena)"; } - std::string initializer_null = - superclass + "(), _internal_metadata_(nullptr)"; + std::string initializer_null = superclass + "()"; if (IsAnyMessage(descriptor_, options_)) { initializer_null += ", _any_metadata_(&type_url_, &value_)"; } @@ -2665,14 +2681,6 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { initializer_null += ", _weak_field_map_(nullptr)"; } - format( - "$classname$::$classname$()\n" - " : $1$ {\n" - " SharedCtor();\n" - " // @@protoc_insertion_point(constructor:$full_name$)\n" - "}\n", - initializer_null); - if (SupportsArenas(descriptor_)) { format( "$classname$::$classname$(::$proto_ns$::Arena* arena)\n" @@ -2682,8 +2690,20 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { " // @@protoc_insertion_point(arena_constructor:$full_name$)\n" "}\n", initializer_with_arena); + } else { + format( + "$classname$::$classname$()\n" + " : $1$ {\n" + " SharedCtor();\n" + " // @@protoc_insertion_point(constructor:$full_name$)\n" + "}\n", + initializer_null); } + std::map vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + format.AddMap(vars); + // Generate the copy constructor. if (UsingImplicitWeakFields(descriptor_->file(), options_)) { // If we are in lite mode and using implicit weak fields, we generate a @@ -2702,7 +2722,6 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { format.Indent(); format.Indent(); format.Indent(); - format(",\n_internal_metadata_(nullptr)"); if (HasFieldPresence(descriptor_->file())) { if (!IsProto2MessageSet(descriptor_, options_)) { @@ -2733,7 +2752,9 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { format.Outdent(); format(" {\n"); - format("_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); + format( + "_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_" + "metadata_);\n"); if (descriptor_->extension_range_count() > 0) { format("_extensions_.MergeFrom(from._extensions_);\n"); @@ -2751,7 +2772,9 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { for (auto field : FieldRange(oneof)) { format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); - field_generators_.get(field).GenerateMergingCode(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GenerateMergingCode(printer); + } format("break;\n"); format.Outdent(); format("}\n"); @@ -2780,6 +2803,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { "$classname$::~$classname$() {\n" " // @@protoc_insertion_point(destructor:$full_name$)\n" " SharedDtor();\n" + " _internal_metadata_.Delete<$unknown_fields_type$>();\n" "}\n" "\n"); @@ -2819,7 +2843,9 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) { void MessageGenerator::GenerateClear(io::Printer* printer) { Formatter format(printer, variables_); - // Performance tuning parameters + + // The maximum number of bytes we will memset to zero without checking their + // hasbit to see if a zero-init is necessary. const int kMaxUnconditionalPrimitiveBytesClear = 4; format( @@ -2834,162 +2860,118 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { "// Prevent compiler warnings about cached_has_bits being unused\n" "(void) cached_has_bits;\n\n"); - int cached_has_bit_index = -1; - - // Step 1: Extensions if (descriptor_->extension_range_count() > 0) { format("_extensions_.Clear();\n"); } - int unconditional_budget = kMaxUnconditionalPrimitiveBytesClear; - for (int i = 0; i < optimized_order_.size(); i++) { - const FieldDescriptor* field = optimized_order_[i]; - - if (!CanInitializeByZeroing(field)) { - continue; + // Collect fields into chunks. Each chunk may have an if() condition that + // checks all hasbits in the chunk and skips it if none are set. + int zero_init_bytes = 0; + for (const auto& field : optimized_order_) { + if (CanInitializeByZeroing(field)) { + zero_init_bytes += EstimateAlignmentSize(field); } - - unconditional_budget -= EstimateAlignmentSize(field); } + bool merge_zero_init = zero_init_bytes > kMaxUnconditionalPrimitiveBytesClear; + int chunk_count = 0; - std::vector> chunks_frag = CollectFields( + std::vector> chunks = CollectFields( optimized_order_, - MatchRepeatedAndHasByteAndZeroInits( - &has_bit_indices_, HasFieldPresence(descriptor_->file()))); + [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { + chunk_count++; + // This predicate guarantees that there is only a single zero-init + // (memset) per chunk, and if present it will be at the beginning. + bool same = HasByteIndex(a) == HasByteIndex(b) && + a->is_repeated() == b->is_repeated() && + (CanInitializeByZeroing(a) == CanInitializeByZeroing(b) || + (CanInitializeByZeroing(a) && + (chunk_count == 1 || merge_zero_init))); + if (!same) chunk_count = 0; + return same; + }); + + ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); + int cached_has_word_index = -1; - // Merge next non-zero initializable chunk if it has the same has_byte index - // and not meeting unconditional clear condition. - std::vector> chunks; - if (!HasFieldPresence(descriptor_->file())) { - // Don't bother with merging without has_bit field. - chunks = chunks_frag; - } else { - // Note that only the next chunk is considered for merging. - for (int i = 0; i < chunks_frag.size(); i++) { - chunks.push_back(chunks_frag[i]); - const FieldDescriptor* field = chunks_frag[i].front(); - const FieldDescriptor* next_field = - (i + 1) < chunks_frag.size() ? chunks_frag[i + 1].front() : nullptr; - if (CanInitializeByZeroing(field) && - (chunks_frag[i].size() == 1 || unconditional_budget < 0) && - next_field != nullptr && - has_bit_indices_[field->index()] / 8 == - has_bit_indices_[next_field->index()] / 8) { - GOOGLE_CHECK(!CanInitializeByZeroing(next_field)); - // Insert next chunk to the current one and skip next chunk. - chunks.back().insert(chunks.back().end(), chunks_frag[i + 1].begin(), - chunks_frag[i + 1].end()); - i++; - } - } - } - - ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio, - HasFieldPresence(descriptor_->file())); for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { std::vector& chunk = chunks[chunk_index]; - GOOGLE_CHECK(!chunk.empty()); - - // Step 2: Repeated fields don't use _has_bits_; emit code to clear them - // here. - if (chunk.front()->is_repeated()) { - for (int i = 0; i < chunk.size(); i++) { - const FieldDescriptor* field = chunk[i]; - const FieldGenerator& generator = field_generators_.get(field); + cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", printer); - generator.GenerateMessageClearingCode(printer); - } - continue; - } + const FieldDescriptor* memset_start = nullptr; + const FieldDescriptor* memset_end = nullptr; + bool saw_non_zero_init = false; - cold_skipper.OnStartChunk(chunk_index, cached_has_bit_index, "", printer); - - // Step 3: Non-repeated fields that can be cleared by memset-to-0, then - // non-repeated, non-zero initializable fields. - int last_chunk = HasFieldPresence(descriptor_->file()) - ? has_bit_indices_[chunk.front()->index()] / 8 - : 0; - int last_chunk_start = 0; - int memset_run_start = -1; - int memset_run_end = -1; - - for (int i = 0; i < chunk.size(); i++) { - const FieldDescriptor* field = chunk[i]; + for (const auto& field : chunk) { if (CanInitializeByZeroing(field)) { - if (memset_run_start == -1) { - memset_run_start = i; - } - memset_run_end = i; + GOOGLE_CHECK(!saw_non_zero_init); + if (!memset_start) memset_start = field; + memset_end = field; + } else { + saw_non_zero_init = true; } } - const bool have_outer_if = - HasFieldPresence(descriptor_->file()) && chunk.size() > 1 && - (memset_run_end != chunk.size() - 1 || unconditional_budget < 0); + // Whether we wrap this chunk in: + // if (cached_has_bits & 1 && + (memset_end != chunk.back() || merge_zero_init); if (have_outer_if) { - uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_); - const int count = popcnt(last_chunk_mask); + // Emit an if() that will let us skip the whole chunk if none are set. + uint32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); + std::string chunk_mask_str = + StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); // Check (up to) 8 has_bits at a time if we have more than one field in // this chunk. Due to field layout ordering, we may check // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_DCHECK_LE(2, count); - GOOGLE_DCHECK_GE(8, count); + GOOGLE_DCHECK_LE(2, popcnt(chunk_mask)); + GOOGLE_DCHECK_GE(8, popcnt(chunk_mask)); - if (cached_has_bit_index != last_chunk / 4) { - cached_has_bit_index = last_chunk / 4; - format("cached_has_bits = _has_bits_[$1$];\n", cached_has_bit_index); + if (cached_has_word_index != HasWordIndex(chunk.front())) { + cached_has_word_index = HasWordIndex(chunk.front()); + format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index); } - format("if (cached_has_bits & 0x$1$u) {\n", - StrCat(strings::Hex(last_chunk_mask, strings::ZERO_PAD_8))); + format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); format.Indent(); } - if (memset_run_start != -1) { - if (memset_run_start == memset_run_end) { + if (memset_start) { + if (memset_start == memset_end) { // For clarity, do not memset a single field. - const FieldGenerator& generator = - field_generators_.get(chunk[memset_run_start]); - generator.GenerateMessageClearingCode(printer); + field_generators_.get(memset_start) + .GenerateMessageClearingCode(printer); } else { - const std::string first_field_name = FieldName(chunk[memset_run_start]); - const std::string last_field_name = FieldName(chunk[memset_run_end]); - format( "::memset(&$1$_, 0, static_cast(\n" " reinterpret_cast(&$2$_) -\n" " reinterpret_cast(&$1$_)) + sizeof($2$_));\n", - first_field_name, last_field_name); + FieldName(memset_start), FieldName(memset_end)); } - - // Advance last_chunk_start to skip over the fields we zeroed/memset. - last_chunk_start = memset_run_end + 1; } - // Go back and emit clears for each of the fields we processed. - for (int j = last_chunk_start; j < chunk.size(); j++) { - const FieldDescriptor* field = chunk[j]; - const FieldGenerator& generator = field_generators_.get(field); - + // Clear all non-zero-initializable fields in the chunk. + for (const auto& field : chunk) { + if (CanInitializeByZeroing(field)) continue; // It's faster to just overwrite primitive types, but we should only // clear strings and messages if they were set. // // TODO(kenton): Let the CppFieldGenerator decide this somehow. - bool should_check_bit = - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || - field->cpp_type() == FieldDescriptor::CPPTYPE_STRING; + bool have_enclosing_if = + HasBitIndex(field) != -1 && + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || + field->cpp_type() == FieldDescriptor::CPPTYPE_STRING); - bool have_enclosing_if = false; - if (should_check_bit && - // If no field presence, then always clear strings/messages as well. - HasFieldPresence(descriptor_->file())) { + if (have_enclosing_if) { PrintPresenceCheck(format, field, has_bit_indices_, printer, - &cached_has_bit_index); - have_enclosing_if = true; + &cached_has_word_index); } - generator.GenerateMessageClearingCode(printer); + field_generators_.get(field).GenerateMessageClearingCode(printer); if (have_enclosing_if) { format.Outdent(); @@ -3004,7 +2986,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { if (cold_skipper.OnEndChunk(chunk_index, printer)) { // Reset here as it may have been updated in just closed if statement. - cached_has_bit_index = -1; + cached_has_word_index = -1; } } @@ -3022,7 +3004,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { format("_has_bits_.Clear();\n"); } - format("_internal_metadata_.Clear();\n"); + std::map vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + format.AddMap(vars); + format("_internal_metadata_.Clear<$unknown_fields_type$>();\n"); format.Outdent(); format("}\n"); @@ -3045,7 +3030,7 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) { format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); // We clear only allocated objects in oneofs - if (!IsStringOrMessage(field)) { + if (!IsStringOrMessage(field) || !IsFieldUsed(field, options_)) { format("// No need to clear\n"); } else { field_generators_.get(field).GenerateClearingCode(printer); @@ -3083,7 +3068,12 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { format("_extensions_.Swap(&other->_extensions_);\n"); } - format("_internal_metadata_.Swap(&other->_internal_metadata_);\n"); + std::map vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + format.AddMap(vars); + format( + "_internal_metadata_.Swap<$unknown_fields_type$>(&other->_internal_" + "metadata_);\n"); if (HasFieldPresence(descriptor_->file())) { for (int i = 0; i < HasBitsSize() / 4; ++i) { @@ -3091,11 +3081,42 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { } } - for (int i = 0; i < optimized_order_.size(); i++) { - // optimized_order_ does not contain oneof fields, but the field - // generators for these fields do not emit swapping code on their own. + // If possible, we swap several fields at once, including padding. + const RunMap runs = + FindRuns(optimized_order_, [this](const FieldDescriptor* field) { + return CanBeManipulatedAsRawBytes(field, options_); + }); + + for (int i = 0; i < optimized_order_.size(); ++i) { const FieldDescriptor* field = optimized_order_[i]; - field_generators_.get(field).GenerateSwappingCode(printer); + const auto it = runs.find(field); + + // We only apply the memswap technique to runs of more than one field, as + // `swap(field_, other.field_)` is better than + // `memswap<...>(&field_, &other.field_)` for generated code readability. + if (it != runs.end() && it->second > 1) { + // Use a memswap, then skip run_length fields. + const size_t run_length = it->second; + const std::string first_field_name = FieldName(field); + const std::string last_field_name = + FieldName(optimized_order_[i + run_length - 1]); + + format.Set("first", first_field_name); + format.Set("last", last_field_name); + + format( + "::PROTOBUF_NAMESPACE_ID::internal::memswap<\n" + " PROTOBUF_FIELD_OFFSET($classname$, $last$_)\n" + " + sizeof($classname$::$last$_)\n" + " - PROTOBUF_FIELD_OFFSET($classname$, $first$_)>(\n" + " reinterpret_cast(&$first$_),\n" + " reinterpret_cast(&other->$first$_));\n"); + + i += run_length - 1; + // ++i at the top of the loop. + } else { + field_generators_.get(field).GenerateSwappingCode(printer); + } } for (auto oneof : OneOfRange(descriptor_)) { @@ -3148,7 +3169,7 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { "}\n"); format.Outdent(); - format("}\n\n"); + format("}\n"); } else { // Generate CheckTypeAndMergeFrom(). format( @@ -3156,11 +3177,13 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { " const ::$proto_ns$::MessageLite& from) {\n" " MergeFrom(*::$proto_ns$::internal::DownCast(\n" " &from));\n" - "}\n" - "\n"); + "}\n"); } +} +void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast. + Formatter format(printer, variables_); format( "void $classname$::MergeFrom(const $classname$& from) {\n" "// @@protoc_insertion_point(class_specific_merge_from_start:" @@ -3171,91 +3194,93 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { format("_extensions_.MergeFrom(from._extensions_);\n"); } - + std::map vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + format.AddMap(vars); format( - "_internal_metadata_.MergeFrom(from._internal_metadata_);\n" + "_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_" + "metadata_);\n" "$uint32$ cached_has_bits = 0;\n" "(void) cached_has_bits;\n\n"); - if (HasFieldPresence(descriptor_->file())) { - std::vector> chunks = CollectFields( - optimized_order_, MatchRepeatedAndHasByte(&has_bit_indices_, true)); - - ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, - kColdRatio, true); + std::vector> chunks = CollectFields( + optimized_order_, + [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { + return HasByteIndex(a) == HasByteIndex(b); + }); - // cached_has_bit_index maintains that: - // cached_has_bits = from._has_bits_[cached_has_bit_index] - // for cached_has_bit_index >= 0 - int cached_has_bit_index = -1; + ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); - for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { - const std::vector& chunk = chunks[chunk_index]; - GOOGLE_CHECK(!chunk.empty()); + // cached_has_word_index maintains that: + // cached_has_bits = from._has_bits_[cached_has_word_index] + // for cached_has_word_index >= 0 + int cached_has_word_index = -1; - // Merge Repeated fields. These fields do not require a - // check as we can simply iterate over them. - if (chunk.front()->is_repeated()) { - for (int i = 0; i < chunk.size(); i++) { - const FieldDescriptor* field = chunk[i]; + for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { + const std::vector& chunk = chunks[chunk_index]; + bool have_outer_if = chunk.size() > 1 && HasByteIndex(chunk.front()) != -1; + cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "from.", + printer); - const FieldGenerator& generator = field_generators_.get(field); - generator.GenerateMergingCode(printer); - } - continue; - } + 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_); + std::string chunk_mask_str = + StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); - // Merge Optional and Required fields (after a _has_bit_ check). - cold_skipper.OnStartChunk(chunk_index, cached_has_bit_index, "from.", - printer); + // Check (up to) 8 has_bits at a time if we have more than one field in + // this chunk. Due to field layout ordering, we may check + // _has_bits_[last_chunk * 8 / 32] multiple times. + GOOGLE_DCHECK_LE(2, popcnt(chunk_mask)); + GOOGLE_DCHECK_GE(8, popcnt(chunk_mask)); - int last_chunk = has_bit_indices_[chunk.front()->index()] / 8; - GOOGLE_DCHECK_NE(-1, last_chunk); + if (cached_has_word_index != HasWordIndex(chunk.front())) { + cached_has_word_index = HasWordIndex(chunk.front()); + format("cached_has_bits = from._has_bits_[$1$];\n", + cached_has_word_index); + } - const bool have_outer_if = chunk.size() > 1; - if (have_outer_if) { - uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_); - const int count = popcnt(last_chunk_mask); + format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); + format.Indent(); + } - // Check (up to) 8 has_bits at a time if we have more than one field in - // this chunk. Due to field layout ordering, we may check - // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_DCHECK_LE(2, count); - GOOGLE_DCHECK_GE(8, count); + // Go back and emit merging code for each of the fields we processed. + bool deferred_has_bit_changes = false; + for (const auto field : chunk) { + const FieldGenerator& generator = field_generators_.get(field); - if (cached_has_bit_index != last_chunk / 4) { - cached_has_bit_index = last_chunk / 4; - format("cached_has_bits = from._has_bits_[$1$];\n", - cached_has_bit_index); + if (field->is_repeated()) { + generator.GenerateMergingCode(printer); + } else if (field->is_optional() && !HasHasbit(field)) { + // Merge semantics without true field presence: primitive fields are + // merged only if non-zero (numeric) or non-empty (string). + bool have_enclosing_if = + EmitFieldNonDefaultCondition(printer, "from.", field); + generator.GenerateMergingCode(printer); + if (have_enclosing_if) { + format.Outdent(); + format("}\n"); } - format("if (cached_has_bits & 0x$1$u) {\n", - StrCat(strings::Hex(last_chunk_mask, strings::ZERO_PAD_8))); + } else if (field->options().weak() || + cached_has_word_index != HasWordIndex(field)) { + // Check hasbit, not using cached bits. + GOOGLE_CHECK(HasHasbit(field)); + format("if (from._internal_has_$1$()) {\n", FieldName(field)); format.Indent(); - } - - // Go back and emit merging code for each of the fields we processed. - bool deferred_has_bit_changes = false; - for (const auto field : chunk) { - const FieldGenerator& generator = field_generators_.get(field); - - // Attempt to use the state of cached_has_bits, if possible. + generator.GenerateMergingCode(printer); + format.Outdent(); + format("}\n"); + } else { + // Check hasbit, using cached bits. + GOOGLE_CHECK(HasHasbit(field)); int has_bit_index = has_bit_indices_[field->index()]; - if (!field->options().weak() && - cached_has_bit_index == has_bit_index / 32) { - const std::string mask = StrCat( - strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); - - format("if (cached_has_bits & 0x$1$u) {\n", mask); - } else { - format("if (from._internal_has_$1$()) {\n", FieldName(field)); - } + const std::string mask = StrCat( + strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); + format("if (cached_has_bits & 0x$1$u) {\n", mask); format.Indent(); if (have_outer_if && IsPOD(field)) { - // GenerateCopyConstructorCode for enum and primitive scalar fields - // does not do _has_bits_ modifications. We defer _has_bits_ - // manipulation until the end of the outer if. - // + // Defer hasbit modification until the end of chunk. // This can reduce the number of loads/stores by up to 7 per 8 fields. deferred_has_bit_changes = true; generator.GenerateCopyConstructorCode(printer); @@ -3266,38 +3291,22 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { format.Outdent(); format("}\n"); } + } - if (have_outer_if) { - if (deferred_has_bit_changes) { - // Flush the has bits for the primitives we deferred. - GOOGLE_CHECK_LE(0, cached_has_bit_index); - format("_has_bits_[$1$] |= cached_has_bits;\n", cached_has_bit_index); - } - - format.Outdent(); - format("}\n"); + if (have_outer_if) { + if (deferred_has_bit_changes) { + // Flush the has bits for the primitives we deferred. + GOOGLE_CHECK_LE(0, cached_has_word_index); + format("_has_bits_[$1$] |= cached_has_bits;\n", cached_has_word_index); } - if (cold_skipper.OnEndChunk(chunk_index, printer)) { - // Reset here as it may have been updated in just closed if statement. - cached_has_bit_index = -1; - } + format.Outdent(); + format("}\n"); } - } else { - // proto3 - for (const auto field : optimized_order_) { - const FieldGenerator& generator = field_generators_.get(field); - // Merge semantics without true field presence: primitive fields are - // merged only if non-zero (numeric) or non-empty (string). - bool have_enclosing_if = - EmitFieldNonDefaultCondition(printer, "from.", field); - generator.GenerateMergingCode(printer); - - if (have_enclosing_if) { - format.Outdent(); - format("}\n"); - } + if (cold_skipper.OnEndChunk(chunk_index, printer)) { + // Reset here as it may have been updated in just closed if statement. + cached_has_word_index = -1; } } @@ -3308,7 +3317,9 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { for (auto field : FieldRange(oneof)) { format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); - field_generators_.get(field).GenerateMergingCode(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GenerateMergingCode(printer); + } format("break;\n"); format.Outdent(); format("}\n"); @@ -3642,6 +3653,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( (i < descriptor_->field_count() && ordered_fields[i]->number() < sorted_extensions[j]->start)) { const FieldDescriptor* field = ordered_fields[i++]; + if (!IsFieldUsed(field, options_)) { + continue; + } if (field->options().weak()) { last_weak_field = field; PrintFieldComment(format, field); @@ -3701,29 +3715,6 @@ std::vector MessageGenerator::RequiredFieldsBitMask() const { return masks; } -// Create an expression that evaluates to -// "for all i, (_has_bits_[i] & masks[i]) == masks[i]" -// masks is allowed to be shorter than _has_bits_, but at least one element of -// masks must be non-zero. -static std::string ConditionalToCheckBitmasks( - const std::vector& masks) { - std::vector parts; - for (int i = 0; i < masks.size(); i++) { - if (masks[i] == 0) continue; - std::string m = StrCat("0x", strings::Hex(masks[i], strings::ZERO_PAD_8)); - // Each xor evaluates to 0 if the expected bits are present. - parts.push_back( - StrCat("((_has_bits_[", i, "] & ", m, ") ^ ", m, ")")); - } - GOOGLE_CHECK(!parts.empty()); - // If we have multiple parts, each expected to be 0, then bitwise-or them. - std::string result = - parts.size() == 1 - ? parts[0] - : StrCat("(", Join(parts, "\n | "), ")"); - return result + " == 0"; -} - void MessageGenerator::GenerateByteSize(io::Printer* printer) { Formatter format(printer, variables_); @@ -3748,7 +3739,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { return; } - if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) { + if (num_required_fields_ > 1) { // Emit a function (rarely used, we hope) that handles the required fields // by checking for each one individually. format( @@ -3798,7 +3789,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { // Handle required fields (if any). We expect all of them to be // present, so emit one conditional that checks for that. If they are all // present then the fast path executes; otherwise the slow path executes. - if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) { + if (num_required_fields_ > 1) { // The fast path works if all required fields are present. const std::vector masks_for_has_bits = RequiredFieldsBitMask(); format("if ($1$) { // All required fields are present.\n", @@ -3832,75 +3823,44 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { std::vector> chunks = CollectFields( optimized_order_, - MatchRepeatedAndHasByteAndRequired( - &has_bit_indices_, HasFieldPresence(descriptor_->file()))); + [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { + return a->label() == b->label() && HasByteIndex(a) == HasByteIndex(b); + }); // Remove chunks with required fields. chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired), chunks.end()); - ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio, - HasFieldPresence(descriptor_->file())); + ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); + int cached_has_word_index = -1; format( "$uint32$ cached_has_bits = 0;\n" "// Prevent compiler warnings about cached_has_bits being unused\n" "(void) cached_has_bits;\n\n"); - int cached_has_bit_index = -1; - for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { const std::vector& chunk = chunks[chunk_index]; - GOOGLE_CHECK(!chunk.empty()); - - // Handle repeated fields. - if (chunk.front()->is_repeated()) { - for (int i = 0; i < chunk.size(); i++) { - const FieldDescriptor* field = chunk[i]; - - PrintFieldComment(format, field); - const FieldGenerator& generator = field_generators_.get(field); - generator.GenerateByteSize(printer); - format("\n"); - } - continue; - } - - cold_skipper.OnStartChunk(chunk_index, cached_has_bit_index, "", printer); - - // Handle optional (non-repeated/oneof) fields. - // - // These are handled in chunks of 8. The first chunk is - // the non-requireds-non-repeateds-non-unions-non-extensions in - // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), - // and the second chunk is the same for - // descriptor_->field(8), descriptor_->field(9), ... - // descriptor_->field(15), - // etc. - int last_chunk = HasFieldPresence(descriptor_->file()) - ? has_bit_indices_[chunk.front()->index()] / 8 - : 0; - GOOGLE_DCHECK_NE(-1, last_chunk); - - const bool have_outer_if = - HasFieldPresence(descriptor_->file()) && chunk.size() > 1; + const bool have_outer_if = chunk.size() > 1 && HasWordIndex(chunk[0]) != -1; + cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", printer); if (have_outer_if) { - uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_); - const int count = popcnt(last_chunk_mask); + // Emit an if() that will let us skip the whole chunk if none are set. + uint32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); + std::string chunk_mask_str = + StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); // Check (up to) 8 has_bits at a time if we have more than one field in // this chunk. Due to field layout ordering, we may check // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_DCHECK_LE(2, count); - GOOGLE_DCHECK_GE(8, count); + GOOGLE_DCHECK_LE(2, popcnt(chunk_mask)); + GOOGLE_DCHECK_GE(8, popcnt(chunk_mask)); - if (cached_has_bit_index != last_chunk / 4) { - cached_has_bit_index = last_chunk / 4; - format("cached_has_bits = _has_bits_[$1$];\n", cached_has_bit_index); + if (cached_has_word_index != HasWordIndex(chunk.front())) { + cached_has_word_index = HasWordIndex(chunk.front()); + format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index); } - format("if (cached_has_bits & 0x$1$u) {\n", - StrCat(strings::Hex(last_chunk_mask, strings::ZERO_PAD_8))); + format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); format.Indent(); } @@ -3908,13 +3868,17 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { for (int j = 0; j < chunk.size(); j++) { const FieldDescriptor* field = chunk[j]; const FieldGenerator& generator = field_generators_.get(field); + bool have_enclosing_if = false; + bool need_extra_newline = false; PrintFieldComment(format, field); - bool have_enclosing_if = false; - if (HasFieldPresence(descriptor_->file())) { + if (field->is_repeated()) { + // No presence check is required. + need_extra_newline = true; + } else if (HasHasbit(field)) { PrintPresenceCheck(format, field, has_bit_indices_, printer, - &cached_has_bit_index); + &cached_has_word_index); have_enclosing_if = true; } else { // Without field presence: field is serialized only if it has a @@ -3931,6 +3895,9 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { "}\n" "\n"); } + if (need_extra_newline) { + format("\n"); + } } if (have_outer_if) { @@ -3940,7 +3907,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { if (cold_skipper.OnEndChunk(chunk_index, printer)) { // Reset here as it may have been updated in just closed if statement. - cached_has_bit_index = -1; + cached_has_word_index = -1; } } @@ -3953,7 +3920,9 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { PrintFieldComment(format, field); format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); - field_generators_.get(field).GenerateByteSize(printer); + if (IsFieldUsed(field, options_)) { + field_generators_.get(field).GenerateByteSize(printer); + } format("break;\n"); format.Outdent(); format("}\n"); @@ -4014,24 +3983,10 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { "}\n\n"); } - if (HasFieldPresence(descriptor_->file())) { - // Check that all required fields in this message are set. We can do this - // most efficiently by checking 32 "has bits" at a time. - const std::vector masks = RequiredFieldsBitMask(); - - for (int i = 0; i < masks.size(); i++) { - uint32 mask = masks[i]; - if (mask == 0) { - continue; - } - - // TODO(ckennelly): Consider doing something similar to ByteSizeLong(), - // where we check all of the required fields in a single branch (assuming - // that we aren't going to benefit from early termination). - format("if ((_has_bits_[$1$] & 0x$2$) != 0x$2$) return false;\n", - i, // 1 - StrCat(strings::Hex(mask, strings::ZERO_PAD_8))); // 2 - } + if (num_required_fields_ > 0 && HasFieldPresence(descriptor_->file())) { + format( + "if (_Internal::MissingRequiredFields(_has_bits_))" + " return false;\n"); } // Now check that all non-oneof embedded messages are initialized. @@ -4093,7 +4048,8 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + if (IsFieldUsed(field, options_) && + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !ShouldIgnoreRequiredFieldCheck(field, options_) && scc_analyzer_->HasRequiredFields(field->message_type())) { GOOGLE_CHECK(!(field->options().weak() || !field->containing_oneof())); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index bc4febf5c5d8..a212ff416b34 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -144,6 +144,7 @@ class MessageGenerator { void GenerateSerializeWithCachedSizesBody(io::Printer* printer); void GenerateByteSize(io::Printer* printer); void GenerateMergeFrom(io::Printer* printer); + void GenerateClassSpecificMergeFrom(io::Printer* printer); void GenerateCopyFrom(io::Printer* printer); void GenerateSwap(io::Printer* printer); void GenerateIsInitialized(io::Printer* printer); @@ -180,6 +181,10 @@ class MessageGenerator { bool copy_constructor) const; size_t HasBitsSize() const; + int HasBitIndex(const FieldDescriptor* a) const; + int HasByteIndex(const FieldDescriptor* a) const; + int HasWordIndex(const FieldDescriptor* a) const; + bool SameHasByte(const FieldDescriptor* a, const FieldDescriptor* b) const; std::vector RequiredFieldsBitMask() const; const Descriptor* descriptor_; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index 12c6524b5cfb..b6b8f24b6afb 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -66,10 +66,10 @@ void SetMessageVariables(const FieldDescriptor* descriptor, (*variables)["type_default_instance_ptr"] = QualifiedDefaultInstancePtr(descriptor->message_type(), options); (*variables)["type_reference_function"] = - implicit_weak - ? (" " + (*variables)["proto_ns"] + "::internal::StrongReference(" + - (*variables)["type_default_instance"] + ");\n") - : ""; + implicit_weak ? (" ::" + (*variables)["proto_ns"] + + "::internal::StrongReference(" + + (*variables)["type_default_instance"] + ");\n") + : ""; // NOTE: Escaped here to unblock proto1->proto2 migration. // TODO(liujisi): Extend this to apply for other conflicting methods. (*variables)["release_name"] = @@ -104,17 +104,43 @@ void MessageFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const { void MessageFieldGenerator::GenerateAccessorDeclarations( io::Printer* printer) const { Formatter format(printer, variables_); + if (!IsFieldUsed(descriptor_, options_)) { + format( + "$deprecated_attr$const $type$& ${1$$name$$}$() const { " + "__builtin_trap(); }\n" + "$deprecated_attr$$type$* ${1$$release_name$$}$() { " + "__builtin_trap(); }\n" + "$deprecated_attr$$type$* ${1$mutable_$name$$}$() { " + "__builtin_trap(); }\n" + "$deprecated_attr$void ${1$set_allocated_$name$$}$" + "($type$* $name$) { __builtin_trap(); }\n", + descriptor_); + if (SupportsArenas(descriptor_)) { + format( + "$deprecated_attr$void " + "${1$unsafe_arena_set_allocated_$name$$}$(\n" + " $type$* $name$) { __builtin_trap(); }\n" + "$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$() { " + "__builtin_trap(); }\n", + descriptor_); + } + return; + } format( "$deprecated_attr$const $type$& ${1$$name$$}$() const;\n" "$deprecated_attr$$type$* ${1$$release_name$$}$();\n" "$deprecated_attr$$type$* ${1$mutable_$name$$}$();\n" "$deprecated_attr$void ${1$set_allocated_$name$$}$" - "($type$* $name$);\n" - "private:\n" - "const $type$& ${1$_internal_$name$$}$() const;\n" - "$type$* ${1$_internal_mutable_$name$$}$();\n" - "public:\n", + "($type$* $name$);\n", descriptor_); + if (IsFieldUsed(descriptor_, options_)) { + format( + "private:\n" + "const $type$& ${1$_internal_$name$$}$() const;\n" + "$type$* ${1$_internal_mutable_$name$$}$();\n" + "public:\n", + descriptor_); + } if (SupportsArenas(descriptor_)) { format( "$deprecated_attr$void " @@ -127,27 +153,6 @@ void MessageFieldGenerator::GenerateAccessorDeclarations( void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( io::Printer* printer) const { - Formatter format(printer, variables_); - if (SupportsArenas(descriptor_)) { - format( - "void $classname$::unsafe_arena_set_allocated_$name$(\n" - " $type$* $name$) {\n" - "$annotate_accessor$" - // If we're not on an arena, free whatever we were holding before. - // (If we are on arena, we can just forget the earlier pointer.) - " if (GetArenaNoVirtual() == nullptr) {\n" - " delete $name$_;\n" - " }\n" - " $name$_ = $name$;\n" - " if ($name$) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " // @@protoc_insertion_point(field_unsafe_arena_set_allocated" - ":$full_name$)\n" - "}\n"); - } } void MessageFieldGenerator::GenerateInlineAccessorDefinitions( @@ -167,10 +172,35 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "}\n"); if (SupportsArenas(descriptor_)) { + format( + "inline void $classname$::unsafe_arena_set_allocated_$name$(\n" + " $type$* $name$) {\n" + "$annotate_accessor$" + // If we're not on an arena, free whatever we were holding before. + // (If we are on arena, we can just forget the earlier pointer.) + " if (GetArena() == nullptr) {\n" + " delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n" + " }\n"); + if (implicit_weak_field_) { + format( + " $name$_ = " + "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n"); + } else { + format(" $name$_ = $name$;\n"); + } + format( + " if ($name$) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " // @@protoc_insertion_point(field_unsafe_arena_set_allocated" + ":$full_name$)\n" + "}\n"); format( "inline $type$* $classname$::$release_name$() {\n" " auto temp = unsafe_arena_release_$name$();\n" - " if (GetArenaNoVirtual() != nullptr) {\n" + " if (GetArena() != nullptr) {\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " }\n" " return temp;\n" @@ -194,7 +224,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "$type_reference_function$" " $set_hasbit$\n" " if ($name$_ == nullptr) {\n" - " auto* p = CreateMaybeMessage<$type$>(GetArenaNoVirtual());\n"); + " auto* p = CreateMaybeMessage<$type$>(GetArena());\n"); if (implicit_weak_field_) { format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n"); } else { @@ -215,7 +245,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline void $classname$::set_allocated_$name$($type$* $name$) {\n" "$annotate_accessor$" - " ::$proto_ns$::Arena* message_arena = GetArenaNoVirtual();\n"); + " ::$proto_ns$::Arena* message_arena = GetArena();\n"); format(" if (message_arena == nullptr) {\n"); if (IsCrossFileMessage(descriptor_)) { format( @@ -309,12 +339,11 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( " if ($type_default_instance_ptr$ == nullptr) {\n" " msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" " ::$proto_ns$::internal::ImplicitWeakMessage>(\n" - " msg->GetArenaNoVirtual());\n" + " msg->GetArena());\n" " } else {\n" " msg->$name$_ = reinterpret_cast(\n" - " $type_default_instance_ptr$)->New(" - "msg->GetArenaNoVirtual());\n" + " $type_default_instance_ptr$)->New(msg->GetArena());\n" " }\n" " }\n" " return msg->$name$_;\n" @@ -353,12 +382,14 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( } void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); if (!HasFieldPresence(descriptor_->file())) { // If we don't have has-bits, message presence is indicated only by ptr != // NULL. Thus on clear, we need to delete the object. format( - "if (GetArenaNoVirtual() == nullptr && $name$_ != nullptr) {\n" + "if (GetArena() == nullptr && $name$_ != nullptr) {\n" " delete $name$_;\n" "}\n" "$name$_ = nullptr;\n"); @@ -369,12 +400,14 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateMessageClearingCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); if (!HasFieldPresence(descriptor_->file())) { // If we don't have has-bits, message presence is indicated only by ptr != // NULL. Thus on clear, we need to delete the object. format( - "if (GetArenaNoVirtual() == nullptr && $name$_ != nullptr) {\n" + "if (GetArena() == nullptr && $name$_ != nullptr) {\n" " delete $name$_;\n" "}\n" "$name$_ = nullptr;\n"); @@ -386,6 +419,8 @@ void MessageFieldGenerator::GenerateMessageClearingCode( } void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); if (implicit_weak_field_) { format( @@ -399,11 +434,15 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const { } void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format("swap($name$_, other->$name$_);\n"); } void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); if (options_.opensource_runtime) { // TODO(gerbens) Remove this when we don't need to destruct default @@ -418,12 +457,16 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateConstructorCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format("$name$_ = nullptr;\n"); } void MessageFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format( "if (from._internal_has_$name$()) {\n" @@ -435,6 +478,8 @@ void MessageFieldGenerator::GenerateCopyConstructorCode( void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format( "target = stream->EnsureSpace(target);\n" @@ -444,6 +489,8 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( } void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format( "total_size += $tag_size$ +\n" @@ -468,7 +515,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( format( "void $classname$::set_allocated_$name$($type$* $name$) {\n" "$annotate_accessor$" - " ::$proto_ns$::Arena* message_arena = GetArenaNoVirtual();\n" + " ::$proto_ns$::Arena* message_arena = GetArena();\n" " clear_$oneof_name$();\n" " if ($name$) {\n"); if (SupportsArenas(descriptor_->message_type()) && @@ -510,7 +557,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $type$* temp = $field_member$;\n"); if (SupportsArenas(descriptor_)) { format( - " if (GetArenaNoVirtual() != nullptr) {\n" + " if (GetArena() != nullptr) {\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " }\n"); } @@ -570,8 +617,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $field_member$ = CreateMaybeMessage< $type$ >(\n" - " GetArenaNoVirtual());\n" + " $field_member$ = CreateMaybeMessage< $type$ >(GetArena());\n" " }\n" " return $field_member$;\n" "}\n" @@ -584,10 +630,12 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( void MessageOneofFieldGenerator::GenerateClearingCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); if (SupportsArenas(descriptor_)) { format( - "if (GetArenaNoVirtual() == nullptr) {\n" + "if (GetArena() == nullptr) {\n" " delete $field_member$;\n" "}\n"); } else { @@ -643,14 +691,35 @@ void RepeatedMessageFieldGenerator::GeneratePrivateMembers( void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations( io::Printer* printer) const { Formatter format(printer, variables_); + if (!IsFieldUsed(descriptor_, options_)) { + format( + "$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index) { " + "__builtin_trap(); }\n" + "$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n" + " ${1$mutable_$name$$}$() { __builtin_trap(); }\n" + "$deprecated_attr$const $type$& ${1$$name$$}$(int index) const { " + "__builtin_trap(); }\n" + "$deprecated_attr$$type$* ${1$add_$name$$}$() { " + "__builtin_trap(); }\n" + "$deprecated_attr$const ::$proto_ns$::RepeatedPtrField< $type$ >&\n" + " ${1$$name$$}$() const { __builtin_trap(); }\n", + descriptor_); + return; + } format( "$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index);\n" "$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n" - " ${1$mutable_$name$$}$();\n" - "private:\n" - "const $type$& ${1$_internal_$name$$}$(int index) const;\n" - "$type$* ${1$_internal_add_$name$$}$();\n" - "public:\n" + " ${1$mutable_$name$$}$();\n", + descriptor_); + if (IsFieldUsed(descriptor_, options_)) { + format( + "private:\n" + "const $type$& ${1$_internal_$name$$}$(int index) const;\n" + "$type$* ${1$_internal_add_$name$$}$();\n" + "public:\n", + descriptor_); + } + format( "$deprecated_attr$const $type$& ${1$$name$$}$(int index) const;\n" "$deprecated_attr$$type$* ${1$add_$name$$}$();\n" "$deprecated_attr$const ::$proto_ns$::RepeatedPtrField< $type$ >&\n" @@ -722,18 +791,24 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( void RepeatedMessageFieldGenerator::GenerateClearingCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format("$name$_.Clear();\n"); } void RepeatedMessageFieldGenerator::GenerateMergingCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format("$name$_.MergeFrom(from.$name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format("$name$_.InternalSwap(&other->$name$_);\n"); } @@ -745,6 +820,8 @@ void RepeatedMessageFieldGenerator::GenerateConstructorCode( void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); if (implicit_weak_field_) { format( @@ -770,6 +847,8 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( void RepeatedMessageFieldGenerator::GenerateByteSize( io::Printer* printer) const { + GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); + Formatter format(printer, variables_); format( "total_size += $tag_size$UL * this->_internal_$name$_size();\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_options.h b/src/google/protobuf/compiler/cpp/cpp_options.h index d8fe3a7aefd2..92b55484676c 100644 --- a/src/google/protobuf/compiler/cpp/cpp_options.h +++ b/src/google/protobuf/compiler/cpp/cpp_options.h @@ -44,7 +44,8 @@ namespace cpp { enum class EnforceOptimizeMode { kNoEnforcement, // Use the runtime specified by the file specific options. - kSpeed, // This is the full runtime. + kSpeed, // Full runtime with a generated code implementation. + kCodeSize, // Full runtime with a reflective implementation. kLiteRuntime, }; @@ -62,6 +63,7 @@ struct Options { bool bootstrap = false; bool opensource_runtime = false; bool annotate_accessor = false; + bool unused_field_stripping = false; std::string runtime_include_base; int num_cc_files = 0; std::string annotation_pragma_name; diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 847f76c2176c..6560cef86cc3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -237,13 +237,13 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "inline void $classname$::_internal_set_$name$(const std::string& " "value) {\n" " $set_hasbit$\n" - " $name$_.Set$lite$($default_variable$, value, GetArenaNoVirtual());\n" + " $name$_.Set$lite$($default_variable$, value, GetArena());\n" "}\n" "inline void $classname$::set_$name$(std::string&& value) {\n" "$annotate_accessor$" " $set_hasbit$\n" " $name$_.Set$lite$(\n" - " $default_variable$, ::std::move(value), GetArenaNoVirtual());\n" + " $default_variable$, ::std::move(value), GetArena());\n" " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(const char* value) {\n" @@ -251,7 +251,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " $null_check$" " $set_hasbit$\n" " $name$_.Set$lite$($default_variable$, $string_piece$(value),\n" - " GetArenaNoVirtual());\n" + " GetArena());\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n"); if (!options_.opensource_runtime) { @@ -259,8 +259,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "inline void $classname$::set_$name$(::StringPiece value) {\n" "$annotate_accessor$" " $set_hasbit$\n" - " $name$_.Set$lite$($default_variable$, value, " - "GetArenaNoVirtual());\n" + " $name$_.Set$lite$($default_variable$, value,GetArena());\n" " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" "}\n"); } @@ -271,13 +270,12 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_accessor$" " $set_hasbit$\n" " $name$_.Set$lite$($default_variable$, $string_piece$(\n" - " reinterpret_cast(value), size), " - "GetArenaNoVirtual());\n" + " reinterpret_cast(value), size), GetArena());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n" " $set_hasbit$\n" - " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n" + " return $name$_.Mutable($default_variable$, GetArena());\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" "$annotate_accessor$" @@ -290,12 +288,11 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " }\n" " $clear_hasbit$\n" " return $name$_.ReleaseNonDefault(" - "$default_variable$, GetArenaNoVirtual());\n"); + "$default_variable$, GetArena());\n"); } else { format( " $clear_hasbit$\n" - " return $name$_.Release($default_variable$, " - "GetArenaNoVirtual());\n"); + " return $name$_.Release($default_variable$, GetArena());\n"); } format( @@ -308,7 +305,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " $clear_hasbit$\n" " }\n" " $name$_.SetAllocated($default_variable$, $name$,\n" - " GetArenaNoVirtual());\n" + " GetArena());\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n"); if (options_.opensource_runtime) { @@ -317,22 +314,22 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_accessor$" " // " "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" - " $DCHK$(GetArenaNoVirtual() != nullptr);\n" + " $DCHK$(GetArena() != nullptr);\n" " $clear_hasbit$\n" " return $name$_.UnsafeArenaRelease($default_variable$,\n" - " GetArenaNoVirtual());\n" + " GetArena());\n" "}\n" "inline void $classname$::unsafe_arena_set_allocated_$name$(\n" "$annotate_accessor$" " std::string* $name$) {\n" - " $DCHK$(GetArenaNoVirtual() != nullptr);\n" + " $DCHK$(GetArena() != nullptr);\n" " if ($name$ != nullptr) {\n" " $set_hasbit$\n" " } else {\n" " $clear_hasbit$\n" " }\n" " $name$_.UnsafeArenaSetAllocated($default_variable$,\n" - " $name$, GetArenaNoVirtual());\n" + " $name$, GetArena());\n" " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" "$full_name$)\n" "}\n"); @@ -436,11 +433,9 @@ void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const { // below methods are inlined one-liners)! if (SupportsArenas(descriptor_)) { if (descriptor_->default_value_string().empty()) { - format( - "$name$_.ClearToEmpty($default_variable$, GetArenaNoVirtual());\n"); + format("$name$_.ClearToEmpty($default_variable$, GetArena());\n"); } else { - format( - "$name$_.ClearToDefault($default_variable$, GetArenaNoVirtual());\n"); + format("$name$_.ClearToDefault($default_variable$, GetArena());\n"); } } else { if (descriptor_->default_value_string().empty()) { @@ -481,14 +476,12 @@ void StringFieldGenerator::GenerateMessageClearingCode( if (must_be_present) { format("$name$_.ClearNonDefaultToEmpty();\n"); } else { - format( - "$name$_.ClearToEmpty($default_variable$, GetArenaNoVirtual());\n"); + format("$name$_.ClearToEmpty($default_variable$, GetArena());\n"); } } else { // Clear to a non-empty default is more involved, as we try to use the // Arena if one is present and may need to reallocate the string. - format( - "$name$_.ClearToDefault($default_variable$, GetArenaNoVirtual());\n"); + format("$name$_.ClearToDefault($default_variable$, GetArena());\n"); } } else if (must_be_present) { // When Arenas are disabled and field presence has been checked, we can @@ -524,9 +517,7 @@ void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { if (inlined_) { format("$name$_.Swap(&other->$name$_);\n"); } else { - format( - "$name$_.Swap(&other->$name$_, $default_variable$,\n" - " GetArenaNoVirtual());\n"); + format("$name$_.Swap(&other->$name$_, $default_variable$, GetArena());\n"); } } @@ -559,7 +550,7 @@ void StringFieldGenerator::GenerateCopyConstructorCode( // TODO(gpike): improve this format( "$name$_.Set$lite$($default_variable$, from._internal_$name$(),\n" - " GetArenaNoVirtual());\n"); + " GetArena());\n"); } else { format("$name$_.AssignWithDefault($default_variable$, from.$name$_);\n"); } @@ -682,8 +673,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $field_member$.Set$lite$($default_variable$, value,\n" - " GetArenaNoVirtual());\n" + " $field_member$.Set$lite$($default_variable$, value, GetArena());\n" "}\n" "inline void $classname$::set_$name$(std::string&& value) {\n" "$annotate_accessor$" @@ -694,7 +684,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " $field_member$.Set$lite$(\n" - " $default_variable$, ::std::move(value), GetArenaNoVirtual());\n" + " $default_variable$, ::std::move(value), GetArena());\n" " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(const char* value) {\n" @@ -706,7 +696,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " $field_member$.Set$lite$($default_variable$,\n" - " $string_piece$(value), GetArenaNoVirtual());\n" + " $string_piece$(value), GetArena());\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n"); if (!options_.opensource_runtime) { @@ -719,7 +709,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " $field_member$.Set$lite$($default_variable$, value,\n" - " GetArenaNoVirtual());\n" + " GetArena());\n" " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" "}\n"); } @@ -736,7 +726,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $field_member$.Set$lite$(\n" " $default_variable$, $string_piece$(\n" " reinterpret_cast(value), size),\n" - " GetArenaNoVirtual());\n" + " GetArena());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n" @@ -745,16 +735,14 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " return $field_member$.Mutable($default_variable$,\n" - " GetArenaNoVirtual());\n" + " return $field_member$.Mutable($default_variable$, GetArena());\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" "$annotate_accessor$" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " return $field_member$.Release($default_variable$,\n" - " GetArenaNoVirtual());\n" + " return $field_member$.Release($default_variable$, GetArena());\n" " } else {\n" " return nullptr;\n" " }\n" @@ -776,11 +764,11 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_accessor$" " // " "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" - " $DCHK$(GetArenaNoVirtual() != nullptr);\n" + " $DCHK$(GetArena() != nullptr);\n" " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" " return $field_member$.UnsafeArenaRelease(\n" - " $default_variable$, GetArenaNoVirtual());\n" + " $default_variable$, GetArena());\n" " } else {\n" " return nullptr;\n" " }\n" @@ -788,7 +776,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( "inline void $classname$::unsafe_arena_set_allocated_$name$(" "std::string* $name$) {\n" "$annotate_accessor$" - " $DCHK$(GetArenaNoVirtual() != nullptr);\n" + " $DCHK$(GetArena() != nullptr);\n" " if (!_internal_has_$name$()) {\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" @@ -796,7 +784,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if ($name$) {\n" " set_has_$name$();\n" " $field_member$.UnsafeArenaSetAllocated($default_variable$, " - "$name$, GetArenaNoVirtual());\n" + "$name$, GetArena());\n" " }\n" " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" "$full_name$)\n" @@ -906,9 +894,7 @@ void StringOneofFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); if (SupportsArenas(descriptor_)) { - format( - "$field_member$.Destroy($default_variable$,\n" - " GetArenaNoVirtual());\n"); + format("$field_member$.Destroy($default_variable$, GetArena());\n"); } else { format("$field_member$.DestroyNoArena($default_variable$);\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.inc b/src/google/protobuf/compiler/cpp/cpp_unittest.inc index 2efbd6d384ab..0bf754cfd356 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.inc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.inc @@ -100,8 +100,8 @@ class MockErrorCollector : public MultiFileErrorCollector { // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, int line, int column, const std::string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", - filename, line, column, message); + strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, column, + message); } }; diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 400d5d07e849..3b42d95ecf5e 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -231,8 +231,9 @@ const FileDescriptor* Importer::Import(const std::string& filename) { return pool_.FindFileByName(filename); } -void Importer::AddUnusedImportTrackFile(const std::string& file_name) { - pool_.AddUnusedImportTrackFile(file_name); +void Importer::AddUnusedImportTrackFile(const std::string& file_name, + bool is_error) { + pool_.AddUnusedImportTrackFile(file_name, is_error); } void Importer::ClearUnusedImportTrackFiles() { diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h index fc4b47854536..db4a876c5bb6 100644 --- a/src/google/protobuf/compiler/importer.h +++ b/src/google/protobuf/compiler/importer.h @@ -178,7 +178,8 @@ class PROTOBUF_EXPORT Importer { // contents are stored. inline const DescriptorPool* pool() const { return &pool_; } - void AddUnusedImportTrackFile(const std::string& file_name); + void AddUnusedImportTrackFile(const std::string& file_name, + bool is_error = false); void ClearUnusedImportTrackFiles(); diff --git a/src/google/protobuf/compiler/importer_unittest.cc b/src/google/protobuf/compiler/importer_unittest.cc index 111d66f8b207..dc5c6929ccb8 100644 --- a/src/google/protobuf/compiler/importer_unittest.cc +++ b/src/google/protobuf/compiler/importer_unittest.cc @@ -74,14 +74,14 @@ class MockErrorCollector : public MultiFileErrorCollector { // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, int line, int column, const std::string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, - column, message); + strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, column, + message); } void AddWarning(const std::string& filename, int line, int column, const std::string& message) { - strings::SubstituteAndAppend(&warning_text_, "$0:$1:$2: $3\n", filename, - line, column, message); + strings::SubstituteAndAppend(&warning_text_, "$0:$1:$2: $3\n", filename, line, + column, message); } }; diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc index 9415eb5d21bc..5454861f61d1 100644 --- a/src/google/protobuf/compiler/java/java_enum.cc +++ b/src/google/protobuf/compiler/java/java_enum.cc @@ -228,7 +228,25 @@ void EnumGenerator::Generate(io::Printer* printer) { if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) { printer->Print( "public final com.google.protobuf.Descriptors.EnumValueDescriptor\n" - " getValueDescriptor() {\n" + " getValueDescriptor() {\n"); + if (SupportUnknownEnumValue(descriptor_->file())) { + if (ordinal_is_index) { + printer->Print( + " if (this == UNRECOGNIZED) {\n" + " throw new java.lang.IllegalStateException(\n" + " \"Can't get the descriptor of an unrecognized enum " + "value.\");\n" + " }\n"); + } else { + printer->Print( + " if (index == -1) {\n" + " throw new java.lang.IllegalStateException(\n" + " \"Can't get the descriptor of an unrecognized enum " + "value.\");\n" + " }\n"); + } + } + printer->Print( " return getDescriptor().getValues().get($index_text$);\n" "}\n" "public final com.google.protobuf.Descriptors.EnumDescriptor\n" @@ -279,15 +297,22 @@ void EnumGenerator::Generate(io::Printer* printer) { // for every enum. printer->Print("values();\n"); } else { + printer->Print("getStaticValuesArray();\n"); + printer->Print("private static $classname$[] getStaticValuesArray() {\n", + "classname", descriptor_->name()); + printer->Indent(); printer->Print( - "{\n" - " "); + "return new $classname$[] {\n" + " ", + "classname", descriptor_->name()); for (int i = 0; i < descriptor_->value_count(); i++) { printer->Print("$name$, ", "name", descriptor_->value(i)->name()); } printer->Print( "\n" "};\n"); + printer->Outdent(); + printer->Print("}"); } printer->Print( diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc index 83acc49089b2..6322ee566ee8 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/src/google/protobuf/compiler/java/java_enum_field.cc @@ -81,7 +81,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, // with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations. (*variables)["for_number"] = "valueOf"; - if (SupportFieldPresence(descriptor->file())) { + if (SupportFieldPresence(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); @@ -145,7 +145,7 @@ ImmutableEnumFieldGenerator::ImmutableEnumFieldGenerator( ImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {} int ImmutableEnumFieldGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return SupportFieldPresence(descriptor_) ? 1 : 0; } int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const { @@ -154,7 +154,7 @@ int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const { void ImmutableEnumFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -171,27 +171,28 @@ void ImmutableEnumFieldGenerator::GenerateInterfaceMembers( void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { printer->Print(variables_, "private int $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $get_has_field_bit_message$;\n" - "}\n"); + printer->Print(variables_, + "@java.lang.Override $deprecation$public boolean " + "${$has$capitalized_name$$}$() {\n" + " return $get_has_field_bit_message$;\n" + "}\n"); printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); - printer->Print( - variables_, - "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" - " return $name$_;\n" - "}\n"); + printer->Print(variables_, + "@java.lang.Override $deprecation$public int " + "${$get$capitalized_name$Value$}$() {\n" + " return $name$_;\n" + "}\n"); printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, - "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" + "@java.lang.Override $deprecation$public $type$ " + "${$get$capitalized_name$$}$() {\n" " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$($name$_);\n" " return result == null ? $unknown$ : result;\n" @@ -202,22 +203,22 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { void ImmutableEnumFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, "private int $name$_ = $default_number$;\n"); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $get_has_field_bit_builder$;\n" - "}\n"); + printer->Print(variables_, + "@java.lang.Override $deprecation$public boolean " + "${$has$capitalized_name$$}$() {\n" + " return $get_has_field_bit_builder$;\n" + "}\n"); printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); - printer->Print( - variables_, - "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" - " return $name$_;\n" - "}\n"); + printer->Print(variables_, + "@java.lang.Override $deprecation$public int " + "${$get$capitalized_name$Value$}$() {\n" + " return $name$_;\n" + "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -232,6 +233,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$($name$_);\n" @@ -284,7 +286,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderClearCode( void ImmutableEnumFieldGenerator::GenerateMergingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { printer->Print(variables_, "if (other.has$capitalized_name$()) {\n" " set$capitalized_name$(other.get$capitalized_name$());\n" @@ -302,7 +304,7 @@ void ImmutableEnumFieldGenerator::GenerateMergingCode( void ImmutableEnumFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n" " $set_has_field_bit_to_local$;\n" @@ -386,7 +388,7 @@ ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {} void ImmutableEnumOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -423,10 +425,11 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers( void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); @@ -436,6 +439,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ((java.lang.Integer) $oneof_name$_).intValue();\n" @@ -457,6 +461,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " @SuppressWarnings(\"deprecation\")\n" @@ -650,6 +655,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public java.util.List<$type$> " "${$get$capitalized_name$List$}$() {\n" " return new com.google.protobuf.Internal.ListAdapter<\n" @@ -659,6 +665,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); @@ -666,6 +673,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.get(index));\n" "}\n"); @@ -673,6 +681,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public java.util.List\n" "${$get$capitalized_name$ValueList$}$() {\n" " return $name$_;\n" @@ -681,6 +690,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public int " "${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.get(index);\n" diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc index 5c137ca50c36..7966931cfabe 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -83,7 +83,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; (*variables)["required"] = descriptor->is_required() ? "true" : "false"; - if (SupportFieldPresence(descriptor->file())) { + if (SupportFieldPresence(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); @@ -140,12 +140,12 @@ ImmutableEnumFieldLiteGenerator::ImmutableEnumFieldLiteGenerator( ImmutableEnumFieldLiteGenerator::~ImmutableEnumFieldLiteGenerator() {} int ImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return SupportFieldPresence(descriptor_) ? 1 : 0; } void ImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -163,7 +163,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { printer->Print(variables_, "private int $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -217,7 +217,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -288,11 +288,11 @@ void ImmutableEnumFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(descriptor_->number(), output); WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_), output); - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { WriteIntToUtf16CharSequence(messageBitIndex_, output); } printer->Print(variables_, "\"$name$_\",\n"); - if (SupportFieldPresence(descriptor_->file())) { + if (!SupportUnknownEnumValue((descriptor_))) { PrintEnumVerifierLogic(printer, descriptor_, variables_, /*var_name=*/"$type$", /*terminating_string=*/",\n", @@ -319,7 +319,7 @@ ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {} void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -386,7 +386,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_), output); WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output); - if (SupportFieldPresence(descriptor_->file())) { + if (!SupportUnknownEnumValue(descriptor_)) { PrintEnumVerifierLogic(printer, descriptor_, variables_, /*var_name=*/"$type$", /*terminating_string=*/",\n", @@ -396,7 +396,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -640,7 +640,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_), output); printer->Print(variables_, "\"$name$_\",\n"); - if (SupportFieldPresence(descriptor_->file())) { + if (!SupportUnknownEnumValue(descriptor_->file())) { PrintEnumVerifierLogic(printer, descriptor_, variables_, /*var_name=*/"$type$", /*terminating_string=*/",\n", diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc index 96ed23401ab1..f6b9635df9ad 100644 --- a/src/google/protobuf/compiler/java/java_field.cc +++ b/src/google/protobuf/compiler/java/java_field.cc @@ -87,7 +87,7 @@ ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field, field, messageBitIndex, builderBitIndex, context); } } else { - if (field->containing_oneof()) { + if (IsRealOneof(field)) { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: return new ImmutableMessageOneofFieldGenerator( @@ -144,7 +144,7 @@ ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator( field, messageBitIndex, context); } } else { - if (field->containing_oneof()) { + if (IsRealOneof(field)) { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: return new ImmutableMessageOneofFieldLiteGenerator( diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 4a96a365d46c..bc4bbe8f6f4d 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -76,6 +76,7 @@ struct FieldDescriptorCompare { typedef std::set FieldDescriptorSet; + // Recursively searches the given message to collect extensions. // Returns true if all the extensions can be recognized. The extensions will be // appended in to the extensions parameter. @@ -85,7 +86,9 @@ bool CollectExtensions(const Message& message, FieldDescriptorSet* extensions) { const Reflection* reflection = message.GetReflection(); // There are unknown fields that could be extensions, thus this call fails. - if (reflection->GetUnknownFields(message).field_count() > 0) return false; + UnknownFieldSet unknown_fields; + unknown_fields.MergeFrom(reflection->GetUnknownFields(message)); + if (unknown_fields.field_count() > 0) return false; std::vector fields; reflection->ListFields(message, &fields); diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc index 5045cfdc66d8..11b04b8d9aca 100644 --- a/src/google/protobuf/compiler/java/java_generator.cc +++ b/src/google/protobuf/compiler/java/java_generator.cc @@ -58,6 +58,10 @@ namespace java { JavaGenerator::JavaGenerator() {} JavaGenerator::~JavaGenerator() {} +uint64 JavaGenerator::GetSupportedFeatures() const { + return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL; +} + bool JavaGenerator::Generate(const FileDescriptor* file, const std::string& parameter, GeneratorContext* context, diff --git a/src/google/protobuf/compiler/java/java_generator.h b/src/google/protobuf/compiler/java/java_generator.h index be63ac49e2bf..a4e1708371af 100644 --- a/src/google/protobuf/compiler/java/java_generator.h +++ b/src/google/protobuf/compiler/java/java_generator.h @@ -58,7 +58,9 @@ class PROTOC_EXPORT JavaGenerator : public CodeGenerator { // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const; + GeneratorContext* context, std::string* error) const override; + + uint64 GetSupportedFeatures() const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator); diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index 41cd52402e23..a04ff6202011 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -963,6 +963,7 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) { static const int kUtf8CheckBit = 0x200; static const int kCheckInitialized = 0x400; static const int kMapWithProto2EnumValue = 0x800; + static const int kHasHasBit = 0x1000; int extra_bits = field->is_required() ? kRequiredBit : 0; if (field->type() == FieldDescriptor::TYPE_STRING && CheckUtf8(field)) { extra_bits |= kUtf8CheckBit; @@ -971,9 +972,12 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) { HasRequiredFields(field->message_type()))) { extra_bits |= kCheckInitialized; } + if (HasHasbit(field)) { + extra_bits |= kHasHasBit; + } if (field->is_map()) { - if (SupportFieldPresence(field->file())) { + if (!SupportUnknownEnumValue(field)) { const FieldDescriptor* value = field->message_type()->FindFieldByName("value"); if (GetJavaType(value) == JAVATYPE_ENUM) { @@ -985,7 +989,7 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) { return GetExperimentalJavaFieldTypeForPacked(field); } else if (field->is_repeated()) { return GetExperimentalJavaFieldTypeForRepeated(field) | extra_bits; - } else if (field->containing_oneof() != NULL) { + } else if (IsRealOneof(field)) { return (GetExperimentalJavaFieldTypeForSingular(field) + kOneofFieldTypeOffset) | extra_bits; diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h index 8655cae8e0b0..e44ad153047d 100644 --- a/src/google/protobuf/compiler/java/java_helpers.h +++ b/src/google/protobuf/compiler/java/java_helpers.h @@ -188,9 +188,11 @@ template void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer, Descriptor* descriptor, bool immutable, const std::string& suffix = "") { - if (context->options().annotate_code && IsOwnFile(descriptor, immutable)) { + if (IsOwnFile(descriptor, immutable)) { PrintGeneratedAnnotation(printer, '$', - AnnotationFileName(descriptor, suffix)); + context->options().annotate_code + ? AnnotationFileName(descriptor, suffix) + : ""); } } @@ -352,9 +354,30 @@ inline bool HasPackedFields(const Descriptor* descriptor) { // them has a required field. Return true if a required field is found. bool HasRequiredFields(const Descriptor* descriptor); -// Whether a .proto file supports field presence test for non-message types. -inline bool SupportFieldPresence(const FileDescriptor* descriptor) { - return descriptor->syntax() != FileDescriptor::SYNTAX_PROTO3; +inline bool IsProto2(const FileDescriptor* descriptor) { + return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2; +} + +inline bool SupportFieldPresence(const FieldDescriptor* descriptor) { + // Note that while proto3 oneofs do conceptually support present, we return + // false for them because they do not offer a public hazzer. Therefore this + // method could be named HasHazzer(). + return !descriptor->is_repeated() && + (descriptor->message_type() || descriptor->has_optional_keyword() || + IsProto2(descriptor->file())); +} + +inline bool IsRealOneof(const FieldDescriptor* descriptor) { + return descriptor->containing_oneof() && + !descriptor->containing_oneof()->is_synthetic(); +} + +inline bool HasHasbit(const FieldDescriptor* descriptor) { + // Note that currently message fields inside oneofs have hasbits. This is + // surprising, as the oneof case should avoid any need for a hasbit. But if + // you change this method to remove hasbits for oneofs, a few tests fail. + return !descriptor->is_repeated() && + (descriptor->has_optional_keyword() || IsProto2(descriptor->file())); } // Whether generate classes expose public PARSER instances. @@ -370,6 +393,10 @@ inline bool SupportUnknownEnumValue(const FileDescriptor* descriptor) { return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3; } +inline bool SupportUnknownEnumValue(const FieldDescriptor* field) { + return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3; +} + // Check whether a message has repeated fields. bool HasRepeatedFields(const Descriptor* descriptor); diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc index 53537458799c..5db199d38fa4 100644 --- a/src/google/protobuf/compiler/java/java_map_field.cc +++ b/src/google/protobuf/compiler/java/java_map_field.cc @@ -483,6 +483,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( printer->Print( variables_, "$deprecation$\n" + "@java.lang.Override\n" "public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" @@ -494,6 +495,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "/**\n" " * Use {@link #get$capitalized_name$Map()} instead.\n" " */\n" + "@java.lang.Override\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" "${$get$capitalized_name$$}$() {\n" @@ -502,6 +504,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" "${$get$capitalized_name$Map$}$() {\n" @@ -512,6 +515,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$\n" "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" @@ -527,6 +531,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$\n" "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" @@ -545,6 +550,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "/**\n" " * Use {@link #get$capitalized_name$ValueMap()} instead.\n" " */\n" + "@java.lang.Override\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" "${$get$capitalized_name$Value$}$() {\n" @@ -554,6 +560,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" "${$get$capitalized_name$ValueMap$}$() {\n" @@ -563,6 +570,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$\n" "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" @@ -576,6 +584,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$\n" "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" @@ -594,6 +603,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "/**\n" " * Use {@link #get$capitalized_name$Map()} instead.\n" " */\n" + "@java.lang.Override\n" "@java.lang.Deprecated\n" "public java.util.Map<$type_parameters$> " "${$get$capitalized_name$$}$() {\n" @@ -602,6 +612,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$type_parameters$> " "${$get$capitalized_name$Map$}$() {\n" @@ -611,6 +622,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$\n" "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" @@ -623,6 +635,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$\n" "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc index 8236f3a45c80..4fa939f3b8bf 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -508,7 +508,7 @@ void ImmutableMapFieldLiteGenerator::GenerateFieldInfo( printer->Print(variables_, "\"$name$_\",\n" "$default_entry$,\n"); - if (SupportFieldPresence(descriptor_->file()) && + if (!SupportUnknownEnumValue(descriptor_) && GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { PrintEnumVerifierLogic(printer, ValueField(descriptor_), variables_, /*var_name=*/"$value_enum_type$", diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index dbf62e58ff3d..0192e4bc67bf 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -75,7 +75,13 @@ std::string MapValueImmutableClassdName(const Descriptor* descriptor, // =================================================================== MessageGenerator::MessageGenerator(const Descriptor* descriptor) - : descriptor_(descriptor) {} + : descriptor_(descriptor) { + for (int i = 0; i < descriptor_->field_count(); i++) { + if (IsRealOneof(descriptor_->field(i))) { + oneofs_.insert(descriptor_->field(i)->containing_oneof()); + } + } +} MessageGenerator::~MessageGenerator() {} @@ -206,7 +212,7 @@ void ImmutableMessageGenerator::GenerateFieldAccessorTable( // 6 bytes per field and oneof *bytecode_estimate += - 10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count(); + 10 + 6 * descriptor_->field_count() + 6 * oneofs_.size(); } int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer( @@ -225,6 +231,7 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer( bytecode_estimate += 6; printer->Print("\"$field_name$\", ", "field_name", info->capitalized_name); } + // We reproduce synthetic oneofs here since proto reflection needs these. for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { const OneofDescriptor* oneof = descriptor_->oneof_decl(i); const OneofGeneratorInfo* info = context_->GetOneofGeneratorInfo(oneof); @@ -269,15 +276,13 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { field_generators_.get(descriptor_->field(i)) .GenerateInterfaceMembers(printer); } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + for (auto oneof : oneofs_) { printer->Print( "\n" "public $classname$.$oneof_capitalized_name$Case " "get$oneof_capitalized_name$Case();\n", "oneof_capitalized_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name, - "classname", + context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname", context_->GetNameResolver()->GetImmutableClassName(descriptor_)); } printer->Outdent(); @@ -291,7 +296,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true); std::map variables; - variables["static"] = is_own_file ? " " : " static "; + variables["static"] = is_own_file ? "" : "static "; variables["classname"] = descriptor_->name(); variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_); variables["ver"] = GeneratedCodeVersionSuffix(); @@ -330,7 +335,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { " $classname$OrBuilder {\n"); builder_type = strings::Substitute("com.google.protobuf.GeneratedMessage$0.Builder", - GeneratedCodeVersionSuffix()); + GeneratedCodeVersionSuffix()); } printer->Print("private static final long serialVersionUID = 0L;\n"); @@ -403,13 +408,11 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { // oneof std::map vars; - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - vars["oneof_name"] = - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name; + for (auto oneof : oneofs_) { + vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name; - vars["oneof_index"] = StrCat(descriptor_->oneof_decl(i)->index()); + context_->GetOneofGeneratorInfo(oneof)->capitalized_name; + vars["oneof_index"] = StrCat((oneof)->index()); // oneofCase_ and oneof_ printer->Print(vars, "private int $oneof_name$Case_ = 0;\n" @@ -423,8 +426,8 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { " implements com.google.protobuf.Internal.EnumLite,\n" " com.google.protobuf.AbstractMessage.InternalOneOfEnum {\n"); printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < (oneof)->field_count(); j++) { + const FieldDescriptor* field = (oneof)->field(j); printer->Print( "$deprecation$$field_name$($field_number$),\n", "deprecation", field->options().deprecated() ? "@java.lang.Deprecated " : "", @@ -452,8 +455,8 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { "\n" "public static $oneof_capitalized_name$Case forNumber(int value) {\n" " switch (value) {\n"); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < (oneof)->field_count(); j++) { + const FieldDescriptor* field = (oneof)->field(j); printer->Print(" case $field_number$: return $field_name$;\n", "field_number", StrCat(field->number()), "field_name", ToUpper(field->name())); @@ -912,19 +915,8 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) { "name", info->capitalized_name); break; case FieldDescriptor::LABEL_OPTIONAL: - if (!SupportFieldPresence(descriptor_->file()) && - field->containing_oneof() != NULL) { - const OneofDescriptor* oneof = field->containing_oneof(); - const OneofGeneratorInfo* oneof_info = - context_->GetOneofGeneratorInfo(oneof); - printer->Print("if ($oneof_name$Case_ == $field_number$) {\n", - "oneof_name", oneof_info->name, "field_number", - StrCat(field->number())); - } else { - printer->Print("if (has$name$()) {\n", "name", - info->capitalized_name); - } printer->Print( + "if (has$name$()) {\n" " if (!get$name$().isInitialized()) {\n" " memoizedIsInitialized = 0;\n" " return false;\n" @@ -987,11 +979,10 @@ bool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) { if (field->is_repeated()) { return false; } - if (SupportFieldPresence(field->file())) { + if (HasHasbit(field)) { return true; } - return GetJavaType(field) == JAVATYPE_MESSAGE && - field->containing_oneof() == NULL; + return GetJavaType(field) == JAVATYPE_MESSAGE && !IsRealOneof(field); } } // namespace @@ -1015,7 +1006,7 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); - if (field->containing_oneof() == NULL) { + if (!IsRealOneof(field)) { const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field); bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field); if (check_has_bits) { @@ -1034,19 +1025,17 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( } // Compare oneofs. - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + for (auto oneof : oneofs_) { printer->Print( "if (!get$oneof_capitalized_name$Case().equals(" "other.get$oneof_capitalized_name$Case())) return false;\n", "oneof_capitalized_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name); - printer->Print( - "switch ($oneof_name$Case_) {\n", "oneof_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name); + context_->GetOneofGeneratorInfo(oneof)->capitalized_name); + printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name", + context_->GetOneofGeneratorInfo(oneof)->name); printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < (oneof)->field_count(); j++) { + const FieldDescriptor* field = (oneof)->field(j); printer->Print("case $field_number$:\n", "field_number", StrCat(field->number())); printer->Indent(); @@ -1099,7 +1088,7 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( // hashCode non-oneofs. for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); - if (field->containing_oneof() == NULL) { + if (!IsRealOneof(field)) { const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field); bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field); if (check_has_bits) { @@ -1115,13 +1104,12 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( } // hashCode oneofs. - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - printer->Print( - "switch ($oneof_name$Case_) {\n", "oneof_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name); + for (auto oneof : oneofs_) { + printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name", + context_->GetOneofGeneratorInfo(oneof)->name); printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < (oneof)->field_count(); j++) { + const FieldDescriptor* field = (oneof)->field(j); printer->Print("case $field_number$:\n", "field_number", StrCat(field->number())); printer->Indent(); @@ -1360,7 +1348,7 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) { // =================================================================== void ImmutableMessageGenerator::GenerateInitializers(io::Printer* printer) { for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { + if (!IsRealOneof(descriptor_->field(i))) { field_generators_.get(descriptor_->field(i)) .GenerateInitializationCode(printer); } diff --git a/src/google/protobuf/compiler/java/java_message.h b/src/google/protobuf/compiler/java/java_message.h index de2f359a411b..87b9df5e598b 100644 --- a/src/google/protobuf/compiler/java/java_message.h +++ b/src/google/protobuf/compiler/java/java_message.h @@ -88,6 +88,7 @@ class MessageGenerator { protected: const Descriptor* descriptor_; + std::set oneofs_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index 16e63afc6cb5..320852b1be97 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -76,6 +76,11 @@ MessageBuilderGenerator::MessageBuilderGenerator(const Descriptor* descriptor, GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A non-lite message generator is used to " "generate lite messages."; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (IsRealOneof(descriptor_->field(i))) { + oneofs_.insert(descriptor_->field(i)->containing_oneof()); + } + } } MessageBuilderGenerator::~MessageBuilderGenerator() {} @@ -115,13 +120,11 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) { // oneof std::map vars; - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - vars["oneof_name"] = - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name; + for (auto oneof : oneofs_) { + vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name; - vars["oneof_index"] = StrCat(descriptor_->oneof_decl(i)->index()); + context_->GetOneofGeneratorInfo(oneof)->capitalized_name; + vars["oneof_index"] = StrCat(oneof->index()); // oneofCase_ and oneof_ printer->Print(vars, "private int $oneof_name$Case_ = 0;\n" @@ -308,7 +311,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( printer->Indent(); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { + if (!IsRealOneof(descriptor_->field(i))) { field_generators_.get(descriptor_->field(i)) .GenerateFieldBuilderInitializationCode(printer); } @@ -328,18 +331,17 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { + if (!IsRealOneof(descriptor_->field(i))) { field_generators_.get(descriptor_->field(i)) .GenerateBuilderClearCode(printer); } } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + for (auto oneof : oneofs_) { printer->Print( "$oneof_name$Case_ = 0;\n" "$oneof_name$_ = null;\n", - "oneof_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name); + "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name); } printer->Outdent(); @@ -423,10 +425,9 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( "bit_field_name", GetBitFieldName(i)); } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - printer->Print( - "result.$oneof_name$Case_ = $oneof_name$Case_;\n", "oneof_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name); + for (auto oneof : oneofs_) { + printer->Print("result.$oneof_name$Case_ = $oneof_name$Case_;\n", + "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name); } printer->Outdent(); @@ -535,21 +536,20 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { + if (!IsRealOneof(descriptor_->field(i))) { field_generators_.get(descriptor_->field(i)) .GenerateMergingCode(printer); } } // Merge oneof fields. - for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { + for (auto oneof : oneofs_) { printer->Print("switch (other.get$oneof_capitalized_name$Case()) {\n", "oneof_capitalized_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name); + context_->GetOneofGeneratorInfo(oneof)->capitalized_name); printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); printer->Print("case $field_name$: {\n", "field_name", ToUpper(field->name())); printer->Indent(); @@ -563,9 +563,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( " break;\n" "}\n", "cap_oneof_name", - ToUpper( - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->name)); + ToUpper(context_->GetOneofGeneratorInfo(oneof)->name)); printer->Outdent(); printer->Print("}\n"); } @@ -655,19 +653,8 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) { "name", info->capitalized_name); break; case FieldDescriptor::LABEL_OPTIONAL: - if (!SupportFieldPresence(descriptor_->file()) && - field->containing_oneof() != NULL) { - const OneofDescriptor* oneof = field->containing_oneof(); - const OneofGeneratorInfo* oneof_info = - context_->GetOneofGeneratorInfo(oneof); - printer->Print("if ($oneof_name$Case_ == $field_number$) {\n", - "oneof_name", oneof_info->name, "field_number", - StrCat(field->number())); - } else { - printer->Print("if (has$name$()) {\n", "name", - info->capitalized_name); - } printer->Print( + "if (has$name$()) {\n" " if (!get$name$().isInitialized()) {\n" " return false;\n" " }\n" diff --git a/src/google/protobuf/compiler/java/java_message_builder.h b/src/google/protobuf/compiler/java/java_message_builder.h index a31d0badf967..fcd73b343626 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.h +++ b/src/google/protobuf/compiler/java/java_message_builder.h @@ -76,6 +76,7 @@ class MessageBuilderGenerator { Context* context_; ClassNameResolver* name_resolver_; FieldGeneratorMap field_generators_; + std::set oneofs_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderGenerator); }; diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc index 6e78fb737149..7b69a9ab3894 100644 --- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc @@ -67,6 +67,11 @@ MessageBuilderLiteGenerator::MessageBuilderLiteGenerator( GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A lite message generator is used to " "generate non-lite messages."; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (IsRealOneof(descriptor_->field(i))) { + oneofs_.insert(descriptor_->field(i)->containing_oneof()); + } + } } MessageBuilderLiteGenerator::~MessageBuilderLiteGenerator() {} @@ -88,13 +93,11 @@ void MessageBuilderLiteGenerator::Generate(io::Printer* printer) { // oneof std::map vars; - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - vars["oneof_name"] = - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i))->name; + for (auto oneof : oneofs_) { + vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name; - vars["oneof_index"] = StrCat(descriptor_->oneof_decl(i)->index()); + context_->GetOneofGeneratorInfo(oneof)->capitalized_name; + vars["oneof_index"] = StrCat(oneof->index()); // oneofCase() and clearOneof() printer->Print(vars, diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.h b/src/google/protobuf/compiler/java/java_message_builder_lite.h index e0a48dc1f797..3402adf3322b 100644 --- a/src/google/protobuf/compiler/java/java_message_builder_lite.h +++ b/src/google/protobuf/compiler/java/java_message_builder_lite.h @@ -73,6 +73,7 @@ class MessageBuilderLiteGenerator { Context* context_; ClassNameResolver* name_resolver_; FieldGeneratorMap field_generators_; + std::set oneofs_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderLiteGenerator); }; diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc index ad684a0d9acb..67273fa2892c 100644 --- a/src/google/protobuf/compiler/java/java_message_field.cc +++ b/src/google/protobuf/compiler/java/java_message_field.cc @@ -74,7 +74,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, ExposePublicParser(descriptor->message_type()->file()) ? "PARSER" : "parser()"; - if (SupportFieldPresence(descriptor->file())) { + if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); @@ -131,7 +131,7 @@ ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator( ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {} int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return HasHasbit(descriptor_) ? 1 : 0; } int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const { @@ -160,10 +160,11 @@ void ImmutableMessageFieldGenerator::GenerateMembers( printer->Print(variables_, "private $type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); @@ -171,6 +172,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); @@ -179,6 +181,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public $type$OrBuilder " "${$get$capitalized_name$OrBuilder$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" @@ -188,6 +191,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$_ != null;\n" "}\n"); @@ -195,6 +199,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); @@ -202,6 +207,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$OrBuilder " "${$get$capitalized_name$OrBuilder$}$() {\n" " return get$capitalized_name$();\n" @@ -246,7 +252,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( // non-nested builder case. It only creates a nested builder lazily on // demand and then forever delegates to it after creation. - bool support_field_presence = SupportFieldPresence(descriptor_->file()); + bool has_hasbit = HasHasbit(descriptor_); printer->Print(variables_, "private $type$ $name$_;\n"); @@ -262,7 +268,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( // boolean hasField() WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - if (support_field_presence) { + if (has_hasbit) { printer->Print( variables_, "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" @@ -323,7 +329,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( printer, "$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)", - support_field_presence + has_hasbit ? "if ($get_has_field_bit_builder$ &&\n" " $name$_ != null &&\n" " $name$_ != $type$.getDefaultInstance()) {\n" @@ -354,9 +360,9 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( "$name$_ = null;\n" "$on_changed$\n", - support_field_presence ? "$name$Builder_.clear();\n" - : "$name$_ = null;\n" - "$name$Builder_ = null;\n", + has_hasbit ? "$name$Builder_.clear();\n" + : "$name$_ = null;\n" + "$name$Builder_ = null;\n", "$clear_has_field_bit_builder$\n" "return this;\n"); @@ -402,7 +408,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n"); } } @@ -412,7 +418,7 @@ void ImmutableMessageFieldGenerator::GenerateInitializationCode( void ImmutableMessageFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { PrintNestedBuilderCondition(printer, "$name$_ = null;\n", "$name$Builder_.clear();\n"); @@ -435,7 +441,7 @@ void ImmutableMessageFieldGenerator::GenerateMergingCode( void ImmutableMessageFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n"); printer->Indent(); PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n", @@ -537,12 +543,14 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers( PrintExtraFieldInfo(variables_, printer); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($type$) $oneof_name$_;\n" @@ -553,6 +561,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$OrBuilder " "${$get$capitalized_name$OrBuilder$}$() {\n" " if ($has_oneof_case_message$) {\n" @@ -581,6 +590,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( // boolean hasField() WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); @@ -589,7 +599,9 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( // Field getField() WriteFieldAccessorDocComment(printer, descriptor_, GETTER); PrintNestedBuilderFunction( - printer, "$deprecation$public $type$ ${$get$capitalized_name$$}$()", + printer, + "@java.lang.Override\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$()", "if ($has_oneof_case_message$) {\n" " return ($type$) $oneof_name$_;\n" @@ -687,6 +699,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public $type$OrBuilder " "${$get$capitalized_name$OrBuilder$}$() {\n" " if (($has_oneof_case_message$) && ($name$Builder_ != null)) {\n" @@ -846,6 +859,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public java.util.List<$type$> " "${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list @@ -854,6 +868,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public java.util.List \n" " ${$get$capitalized_name$OrBuilderList$}$() {\n" " return $name$_;\n" @@ -862,6 +877,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); @@ -869,12 +885,14 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$OrBuilder " "${$get$capitalized_name$OrBuilder$}$(\n" " int index) {\n" diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc index cb5f3c0e0989..41d33eefcfda 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -70,7 +70,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; (*variables)["required"] = descriptor->is_required() ? "true" : "false"; - if (SupportFieldPresence(descriptor->file())) { + if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); @@ -119,7 +119,11 @@ ImmutableMessageFieldLiteGenerator::ImmutableMessageFieldLiteGenerator( ImmutableMessageFieldLiteGenerator::~ImmutableMessageFieldLiteGenerator() {} int ImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + // TODO(dweis): We don't need a has bit for messages as they have null + // sentinels and no user should be reflecting on this. We could save some + // bits by setting to 0 and updating the runtimes but this might come at a + // runtime performance cost since we can't memoize has-bit reads. + return HasHasbit(descriptor_) ? 1 : 0; } void ImmutableMessageFieldLiteGenerator::GenerateInterfaceMembers( @@ -136,7 +140,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers( printer->Print(variables_, "private $type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -279,7 +283,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(descriptor_->number(), output); WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_), output); - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { WriteIntToUtf16CharSequence(messageBitIndex_, output); } printer->Print(variables_, "\"$name$_\",\n"); diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index c2233110b504..4afffdc7a979 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -73,6 +73,11 @@ ImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator( GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A lite message generator is used to " "generate non-lite messages."; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (IsRealOneof(descriptor_->field(i))) { + oneofs_.insert(descriptor_->field(i)->containing_oneof()); + } + } } ImmutableMessageLiteGenerator::~ImmutableMessageLiteGenerator() {} @@ -134,15 +139,13 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { field_generators_.get(descriptor_->field(i)) .GenerateInterfaceMembers(printer); } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + for (auto oneof : oneofs_) { printer->Print( "\n" "public $classname$.$oneof_capitalized_name$Case " "get$oneof_capitalized_name$Case();\n", "oneof_capitalized_name", - context_->GetOneofGeneratorInfo(descriptor_->oneof_decl(i)) - ->capitalized_name, - "classname", + context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname", context_->GetNameResolver()->GetImmutableClassName(descriptor_)); } printer->Outdent(); @@ -224,12 +227,11 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { // oneof std::map vars; - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + for (auto oneof : oneofs_) { vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(oneof)->capitalized_name; - vars["oneof_index"] = StrCat(oneof->index()); + vars["oneof_index"] = StrCat((oneof)->index()); // oneofCase_ and oneof_ printer->Print(vars, "private int $oneof_name$Case_ = 0;\n" @@ -237,8 +239,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { // OneofCase enum printer->Print(vars, "public enum $oneof_capitalized_name$Case {\n"); printer->Indent(); - for (int j = 0; j < oneof->field_count(); j++) { - const FieldDescriptor* field = oneof->field(j); + for (int j = 0; j < (oneof)->field_count(); j++) { + const FieldDescriptor* field = (oneof)->field(j); printer->Print("$field_name$($field_number$),\n", "field_name", ToUpper(field->name()), "field_number", StrCat(field->number())); @@ -262,8 +264,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "\n" "public static $oneof_capitalized_name$Case forNumber(int value) {\n" " switch (value) {\n"); - for (int j = 0; j < oneof->field_count(); j++) { - const FieldDescriptor* field = oneof->field(j); + for (int j = 0; j < (oneof)->field_count(); j++) { + const FieldDescriptor* field = (oneof)->field(j); printer->Print(" case $field_number$: return $field_name$;\n", "field_number", StrCat(field->number()), "field_name", ToUpper(field->name())); @@ -472,7 +474,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo( std::vector chars; int flags = 0; - if (SupportFieldPresence(descriptor_->file())) { + if (IsProto2(descriptor_->file())) { flags |= 0x1; } if (descriptor_->options().message_set_wire_format()) { @@ -489,9 +491,8 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo( printer->Indent(); // Record the number of oneofs. - WriteIntToUtf16CharSequence(descriptor_->oneof_decl_count(), &chars); - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + WriteIntToUtf16CharSequence(oneofs_.size(), &chars); + for (auto oneof : oneofs_) { printer->Print( "\"$oneof_name$_\",\n" "\"$oneof_name$Case_\",\n", @@ -715,7 +716,7 @@ void ImmutableMessageLiteGenerator::GenerateParser(io::Printer* printer) { // =================================================================== void ImmutableMessageLiteGenerator::GenerateInitializers(io::Printer* printer) { for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { + if (!IsRealOneof(descriptor_->field(i))) { field_generators_.get(descriptor_->field(i)) .GenerateInitializationCode(printer); } diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc index 186431aba4a4..277c8ca95273 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -133,7 +133,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, } (*variables)["on_changed"] = "onChanged();"; - if (SupportFieldPresence(descriptor->file())) { + if (SupportFieldPresence(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); @@ -195,7 +195,7 @@ ImmutablePrimitiveFieldGenerator::ImmutablePrimitiveFieldGenerator( ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {} int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return SupportFieldPresence(descriptor_) ? 1 : 0; } int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const { @@ -204,7 +204,7 @@ int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const { void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -217,10 +217,11 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers( io::Printer* printer) const { printer->Print(variables_, "private $field_type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); @@ -229,6 +230,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); @@ -239,10 +241,11 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, "private $field_type$ $name$_ $default_init$;\n"); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); @@ -251,6 +254,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); @@ -313,7 +317,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode( void ImmutablePrimitiveFieldGenerator::GenerateMergingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { printer->Print(variables_, "if (other.has$capitalized_name$()) {\n" " set$capitalized_name$(other.get$capitalized_name$());\n" @@ -328,7 +332,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMergingCode( void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { if (IsDefaultValueJavaDefault(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n" @@ -492,10 +496,11 @@ ImmutablePrimitiveOneofFieldGenerator:: void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); @@ -504,6 +509,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($boxed_type$) $oneof_name$_;\n" @@ -515,7 +521,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -663,6 +669,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers( PrintExtraFieldInfo(variables_, printer); WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public java.util.List<$boxed_type$>\n" " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index f038412bda1a..65d0bd0d663c 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -139,7 +139,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["fixed_size"] = StrCat(fixed_size); } - if (SupportFieldPresence(descriptor->file())) { + if (SupportFieldPresence(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); @@ -190,12 +190,12 @@ ImmutablePrimitiveFieldLiteGenerator::ImmutablePrimitiveFieldLiteGenerator( ImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {} int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return SupportFieldPresence(descriptor_) ? 1 : 0; } void ImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -215,7 +215,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( } printer->Print(variables_, "private $field_type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -261,7 +261,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -308,7 +308,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(descriptor_->number(), output); WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_), output); - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { WriteIntToUtf16CharSequence(messageBitIndex_, output); } printer->Print(variables_, "\"$name$_\",\n"); @@ -346,7 +346,7 @@ ImmutablePrimitiveOneofFieldLiteGenerator:: void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -396,7 +396,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc index 0e483268d9dc..8e1595b89dd2 100644 --- a/src/google/protobuf/compiler/java/java_string_field.cc +++ b/src/google/protobuf/compiler/java/java_string_field.cc @@ -90,7 +90,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; (*variables)["on_changed"] = "onChanged();"; - if (SupportFieldPresence(descriptor->file())) { + if (SupportFieldPresence(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); @@ -147,7 +147,7 @@ ImmutableStringFieldGenerator::ImmutableStringFieldGenerator( ImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {} int ImmutableStringFieldGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return SupportFieldPresence(descriptor_) ? 1 : 0; } int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const { @@ -188,7 +188,7 @@ int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const { // UnmodifiableLazyStringList. void ImmutableStringFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -207,10 +207,11 @@ void ImmutableStringFieldGenerator::GenerateMembers( printer->Print(variables_, "private volatile java.lang.Object $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); @@ -220,6 +221,7 @@ void ImmutableStringFieldGenerator::GenerateMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.Object ref = $name$_;\n" " if (ref instanceof java.lang.String) {\n" @@ -243,6 +245,7 @@ void ImmutableStringFieldGenerator::GenerateMembers( "}\n"); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public com.google.protobuf.ByteString\n" " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.Object ref = $name$_;\n" @@ -263,7 +266,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, "private java.lang.Object $name$_ $default_init$;\n"); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -381,7 +384,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderClearCode( void ImmutableStringFieldGenerator::GenerateMergingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { // Allow a slight breach of abstraction here in order to avoid forcing // all string fields to Strings when copying fields from a Message. printer->Print(variables_, @@ -401,7 +404,7 @@ void ImmutableStringFieldGenerator::GenerateMergingCode( void ImmutableStringFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n" " $set_has_field_bit_to_local$;\n" @@ -482,7 +485,7 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -548,10 +551,11 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); @@ -561,6 +565,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, + "@java.lang.Override\n" "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.Object ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" @@ -590,6 +595,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, + "@java.lang.Override\n" "$deprecation$public com.google.protobuf.ByteString\n" " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.Object ref $default_init$;\n" diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc index 90e158186044..25e46d9e3fe8 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -85,7 +85,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; (*variables)["required"] = descriptor->is_required() ? "true" : "false"; - if (SupportFieldPresence(descriptor->file())) { + if (SupportFieldPresence(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); @@ -130,7 +130,7 @@ ImmutableStringFieldLiteGenerator::ImmutableStringFieldLiteGenerator( ImmutableStringFieldLiteGenerator::~ImmutableStringFieldLiteGenerator() {} int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const { - return SupportFieldPresence(descriptor_->file()) ? 1 : 0; + return SupportFieldPresence(descriptor_) ? 1 : 0; } // A note about how strings are handled. In the SPEED and CODE_SIZE runtimes, @@ -160,7 +160,7 @@ int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const { // shouldn't be necessary or used on devices. void ImmutableStringFieldLiteGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -179,7 +179,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( printer->Print(variables_, "private java.lang.String $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -241,7 +241,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -309,7 +309,7 @@ void ImmutableStringFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(descriptor_->number(), output); WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_), output); - if (SupportFieldPresence(descriptor_->file())) { + if (HasHasbit(descriptor_)) { WriteIntToUtf16CharSequence(messageBitIndex_, output); } printer->Print(variables_, "\"$name$_\",\n"); @@ -341,7 +341,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -421,7 +421,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_->file())) { + if (SupportFieldPresence(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index e88b18bea727..8b8290175554 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -87,6 +87,15 @@ MockCodeGenerator::MockCodeGenerator(const std::string& name) : name_(name) {} MockCodeGenerator::~MockCodeGenerator() {} +uint64 MockCodeGenerator::GetSupportedFeatures() const { + uint64 all_features = CodeGenerator::FEATURE_PROTO3_OPTIONAL; + return all_features & ~suppressed_features_; +} + +void MockCodeGenerator::SuppressFeatures(uint64 features) { + suppressed_features_ = features; +} + void MockCodeGenerator::ExpectGenerated( const std::string& name, const std::string& parameter, const std::string& insertions, const std::string& file, @@ -320,7 +329,7 @@ std::string MockCodeGenerator::GetOutputFileContent( const std::string& file, const std::string& parsed_file_list, const std::string& first_message_name) { return strings::Substitute("$0: $1, $2, $3, $4\n", generator_name, parameter, - file, first_message_name, parsed_file_list); + file, first_message_name, parsed_file_list); } } // namespace compiler diff --git a/src/google/protobuf/compiler/mock_code_generator.h b/src/google/protobuf/compiler/mock_code_generator.h index 082ba18d4d0d..e650b02be1fa 100644 --- a/src/google/protobuf/compiler/mock_code_generator.h +++ b/src/google/protobuf/compiler/mock_code_generator.h @@ -110,8 +110,12 @@ class MockCodeGenerator : public CodeGenerator { const std::string& parameter, GeneratorContext* context, std::string* error) const; + uint64 GetSupportedFeatures() const override; + void SuppressFeatures(uint64 features); + private: std::string name_; + uint64 suppressed_features_ = 0; static std::string GetOutputFileContent(const std::string& generator_name, const std::string& parameter, diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 41e2eb699f88..a0f5a2cac469 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -34,22 +34,24 @@ // // Recursive descent FTW. +#include + #include + #include #include - -#include +#include #include #include #include -#include #include #include #include #include #include #include +#include namespace google { namespace protobuf { @@ -765,6 +767,44 @@ bool Parser::ParseMessageDefinition( } } DO(ParseMessageBlock(message, message_location, containing_file)); + + if (syntax_identifier_ == "proto3") { + // Add synthetic one-field oneofs for optional fields, except messages which + // already have presence in proto3. + // + // We have to make sure the oneof names don't conflict with any other + // field or oneof. + std::unordered_set names; + for (const auto& field : message->field()) { + names.insert(field.name()); + } + for (const auto& oneof : message->oneof_decl()) { + names.insert(oneof.name()); + } + + for (auto& field : *message->mutable_field()) { + if (field.proto3_optional() && + field.type() != FieldDescriptorProto::TYPE_MESSAGE) { + std::string oneof_name = field.name(); + + // Prepend 'XXXXX_' until we are no longer conflicting. + // Avoid prepending a double-underscore because such names are + // reserved in C++. + if (oneof_name.empty() || oneof_name[0] != '_') { + oneof_name = '_' + oneof_name; + } + while (names.count(oneof_name) > 0) { + oneof_name = 'X' + oneof_name; + } + + names.insert(oneof_name); + field.set_oneof_index(message->oneof_decl_size()); + OneofDescriptorProto* oneof = message->add_oneof_decl(); + oneof->set_name(oneof_name); + } + } + } + return true; } @@ -907,10 +947,7 @@ bool Parser::ParseMessageField(FieldDescriptorProto* field, field->set_label(label); if (label == FieldDescriptorProto::LABEL_OPTIONAL && syntax_identifier_ == "proto3") { - AddError( - "Explicit 'optional' labels are disallowed in the Proto3 syntax. " - "To define 'optional' fields in Proto3, simply remove the " - "'optional' label, as fields are 'optional' by default."); + field->set_proto3_optional(true); } } } diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index 8994cc5a5e27..4a3a228e89cc 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -68,8 +68,7 @@ class MockErrorCollector : public io::ErrorCollector { // implements ErrorCollector --------------------------------------- void AddWarning(int line, int column, const std::string& message) override { - strings::SubstituteAndAppend(&warning_, "$0:$1: $2\n", line, column, - message); + strings::SubstituteAndAppend(&warning_, "$0:$1: $2\n", line, column, message); } void AddError(int line, int column, const std::string& message) override { @@ -1009,6 +1008,43 @@ TEST_F(ParseMessageTest, OptionalLabelProto3) { "}"); } +TEST_F(ParseMessageTest, ExplicitOptionalLabelProto3) { + ExpectParsesTo( + "syntax = 'proto3';\n" + "message TestMessage {\n" + " optional int32 foo = 1;\n" + "}\n", + + "syntax: \"proto3\" " + "message_type {" + " name: \"TestMessage\"" + " field { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 " + " proto3_optional: true oneof_index: 0 } " + " oneof_decl { name:\"_foo\" } " + "}"); + + // Handle collisions in the synthetic oneof name. + ExpectParsesTo( + "syntax = 'proto3';\n" + "message TestMessage {\n" + " optional int32 foo = 1;\n" + " oneof _foo {\n" + " int32 __foo = 2;\n" + " }\n" + "}\n", + + "syntax: \"proto3\" " + "message_type {" + " name: \"TestMessage\"" + " field { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 " + " proto3_optional: true oneof_index: 1 } " + " field { name:\"__foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:2 " + " oneof_index: 0 } " + " oneof_decl { name:\"_foo\" } " + " oneof_decl { name:\"X_foo\" } " + "}"); +} + // =================================================================== typedef ParserTest ParseEnumTest; @@ -1575,17 +1611,6 @@ TEST_F(ParseErrorTest, EofInAggregateValue) { "1:0: Unexpected end of stream while parsing aggregate value.\n"); } -TEST_F(ParseErrorTest, ExplicitOptionalLabelProto3) { - ExpectHasErrors( - "syntax = 'proto3';\n" - "message TestMessage {\n" - " optional int32 foo = 1;\n" - "}\n", - "2:11: Explicit 'optional' labels are disallowed in the Proto3 syntax. " - "To define 'optional' fields in Proto3, simply remove the 'optional' " - "label, as fields are 'optional' by default.\n"); -} - // ------------------------------------------------------------------- // Enum errors diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index 7de3985c530f..7306cf44490f 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -132,6 +132,8 @@ bool GenerateCode(const CodeGeneratorRequest& request, bool succeeded = generator.GenerateAll(parsed_files, request.parameter(), &context, &error); + response->set_supported_features(generator.GetSupportedFeatures()); + if (!succeeded && error.empty()) { error = "Code generator returned false but provided no error " diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 8e590e91794e..6739215d892b 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -97,7 +97,7 @@ PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_goo {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; +static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { @@ -144,15 +144,17 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fcompiler_2 ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, error_), + PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, supported_features_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, file_), 0, + 1, ~0u, }; static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, 9, sizeof(PROTOBUF_NAMESPACE_ID::compiler::Version)}, { 13, 22, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, { 26, 34, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, - { 37, 44, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, + { 37, 45, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { @@ -172,13 +174,16 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2epro "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." "FileDescriptorProto\022;\n\020compiler_version\030" "\003 \001(\0132!.google.protobuf.compiler.Version" - "\"\252\001\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" - "\t\022B\n\004file\030\017 \003(\01324.google.protobuf.compil" - "er.CodeGeneratorResponse.File\032>\n\004File\022\014\n" - "\004name\030\001 \001(\t\022\027\n\017insertion_point\030\002 \001(\t\022\017\n\007" - "content\030\017 \001(\tBg\n\034com.google.protobuf.com" - "pilerB\014PluginProtosZ9github.com/golang/p" - "rotobuf/protoc-gen-go/plugin;plugin_go" + "\"\200\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" + "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 " + "\003(\01324.google.protobuf.compiler.CodeGener" + "atorResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022" + "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(" + "\t\"8\n\007Feature\022\020\n\014FEATURE_NONE\020\000\022\033\n\027FEATUR" + "E_PROTO3_OPTIONAL\020\001Bg\n\034com.google.protob" + "uf.compilerB\014PluginProtosZ9github.com/go" + "lang/protobuf/protoc-gen-go/plugin;plugi" + "n_go" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, @@ -190,9 +195,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", 638, + false, false, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", 724, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_sccs, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 4, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, 4, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, @@ -202,6 +206,27 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google static bool dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto)), true); PROTOBUF_NAMESPACE_OPEN namespace compiler { +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); + return file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]; +} +bool CodeGeneratorResponse_Feature_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; + } +} + +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) +constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_NONE; +constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_PROTO3_OPTIONAL; +constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MIN; +constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MAX; +constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) // =================================================================== @@ -224,19 +249,20 @@ class Version::_Internal { } }; -Version::Version() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version) } Version::Version(const Version& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_suffix()) { - suffix_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.suffix_); + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_suffix(), + GetArena()); } ::memcpy(&major_, &from.major_, static_cast(reinterpret_cast(&patch_) - @@ -255,12 +281,20 @@ void Version::SharedCtor() { Version::~Version() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Version::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void Version::ArenaDtor(void* object) { + Version* _this = reinterpret_cast< Version* >(object); + (void)_this; +} +void Version::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void Version::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -278,7 +312,7 @@ void Version::Clear() { cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { - suffix_.ClearNonDefaultToEmptyNoArena(); + suffix_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x0000000eu) { ::memset(&major_, 0, static_cast( @@ -286,12 +320,13 @@ void Version::Clear() { reinterpret_cast(&major_)) + sizeof(patch_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -338,7 +373,9 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -390,7 +427,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Version::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version) return target; @@ -462,15 +499,14 @@ void Version::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Version::MergeFrom(const Version& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _has_bits_[0] |= 0x00000001u; - suffix_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.suffix_); + _internal_set_suffix(from._internal_suffix()); } if (cached_has_bits & 0x00000002u) { major_ = from.major_; @@ -505,13 +541,15 @@ bool Version::IsInitialized() const { void Version::InternalSwap(Version* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - suffix_.Swap(&other->suffix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(major_, other->major_); - swap(minor_, other->minor_); - swap(patch_, other->patch_); + suffix_.Swap(&other->suffix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Version, patch_) + + sizeof(Version::patch_) + - PROTOBUF_FIELD_OFFSET(Version, major_)>( + reinterpret_cast(&major_), + reinterpret_cast(&other->major_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const { @@ -544,21 +582,24 @@ CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* ms void CodeGeneratorRequest::clear_proto_file() { proto_file_.Clear(); } -CodeGeneratorRequest::CodeGeneratorRequest() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + file_to_generate_(arena), + proto_file_(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest) } CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), file_to_generate_(from.file_to_generate_), proto_file_(from.proto_file_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_parameter()) { - parameter_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.parameter_); + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_parameter(), + GetArena()); } if (from._internal_has_compiler_version()) { compiler_version_ = new PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_); @@ -577,13 +618,21 @@ void CodeGeneratorRequest::SharedCtor() { CodeGeneratorRequest::~CodeGeneratorRequest() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void CodeGeneratorRequest::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete compiler_version_; } +void CodeGeneratorRequest::ArenaDtor(void* object) { + CodeGeneratorRequest* _this = reinterpret_cast< CodeGeneratorRequest* >(object); + (void)_this; +} +void CodeGeneratorRequest::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void CodeGeneratorRequest::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -604,7 +653,7 @@ void CodeGeneratorRequest::Clear() { cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - parameter_.ClearNonDefaultToEmptyNoArena(); + parameter_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(compiler_version_ != nullptr); @@ -612,12 +661,13 @@ void CodeGeneratorRequest::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -675,7 +725,9 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -735,7 +787,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorRequest::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorRequest) return target; @@ -808,7 +860,7 @@ void CodeGeneratorRequest::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& fro void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -817,8 +869,7 @@ void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _has_bits_[0] |= 0x00000001u; - parameter_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.parameter_); + _internal_set_parameter(from._internal_parameter()); } if (cached_has_bits & 0x00000002u) { _internal_mutable_compiler_version()->PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom(from._internal_compiler_version()); @@ -847,12 +898,11 @@ bool CodeGeneratorRequest::IsInitialized() const { void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); file_to_generate_.InternalSwap(&other->file_to_generate_); proto_file_.InternalSwap(&other->proto_file_); - parameter_.Swap(&other->parameter_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + parameter_.Swap(&other->parameter_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(compiler_version_, other->compiler_version_); } @@ -879,27 +929,30 @@ class CodeGeneratorResponse_File::_Internal { } }; -CodeGeneratorResponse_File::CodeGeneratorResponse_File() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), + GetArena()); } insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_insertion_point()) { - insertion_point_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.insertion_point_); + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_insertion_point(), + GetArena()); } content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_content()) { - content_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.content_); + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_content(), + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } @@ -914,14 +967,22 @@ void CodeGeneratorResponse_File::SharedCtor() { CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void CodeGeneratorResponse_File::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void CodeGeneratorResponse_File::ArenaDtor(void* object) { + CodeGeneratorResponse_File* _this = reinterpret_cast< CodeGeneratorResponse_File* >(object); + (void)_this; +} +void CodeGeneratorResponse_File::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void CodeGeneratorResponse_File::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -940,22 +1001,23 @@ void CodeGeneratorResponse_File::Clear() { cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmptyNoArena(); + name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - insertion_point_.ClearNonDefaultToEmptyNoArena(); + insertion_point_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - content_.ClearNonDefaultToEmptyNoArena(); + content_.ClearNonDefaultToEmpty(); } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1000,7 +1062,9 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1054,7 +1118,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse_File::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse.File) return target; @@ -1119,23 +1183,20 @@ void CodeGeneratorResponse_File::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Messag void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _has_bits_[0] |= 0x00000001u; - name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _has_bits_[0] |= 0x00000002u; - insertion_point_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.insertion_point_); + _internal_set_insertion_point(from._internal_insertion_point()); } if (cached_has_bits & 0x00000004u) { - _has_bits_[0] |= 0x00000004u; - content_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.content_); + _internal_set_content(from._internal_content()); } } } @@ -1160,14 +1221,11 @@ bool CodeGeneratorResponse_File::IsInitialized() const { void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - insertion_point_.Swap(&other->insertion_point_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - content_.Swap(&other->content_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + insertion_point_.Swap(&other->insertion_point_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + content_.Swap(&other->content_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const { @@ -1185,40 +1243,55 @@ class CodeGeneratorResponse::_Internal { static void set_has_error(HasBits* has_bits) { (*has_bits)[0] |= 1u; } + static void set_has_supported_features(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } }; -CodeGeneratorResponse::CodeGeneratorResponse() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + file_(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse) } CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), file_(from.file_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_error()) { - error_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.error_); + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_error(), + GetArena()); } + supported_features_ = from.supported_features_; // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } void CodeGeneratorResponse::SharedCtor() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + supported_features_ = PROTOBUF_ULONGLONG(0); } CodeGeneratorResponse::~CodeGeneratorResponse() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void CodeGeneratorResponse::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void CodeGeneratorResponse::ArenaDtor(void* object) { + CodeGeneratorResponse* _this = reinterpret_cast< CodeGeneratorResponse* >(object); + (void)_this; +} +void CodeGeneratorResponse::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void CodeGeneratorResponse::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -1237,15 +1310,17 @@ void CodeGeneratorResponse::Clear() { file_.Clear(); cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { - error_.ClearNonDefaultToEmptyNoArena(); + error_.ClearNonDefaultToEmpty(); } + supported_features_ = PROTOBUF_ULONGLONG(0); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1262,6 +1337,14 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA CHK_(ptr); } else goto handle_unusual; continue; + // optional uint64 supported_features = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + _Internal::set_has_supported_features(&has_bits); + supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; case 15: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) { @@ -1280,7 +1363,9 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1312,6 +1397,12 @@ ::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse::_InternalSerialize( 1, this->_internal_error(), target); } + // optional uint64 supported_features = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(2, this->_internal_supported_features(), target); + } + // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; for (unsigned int i = 0, n = static_cast(this->_internal_file_size()); i < n; i++) { @@ -1322,7 +1413,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse) return target; @@ -1343,14 +1434,23 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - // optional string error = 1; cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_error()); - } + if (cached_has_bits & 0x00000003u) { + // optional string error = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_error()); + } + + // optional uint64 supported_features = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size( + this->_internal_supported_features()); + } + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); @@ -1378,14 +1478,20 @@ void CodeGeneratorResponse::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& fr void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; file_.MergeFrom(from.file_); - if (from._internal_has_error()) { - _has_bits_[0] |= 0x00000001u; - error_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.error_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_set_error(from._internal_error()); + } + if (cached_has_bits & 0x00000002u) { + supported_features_ = from.supported_features_; + } + _has_bits_[0] |= cached_has_bits; } } @@ -1409,11 +1515,11 @@ bool CodeGeneratorResponse::IsInitialized() const { void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); file_.InternalSwap(&other->file_); - error_.Swap(&other->error_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + error_.Swap(&other->error_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + swap(supported_features_, other->supported_features_); } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const { @@ -1426,16 +1532,16 @@ ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const { PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::Version >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::compiler::Version >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::Version >(arena); } template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(arena); } template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(arena); } template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 6061e3c6baaf..80ebc07a7da3 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -26,11 +26,12 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export #include // IWYU pragma: export +#include #include #include // @@protoc_insertion_point(includes) @@ -86,12 +87,35 @@ PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN namespace compiler { +enum CodeGeneratorResponse_Feature : int { + CodeGeneratorResponse_Feature_FEATURE_NONE = 0, + CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1 +}; +PROTOC_EXPORT bool CodeGeneratorResponse_Feature_IsValid(int value); +constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MIN = CodeGeneratorResponse_Feature_FEATURE_NONE; +constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MAX = CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL; +constexpr int CodeGeneratorResponse_Feature_Feature_ARRAYSIZE = CodeGeneratorResponse_Feature_Feature_MAX + 1; + +PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor(); +template +inline const std::string& CodeGeneratorResponse_Feature_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function CodeGeneratorResponse_Feature_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + CodeGeneratorResponse_Feature_descriptor(), enum_t_value); +} +inline bool CodeGeneratorResponse_Feature_Parse( + const std::string& name, CodeGeneratorResponse_Feature* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + CodeGeneratorResponse_Feature_descriptor(), name, value); +} // =================================================================== -class PROTOC_EXPORT Version : +class PROTOC_EXPORT Version PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { public: - Version(); + inline Version() : Version(nullptr) {}; virtual ~Version(); Version(const Version& from); @@ -105,7 +129,7 @@ class PROTOC_EXPORT Version : return *this; } inline Version& operator=(Version&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -114,10 +138,10 @@ class PROTOC_EXPORT Version : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { @@ -144,6 +168,15 @@ class PROTOC_EXPORT Version : } inline void Swap(Version* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Version* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -178,13 +211,11 @@ class PROTOC_EXPORT Version : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.Version"; } + protected: + explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -220,6 +251,15 @@ class PROTOC_EXPORT Version : std::string* mutable_suffix(); std::string* release_suffix(); void set_allocated_suffix(std::string* suffix); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_suffix(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_suffix( + std::string* suffix); private: const std::string& _internal_suffix() const; void _internal_set_suffix(const std::string& value); @@ -269,7 +309,9 @@ class PROTOC_EXPORT Version : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_; @@ -280,10 +322,10 @@ class PROTOC_EXPORT Version : }; // ------------------------------------------------------------------- -class PROTOC_EXPORT CodeGeneratorRequest : +class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { public: - CodeGeneratorRequest(); + inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {}; virtual ~CodeGeneratorRequest(); CodeGeneratorRequest(const CodeGeneratorRequest& from); @@ -297,7 +339,7 @@ class PROTOC_EXPORT CodeGeneratorRequest : return *this; } inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -306,10 +348,10 @@ class PROTOC_EXPORT CodeGeneratorRequest : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { @@ -336,6 +378,15 @@ class PROTOC_EXPORT CodeGeneratorRequest : } inline void Swap(CodeGeneratorRequest* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(CodeGeneratorRequest* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -370,13 +421,11 @@ class PROTOC_EXPORT CodeGeneratorRequest : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.CodeGeneratorRequest"; } + protected: + explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -454,6 +503,15 @@ class PROTOC_EXPORT CodeGeneratorRequest : std::string* mutable_parameter(); std::string* release_parameter(); void set_allocated_parameter(std::string* parameter); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_parameter(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_parameter( + std::string* parameter); private: const std::string& _internal_parameter() const; void _internal_set_parameter(const std::string& value); @@ -474,12 +532,17 @@ class PROTOC_EXPORT CodeGeneratorRequest : const PROTOBUF_NAMESPACE_ID::compiler::Version& _internal_compiler_version() const; PROTOBUF_NAMESPACE_ID::compiler::Version* _internal_mutable_compiler_version(); public: + void unsafe_arena_set_allocated_compiler_version( + PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version); + PROTOBUF_NAMESPACE_ID::compiler::Version* unsafe_arena_release_compiler_version(); // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField file_to_generate_; @@ -490,10 +553,10 @@ class PROTOC_EXPORT CodeGeneratorRequest : }; // ------------------------------------------------------------------- -class PROTOC_EXPORT CodeGeneratorResponse_File : +class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { public: - CodeGeneratorResponse_File(); + inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {}; virtual ~CodeGeneratorResponse_File(); CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from); @@ -507,7 +570,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : return *this; } inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -516,10 +579,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { @@ -546,6 +609,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : } inline void Swap(CodeGeneratorResponse_File* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(CodeGeneratorResponse_File* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -580,13 +652,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.CodeGeneratorResponse.File"; } + protected: + explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -621,6 +691,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_name(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + std::string* name); private: const std::string& _internal_name() const; void _internal_set_name(const std::string& value); @@ -641,6 +720,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : std::string* mutable_insertion_point(); std::string* release_insertion_point(); void set_allocated_insertion_point(std::string* insertion_point); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_insertion_point(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_insertion_point( + std::string* insertion_point); private: const std::string& _internal_insertion_point() const; void _internal_set_insertion_point(const std::string& value); @@ -661,6 +749,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : std::string* mutable_content(); std::string* release_content(); void set_allocated_content(std::string* content); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_content(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_content( + std::string* content); private: const std::string& _internal_content() const; void _internal_set_content(const std::string& value); @@ -671,7 +768,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; @@ -681,10 +780,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : }; // ------------------------------------------------------------------- -class PROTOC_EXPORT CodeGeneratorResponse : +class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { public: - CodeGeneratorResponse(); + inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {}; virtual ~CodeGeneratorResponse(); CodeGeneratorResponse(const CodeGeneratorResponse& from); @@ -698,7 +797,7 @@ class PROTOC_EXPORT CodeGeneratorResponse : return *this; } inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -707,10 +806,10 @@ class PROTOC_EXPORT CodeGeneratorResponse : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { @@ -737,6 +836,15 @@ class PROTOC_EXPORT CodeGeneratorResponse : } inline void Swap(CodeGeneratorResponse* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(CodeGeneratorResponse* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -771,13 +879,11 @@ class PROTOC_EXPORT CodeGeneratorResponse : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.CodeGeneratorResponse"; } + protected: + explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -793,11 +899,42 @@ class PROTOC_EXPORT CodeGeneratorResponse : typedef CodeGeneratorResponse_File File; + typedef CodeGeneratorResponse_Feature Feature; + static constexpr Feature FEATURE_NONE = + CodeGeneratorResponse_Feature_FEATURE_NONE; + static constexpr Feature FEATURE_PROTO3_OPTIONAL = + CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL; + static inline bool Feature_IsValid(int value) { + return CodeGeneratorResponse_Feature_IsValid(value); + } + static constexpr Feature Feature_MIN = + CodeGeneratorResponse_Feature_Feature_MIN; + static constexpr Feature Feature_MAX = + CodeGeneratorResponse_Feature_Feature_MAX; + static constexpr int Feature_ARRAYSIZE = + CodeGeneratorResponse_Feature_Feature_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Feature_descriptor() { + return CodeGeneratorResponse_Feature_descriptor(); + } + template + static inline const std::string& Feature_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Feature_Name."); + return CodeGeneratorResponse_Feature_Name(enum_t_value); + } + static inline bool Feature_Parse(const std::string& name, + Feature* value) { + return CodeGeneratorResponse_Feature_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { kFileFieldNumber = 15, kErrorFieldNumber = 1, + kSupportedFeaturesFieldNumber = 2, }; // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; int file_size() const; @@ -831,21 +968,46 @@ class PROTOC_EXPORT CodeGeneratorResponse : std::string* mutable_error(); std::string* release_error(); void set_allocated_error(std::string* error); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_error(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_error( + std::string* error); private: const std::string& _internal_error() const; void _internal_set_error(const std::string& value); std::string* _internal_mutable_error(); public: + // optional uint64 supported_features = 2; + bool has_supported_features() const; + private: + bool _internal_has_supported_features() const; + public: + void clear_supported_features(); + ::PROTOBUF_NAMESPACE_ID::uint64 supported_features() const; + void set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value); + private: + ::PROTOBUF_NAMESPACE_ID::uint64 _internal_supported_features() const; + void _internal_set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value); + public: + // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_; + ::PROTOBUF_NAMESPACE_ID::uint64 supported_features_; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // =================================================================== @@ -952,7 +1114,7 @@ inline bool Version::has_suffix() const { return _internal_has_suffix(); } inline void Version::clear_suffix() { - suffix_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + suffix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& Version::suffix() const { @@ -968,33 +1130,35 @@ inline std::string* Version::mutable_suffix() { return _internal_mutable_suffix(); } inline const std::string& Version::_internal_suffix() const { - return suffix_.GetNoArena(); + return suffix_.Get(); } inline void Version::_internal_set_suffix(const std::string& value) { _has_bits_[0] |= 0x00000001u; - suffix_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Version::set_suffix(std::string&& value) { _has_bits_[0] |= 0x00000001u; - suffix_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + suffix_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix) } inline void Version::set_suffix(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; - suffix_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) } -inline void Version::set_suffix(const char* value, size_t size) { +inline void Version::set_suffix(const char* value, + size_t size) { _has_bits_[0] |= 0x00000001u; - suffix_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) } inline std::string* Version::_internal_mutable_suffix() { _has_bits_[0] |= 0x00000001u; - return suffix_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return suffix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Version::release_suffix() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) @@ -1002,7 +1166,7 @@ inline std::string* Version::release_suffix() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return suffix_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Version::set_allocated_suffix(std::string* suffix) { if (suffix != nullptr) { @@ -1010,9 +1174,29 @@ inline void Version::set_allocated_suffix(std::string* suffix) { } else { _has_bits_[0] &= ~0x00000001u; } - suffix_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix); + suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) } +inline std::string* Version::unsafe_arena_release_suffix() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.Version.suffix) + GOOGLE_DCHECK(GetArena() != nullptr); + _has_bits_[0] &= ~0x00000001u; + return suffix_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void Version::unsafe_arena_set_allocated_suffix( + std::string* suffix) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (suffix != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + suffix_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + suffix, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.Version.suffix) +} // ------------------------------------------------------------------- @@ -1101,7 +1285,7 @@ inline bool CodeGeneratorRequest::has_parameter() const { return _internal_has_parameter(); } inline void CodeGeneratorRequest::clear_parameter() { - parameter_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + parameter_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorRequest::parameter() const { @@ -1117,33 +1301,35 @@ inline std::string* CodeGeneratorRequest::mutable_parameter() { return _internal_mutable_parameter(); } inline const std::string& CodeGeneratorRequest::_internal_parameter() const { - return parameter_.GetNoArena(); + return parameter_.Get(); } inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) { _has_bits_[0] |= 0x00000001u; - parameter_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void CodeGeneratorRequest::set_parameter(std::string&& value) { _has_bits_[0] |= 0x00000001u; - parameter_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + parameter_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter) } inline void CodeGeneratorRequest::set_parameter(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; - parameter_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter) } -inline void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { +inline void CodeGeneratorRequest::set_parameter(const char* value, + size_t size) { _has_bits_[0] |= 0x00000001u; - parameter_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter) } inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { _has_bits_[0] |= 0x00000001u; - return parameter_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return parameter_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* CodeGeneratorRequest::release_parameter() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) @@ -1151,7 +1337,7 @@ inline std::string* CodeGeneratorRequest::release_parameter() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return parameter_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter) { if (parameter != nullptr) { @@ -1159,9 +1345,29 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter } else { _has_bits_[0] &= ~0x00000001u; } - parameter_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter); + parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) } +inline std::string* CodeGeneratorRequest::unsafe_arena_release_parameter() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) + GOOGLE_DCHECK(GetArena() != nullptr); + _has_bits_[0] &= ~0x00000001u; + return parameter_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void CodeGeneratorRequest::unsafe_arena_set_allocated_parameter( + std::string* parameter) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (parameter != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + parameter_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + parameter, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) +} // repeated .google.protobuf.FileDescriptorProto proto_file = 15; inline int CodeGeneratorRequest::_internal_proto_file_size() const { @@ -1221,7 +1427,27 @@ inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::com // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) return _internal_compiler_version(); } +inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version( + PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_); + } + compiler_version_ = compiler_version; + if (compiler_version) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) +} inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_compiler_version() { + auto temp = unsafe_arena_release_compiler_version(); + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::unsafe_arena_release_compiler_version() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; @@ -1231,7 +1457,7 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_c inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() { _has_bits_[0] |= 0x00000002u; if (compiler_version_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); compiler_version_ = p; } return compiler_version_; @@ -1241,12 +1467,13 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable_c return _internal_mutable_compiler_version(); } inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete compiler_version_; } if (compiler_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr; + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(compiler_version); if (message_arena != submessage_arena) { compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, compiler_version, submessage_arena); @@ -1272,7 +1499,7 @@ inline bool CodeGeneratorResponse_File::has_name() const { return _internal_has_name(); } inline void CodeGeneratorResponse_File::clear_name() { - name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorResponse_File::name() const { @@ -1288,33 +1515,35 @@ inline std::string* CodeGeneratorResponse_File::mutable_name() { return _internal_mutable_name(); } inline const std::string& CodeGeneratorResponse_File::_internal_name() const { - return name_.GetNoArena(); + return name_.Get(); } inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void CodeGeneratorResponse_File::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; - name_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name) } inline void CodeGeneratorResponse_File::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) } -inline void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { +inline void CodeGeneratorResponse_File::set_name(const char* value, + size_t size) { _has_bits_[0] |= 0x00000001u; - name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) } inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* CodeGeneratorResponse_File::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) @@ -1322,7 +1551,7 @@ inline std::string* CodeGeneratorResponse_File::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1330,9 +1559,29 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { } else { _has_bits_[0] &= ~0x00000001u; } - name_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) } +inline std::string* CodeGeneratorResponse_File::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) + GOOGLE_DCHECK(GetArena() != nullptr); + _has_bits_[0] &= ~0x00000001u; + return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_name( + std::string* name) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + name, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} // optional string insertion_point = 2; inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const { @@ -1343,7 +1592,7 @@ inline bool CodeGeneratorResponse_File::has_insertion_point() const { return _internal_has_insertion_point(); } inline void CodeGeneratorResponse_File::clear_insertion_point() { - insertion_point_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + insertion_point_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& CodeGeneratorResponse_File::insertion_point() const { @@ -1359,33 +1608,35 @@ inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { return _internal_mutable_insertion_point(); } inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point() const { - return insertion_point_.GetNoArena(); + return insertion_point_.Get(); } inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) { _has_bits_[0] |= 0x00000002u; - insertion_point_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void CodeGeneratorResponse_File::set_insertion_point(std::string&& value) { _has_bits_[0] |= 0x00000002u; - insertion_point_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + insertion_point_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; - insertion_point_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } -inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { +inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, + size_t size) { _has_bits_[0] |= 0x00000002u; - insertion_point_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { _has_bits_[0] |= 0x00000002u; - return insertion_point_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return insertion_point_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* CodeGeneratorResponse_File::release_insertion_point() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) @@ -1393,7 +1644,7 @@ inline std::string* CodeGeneratorResponse_File::release_insertion_point() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return insertion_point_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::string* insertion_point) { if (insertion_point != nullptr) { @@ -1401,9 +1652,29 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin } else { _has_bits_[0] &= ~0x00000002u; } - insertion_point_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point); + insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } +inline std::string* CodeGeneratorResponse_File::unsafe_arena_release_insertion_point() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + GOOGLE_DCHECK(GetArena() != nullptr); + _has_bits_[0] &= ~0x00000002u; + return insertion_point_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_insertion_point( + std::string* insertion_point) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (insertion_point != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + insertion_point_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + insertion_point, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} // optional string content = 15; inline bool CodeGeneratorResponse_File::_internal_has_content() const { @@ -1414,7 +1685,7 @@ inline bool CodeGeneratorResponse_File::has_content() const { return _internal_has_content(); } inline void CodeGeneratorResponse_File::clear_content() { - content_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + content_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& CodeGeneratorResponse_File::content() const { @@ -1430,33 +1701,35 @@ inline std::string* CodeGeneratorResponse_File::mutable_content() { return _internal_mutable_content(); } inline const std::string& CodeGeneratorResponse_File::_internal_content() const { - return content_.GetNoArena(); + return content_.Get(); } inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) { _has_bits_[0] |= 0x00000004u; - content_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void CodeGeneratorResponse_File::set_content(std::string&& value) { _has_bits_[0] |= 0x00000004u; - content_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + content_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content) } inline void CodeGeneratorResponse_File::set_content(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000004u; - content_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) } -inline void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { +inline void CodeGeneratorResponse_File::set_content(const char* value, + size_t size) { _has_bits_[0] |= 0x00000004u; - content_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) } inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { _has_bits_[0] |= 0x00000004u; - return content_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return content_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* CodeGeneratorResponse_File::release_content() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) @@ -1464,7 +1737,7 @@ inline std::string* CodeGeneratorResponse_File::release_content() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return content_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void CodeGeneratorResponse_File::set_allocated_content(std::string* content) { if (content != nullptr) { @@ -1472,9 +1745,29 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte } else { _has_bits_[0] &= ~0x00000004u; } - content_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content); + content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) } +inline std::string* CodeGeneratorResponse_File::unsafe_arena_release_content() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) + GOOGLE_DCHECK(GetArena() != nullptr); + _has_bits_[0] &= ~0x00000004u; + return content_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_content( + std::string* content) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (content != nullptr) { + _has_bits_[0] |= 0x00000004u; + } else { + _has_bits_[0] &= ~0x00000004u; + } + content_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + content, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} // ------------------------------------------------------------------- @@ -1489,7 +1782,7 @@ inline bool CodeGeneratorResponse::has_error() const { return _internal_has_error(); } inline void CodeGeneratorResponse::clear_error() { - error_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + error_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorResponse::error() const { @@ -1505,33 +1798,35 @@ inline std::string* CodeGeneratorResponse::mutable_error() { return _internal_mutable_error(); } inline const std::string& CodeGeneratorResponse::_internal_error() const { - return error_.GetNoArena(); + return error_.Get(); } inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) { _has_bits_[0] |= 0x00000001u; - error_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void CodeGeneratorResponse::set_error(std::string&& value) { _has_bits_[0] |= 0x00000001u; - error_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + error_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error) } inline void CodeGeneratorResponse::set_error(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; - error_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error) } -inline void CodeGeneratorResponse::set_error(const char* value, size_t size) { +inline void CodeGeneratorResponse::set_error(const char* value, + size_t size) { _has_bits_[0] |= 0x00000001u; - error_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error) } inline std::string* CodeGeneratorResponse::_internal_mutable_error() { _has_bits_[0] |= 0x00000001u; - return error_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return error_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* CodeGeneratorResponse::release_error() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) @@ -1539,7 +1834,7 @@ inline std::string* CodeGeneratorResponse::release_error() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return error_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { if (error != nullptr) { @@ -1547,9 +1842,57 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { } else { _has_bits_[0] &= ~0x00000001u; } - error_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error); + error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) } +inline std::string* CodeGeneratorResponse::unsafe_arena_release_error() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.error) + GOOGLE_DCHECK(GetArena() != nullptr); + _has_bits_[0] &= ~0x00000001u; + return error_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void CodeGeneratorResponse::unsafe_arena_set_allocated_error( + std::string* error) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (error != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + error_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + error, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) +} + +// optional uint64 supported_features = 2; +inline bool CodeGeneratorResponse::_internal_has_supported_features() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool CodeGeneratorResponse::has_supported_features() const { + return _internal_has_supported_features(); +} +inline void CodeGeneratorResponse::clear_supported_features() { + supported_features_ = PROTOBUF_ULONGLONG(0); + _has_bits_[0] &= ~0x00000002u; +} +inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::_internal_supported_features() const { + return supported_features_; +} +inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::supported_features() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.supported_features) + return _internal_supported_features(); +} +inline void CodeGeneratorResponse::_internal_set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value) { + _has_bits_[0] |= 0x00000002u; + supported_features_ = value; +} +inline void CodeGeneratorResponse::set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value) { + _internal_set_supported_features(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.supported_features) +} // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; inline int CodeGeneratorResponse::_internal_file_size() const { @@ -1605,6 +1948,16 @@ CodeGeneratorResponse::file() const { } // namespace compiler PROTOBUF_NAMESPACE_CLOSE +PROTOBUF_NAMESPACE_OPEN + +template <> struct is_proto_enum< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature>() { + return PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature_descriptor(); +} + +PROTOBUF_NAMESPACE_CLOSE + // @@protoc_insertion_point(global_scope) #include diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto index 665e5a725d8c..492b896c5bab 100644 --- a/src/google/protobuf/compiler/plugin.proto +++ b/src/google/protobuf/compiler/plugin.proto @@ -107,6 +107,16 @@ message CodeGeneratorResponse { // exiting with a non-zero status code. optional string error = 1; + // A bitmask of supported features that the code generator supports. + // This is a bitwise "or" of values from the Feature enum. + optional uint64 supported_features = 2; + + // Sync with code_generator.h. + enum Feature { + FEATURE_NONE = 0; + FEATURE_PROTO3_OPTIONAL = 1; + } + // Represents a single generated file. message File { // The file name, relative to the output directory. The name must not diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index b20f3fb27dae..1e7e923d82ff 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -441,7 +441,8 @@ void Generator::PrintFileDescriptor() const { " name='$name$',\n" " package='$package$',\n" " syntax='$syntax$',\n" - " serialized_options=$options$,\n"; + " serialized_options=$options$,\n" + " create_key=_descriptor._internal_create_key,\n"; printer_->Print(m, file_descriptor_template); printer_->Indent(); if (pure_python_workable_) { @@ -531,6 +532,7 @@ void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { " full_name='$full_name$',\n" " filename=None,\n" " file=$file$,\n" + " create_key=_descriptor._internal_create_key,\n" " values=[\n"; std::string options_string; enum_descriptor.options().SerializeToString(&options_string); @@ -635,7 +637,8 @@ void Generator::PrintServiceDescriptor( "full_name='$full_name$',\n" "file=$file$,\n" "index=$index$,\n" - "serialized_options=$options_value$,\n"; + "serialized_options=$options_value$,\n" + "create_key=_descriptor._internal_create_key,\n"; printer_->Print(m, required_function_arguments); ServiceDescriptorProto sdp; @@ -663,7 +666,8 @@ void Generator::PrintServiceDescriptor( "containing_service=None,\n" "input_type=$input_type$,\n" "output_type=$output_type$,\n" - "serialized_options=$options_value$,\n"); + "serialized_options=$options_value$,\n" + "create_key=_descriptor._internal_create_key,\n"); printer_->Outdent(); printer_->Print("),\n"); } @@ -733,7 +737,8 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { "full_name='$full_name$',\n" "filename=None,\n" "file=$file$,\n" - "containing_type=None,\n"; + "containing_type=None,\n" + "create_key=_descriptor._internal_create_key,\n"; printer_->Print(m, required_function_arguments); PrintFieldsInDescriptor(message_descriptor); PrintExtensionsInDescriptor(message_descriptor); @@ -796,7 +801,8 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { printer_->Print(m, "_descriptor.OneofDescriptor(\n" " name='$name$', full_name='$full_name$',\n" - " index=$index$, containing_type=None, " + " index=$index$, containing_type=None,\n" + " create_key=_descriptor._internal_create_key,\n" "fields=[]$serialized_options$),\n"); } printer_->Outdent(); @@ -1037,8 +1043,8 @@ std::string Generator::FieldReferencingExpression( return ResolveKeyword(field.name()); } return strings::Substitute("$0.$1['$2']", - ModuleLevelDescriptorName(*containing_type), - python_dict_name, field.name()); + ModuleLevelDescriptorName(*containing_type), + python_dict_name, field.name()); } // Prints containing_type for nested descriptors or enum descriptors. @@ -1144,7 +1150,8 @@ void Generator::PrintEnumValueDescriptor( "_descriptor.EnumValueDescriptor(\n" " name='$name$', index=$index$, number=$number$,\n" " serialized_options=$options$,\n" - " type=None)"); + " type=None,\n" + " create_key=_descriptor._internal_create_key)"); } // Returns a CEscaped string of serialized_options. @@ -1187,7 +1194,8 @@ void Generator::PrintFieldDescriptor(const FieldDescriptor& field, "default_value=$default_value$,\n" " message_type=None, enum_type=None, containing_type=None,\n" " is_extension=$is_extension$, extension_scope=None,\n" - " serialized_options=$serialized_options$$json_name$, file=DESCRIPTOR)"; + " serialized_options=$serialized_options$$json_name$, file=DESCRIPTOR," + " create_key=_descriptor._internal_create_key)"; printer_->Print(m, field_descriptor_decl); } diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index fd439be9ab44..7e59cd7d8d26 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -255,8 +255,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, child_handle_ = NULL; if (exit_code != 0) { - *error = - strings::Substitute("Plugin failed with status code $0.", exit_code); + *error = strings::Substitute("Plugin failed with status code $0.", exit_code); return false; } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 80a12fc85418..b94e925e45f4 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -579,6 +579,12 @@ class DescriptorPool::Tables { // set of extensions numbers from fallback_database_. HASH_SET extensions_loaded_from_db_; + // Maps type name to Descriptor::WellKnownType. This is logically global + // and const, but we make it a member here to simplify its construction and + // destruction. This only has 20-ish entries and is one per DescriptorPool, + // so the overhead is small. + HASH_MAP well_known_types_; + // ----------------------------------------------------------------- // Finding items. @@ -649,7 +655,7 @@ class DescriptorPool::Tables { private: // All other memory allocated in the pool. Must be first as other objects can // point into these. - std::vector> allocations_; + std::vector> allocations_; std::vector> strings_; std::vector> messages_; std::vector> once_dynamics_; @@ -800,7 +806,26 @@ DescriptorPool::Tables::Tables() known_bad_symbols_(3), extensions_loaded_from_db_(3), symbols_by_name_(3), - files_by_name_(3) {} + files_by_name_(3) { + well_known_types_.insert({ + {"google.protobuf.DoubleValue", Descriptor::WELLKNOWNTYPE_DOUBLEVALUE}, + {"google.protobuf.FloatValue", Descriptor::WELLKNOWNTYPE_FLOATVALUE}, + {"google.protobuf.Int64Value", Descriptor::WELLKNOWNTYPE_INT64VALUE}, + {"google.protobuf.UInt64Value", Descriptor::WELLKNOWNTYPE_UINT64VALUE}, + {"google.protobuf.Int32Value", Descriptor::WELLKNOWNTYPE_INT32VALUE}, + {"google.protobuf.UInt32Value", Descriptor::WELLKNOWNTYPE_UINT32VALUE}, + {"google.protobuf.StringValue", Descriptor::WELLKNOWNTYPE_STRINGVALUE}, + {"google.protobuf.BytesValue", Descriptor::WELLKNOWNTYPE_BYTESVALUE}, + {"google.protobuf.BoolValue", Descriptor::WELLKNOWNTYPE_BOOLVALUE}, + {"google.protobuf.Any", Descriptor::WELLKNOWNTYPE_ANY}, + {"google.protobuf.FieldMask", Descriptor::WELLKNOWNTYPE_FIELDMASK}, + {"google.protobuf.Duration", Descriptor::WELLKNOWNTYPE_DURATION}, + {"google.protobuf.Timestamp", Descriptor::WELLKNOWNTYPE_TIMESTAMP}, + {"google.protobuf.Value", Descriptor::WELLKNOWNTYPE_VALUE}, + {"google.protobuf.ListValue", Descriptor::WELLKNOWNTYPE_LISTVALUE}, + {"google.protobuf.Struct", Descriptor::WELLKNOWNTYPE_STRUCT}, + }); +} DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); } @@ -1209,8 +1234,8 @@ void* DescriptorPool::Tables::AllocateBytes(int size) { // allocators... if (size == 0) return nullptr; - allocations_.emplace_back(new char[size]); - return allocations_.back().get(); + allocations_.emplace_back(size); + return allocations_.back().data(); } void FileDescriptorTables::BuildLocationsByPath( @@ -1283,8 +1308,9 @@ void DescriptorPool::InternalDontEnforceDependencies() { enforce_dependencies_ = false; } -void DescriptorPool::AddUnusedImportTrackFile(const std::string& file_name) { - unused_import_track_files_.insert(file_name); +void DescriptorPool::AddUnusedImportTrackFile(const std::string& file_name, + bool is_error) { + unused_import_track_files_[file_name] = is_error; } void DescriptorPool::ClearUnusedImportTrackFiles() { @@ -2117,7 +2143,9 @@ void FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const { if (has_json_name_) { proto->set_json_name(json_name()); } - + if (proto3_optional_) { + proto->set_proto3_optional(true); + } // Some compilers do not allow static_cast directly between two enum types, // so we must cast to int first. proto->set_label(static_cast( @@ -2337,7 +2365,7 @@ bool FormatLineOptions(int depth, const Message& options, if (RetrieveOptions(depth, options, pool, &all_options)) { for (int i = 0; i < all_options.size(); i++) { strings::SubstituteAndAppend(output, "$0option $1;\n", prefix, - all_options[i]); + all_options[i]); } } return !all_options.empty(); @@ -2422,7 +2450,7 @@ std::string FileDescriptor::DebugStringWithOptions( debug_string_options); syntax_comment.AddPreComment(&contents); strings::SubstituteAndAppend(&contents, "syntax = \"$0\";\n\n", - SyntaxName(syntax())); + SyntaxName(syntax())); syntax_comment.AddPostComment(&contents); } @@ -2439,13 +2467,13 @@ std::string FileDescriptor::DebugStringWithOptions( for (int i = 0; i < dependency_count(); i++) { if (public_dependencies.count(i) > 0) { strings::SubstituteAndAppend(&contents, "import public \"$0\";\n", - dependency(i)->name()); + dependency(i)->name()); } else if (weak_dependencies.count(i) > 0) { strings::SubstituteAndAppend(&contents, "import weak \"$0\";\n", - dependency(i)->name()); + dependency(i)->name()); } else { strings::SubstituteAndAppend(&contents, "import \"$0\";\n", - dependency(i)->name()); + dependency(i)->name()); } } @@ -2496,10 +2524,9 @@ std::string FileDescriptor::DebugStringWithOptions( if (i > 0) contents.append("}\n\n"); containing_type = extension(i)->containing_type(); strings::SubstituteAndAppend(&contents, "extend .$0 {\n", - containing_type->full_name()); + containing_type->full_name()); } - extension(i)->DebugString(1, FieldDescriptor::PRINT_LABEL, &contents, - debug_string_options); + extension(i)->DebugString(1, &contents, debug_string_options); } if (extension_count() > 0) contents.append("}\n\n"); @@ -2567,8 +2594,7 @@ void Descriptor::DebugString(int depth, std::string* contents, } for (int i = 0; i < field_count(); i++) { if (field(i)->containing_oneof() == nullptr) { - field(i)->DebugString(depth, FieldDescriptor::PRINT_LABEL, contents, - debug_string_options); + field(i)->DebugString(depth, contents, debug_string_options); } else if (field(i)->containing_oneof()->field(0) == field(i)) { // This is the first field in this oneof, so print the whole oneof. field(i)->containing_oneof()->DebugString(depth, contents, @@ -2578,8 +2604,8 @@ void Descriptor::DebugString(int depth, std::string* contents, for (int i = 0; i < extension_range_count(); i++) { strings::SubstituteAndAppend(contents, "$0 extensions $1 to $2;\n", prefix, - extension_range(i)->start, - extension_range(i)->end - 1); + extension_range(i)->start, + extension_range(i)->end - 1); } // Group extensions by what they extend, so they can be printed out together. @@ -2589,10 +2615,9 @@ void Descriptor::DebugString(int depth, std::string* contents, if (i > 0) strings::SubstituteAndAppend(contents, "$0 }\n", prefix); containing_type = extension(i)->containing_type(); strings::SubstituteAndAppend(contents, "$0 extend .$1 {\n", prefix, - containing_type->full_name()); + containing_type->full_name()); } - extension(i)->DebugString(depth + 1, FieldDescriptor::PRINT_LABEL, contents, - debug_string_options); + extension(i)->DebugString(depth + 1, contents, debug_string_options); } if (extension_count() > 0) strings::SubstituteAndAppend(contents, "$0 }\n", prefix); @@ -2605,7 +2630,7 @@ void Descriptor::DebugString(int depth, std::string* contents, strings::SubstituteAndAppend(contents, "$0, ", range->start); } else { strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start, - range->end - 1); + range->end - 1); } } contents->replace(contents->size() - 2, 2, ";\n"); @@ -2615,7 +2640,7 @@ void Descriptor::DebugString(int depth, std::string* contents, strings::SubstituteAndAppend(contents, "$0 reserved ", prefix); for (int i = 0; i < reserved_name_count(); i++) { strings::SubstituteAndAppend(contents, "\"$0\", ", - CEscape(reserved_name(i))); + CEscape(reserved_name(i))); } contents->replace(contents->size() - 2, 2, ";\n"); } @@ -2635,10 +2660,10 @@ std::string FieldDescriptor::DebugStringWithOptions( int depth = 0; if (is_extension()) { strings::SubstituteAndAppend(&contents, "extend .$0 {\n", - containing_type()->full_name()); + containing_type()->full_name()); depth = 1; } - DebugString(depth, PRINT_LABEL, &contents, debug_string_options); + DebugString(depth, &contents, debug_string_options); if (is_extension()) { contents.append("}\n"); } @@ -2658,7 +2683,7 @@ std::string FieldDescriptor::FieldTypeNameDebugString() const { } void FieldDescriptor::DebugString( - int depth, PrintLabelFlag print_label_flag, std::string* contents, + int depth, std::string* contents, const DebugStringOptions& debug_string_options) const { std::string prefix(depth * 2, ' '); std::string field_type; @@ -2673,20 +2698,12 @@ void FieldDescriptor::DebugString( field_type = FieldTypeNameDebugString(); } - bool print_label = true; - // Determine whether to omit label: - // 1. For an optional field, omit label if it's in oneof or in proto3. - // 2. For a repeated field, omit label if it's a map. - if (is_optional() && (print_label_flag == OMIT_LABEL || - file()->syntax() == FileDescriptor::SYNTAX_PROTO3)) { - print_label = false; - } else if (is_map()) { - print_label = false; - } - std::string label; - if (print_label) { - label = kLabelToName[this->label()]; - label.push_back(' '); + std::string label = StrCat(kLabelToName[this->label()], " "); + + // Label is omitted for maps, oneof, and plain proto3 fields. + if (is_map() || containing_oneof() || + (is_optional() && !has_optional_keyword())) { + label.clear(); } SourceLocationCommentPrinter comment_printer(this, prefix, @@ -2701,7 +2718,7 @@ void FieldDescriptor::DebugString( if (has_default_value()) { bracketed = true; strings::SubstituteAndAppend(contents, " [default = $0", - DefaultValueAsString(true)); + DefaultValueAsString(true)); } if (has_json_name_) { if (!bracketed) { @@ -2771,8 +2788,7 @@ void OneofDescriptor::DebugString( } else { contents->append("\n"); for (int i = 0; i < field_count(); i++) { - field(i)->DebugString(depth, FieldDescriptor::OMIT_LABEL, contents, - debug_string_options); + field(i)->DebugString(depth, contents, debug_string_options); } strings::SubstituteAndAppend(contents, "$0}\n", prefix); } @@ -2817,7 +2833,7 @@ void EnumDescriptor::DebugString( strings::SubstituteAndAppend(contents, "$0, ", range->start); } else { strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start, - range->end); + range->end); } } contents->replace(contents->size() - 2, 2, ";\n"); @@ -2827,7 +2843,7 @@ void EnumDescriptor::DebugString( strings::SubstituteAndAppend(contents, "$0 reserved ", prefix); for (int i = 0; i < reserved_name_count(); i++) { strings::SubstituteAndAppend(contents, "\"$0\", ", - CEscape(reserved_name(i))); + CEscape(reserved_name(i))); } contents->replace(contents->size() - 2, 2, ";\n"); } @@ -2933,7 +2949,7 @@ void MethodDescriptor::DebugString( if (FormatLineOptions(depth, options(), service()->file()->pool(), &formatted_options)) { strings::SubstituteAndAppend(contents, " {\n$0$1}\n", formatted_options, - prefix); + prefix); } else { contents->append(";\n"); } @@ -3294,14 +3310,14 @@ class DescriptorBuilder { void BuildMessage(const DescriptorProto& proto, const Descriptor* parent, Descriptor* result); void BuildFieldOrExtension(const FieldDescriptorProto& proto, - const Descriptor* parent, FieldDescriptor* result, + Descriptor* parent, FieldDescriptor* result, bool is_extension); - void BuildField(const FieldDescriptorProto& proto, const Descriptor* parent, + void BuildField(const FieldDescriptorProto& proto, Descriptor* parent, FieldDescriptor* result) { BuildFieldOrExtension(proto, parent, result, false); } - void BuildExtension(const FieldDescriptorProto& proto, - const Descriptor* parent, FieldDescriptor* result) { + void BuildExtension(const FieldDescriptorProto& proto, Descriptor* parent, + FieldDescriptor* result) { BuildFieldOrExtension(proto, parent, result, true); } void BuildExtensionRange(const DescriptorProto::ExtensionRange& proto, @@ -3424,6 +3440,7 @@ class DescriptorBuilder { void SetUInt64(int number, uint64 value, FieldDescriptor::Type type, UnknownFieldSet* unknown_fields); + // A helper function that adds an error at the specified location of the // option we're currently interpreting, and returns false. bool AddOptionError(DescriptorPool::ErrorCollector::ErrorLocation location, @@ -3517,6 +3534,9 @@ class DescriptorBuilder { const EnumDescriptorProto& proto); void ValidateEnumValueOptions(EnumValueDescriptor* enum_value, const EnumValueDescriptorProto& proto); + void ValidateExtensionRangeOptions( + const std::string& full_name, Descriptor::ExtensionRange* extension_range, + const DescriptorProto_ExtensionRange& proto); void ValidateServiceOptions(ServiceDescriptor* service, const ServiceDescriptorProto& proto); void ValidateMethodOptions(MethodDescriptor* method, @@ -3988,7 +4008,7 @@ FileDescriptor* DescriptorPool::NewPlaceholderFileWithMutexHeld( placeholder->tables_ = &FileDescriptorTables::GetEmptyInstance(); placeholder->source_code_info_ = &SourceCodeInfo::default_instance(); placeholder->is_placeholder_ = true; - placeholder->syntax_ = FileDescriptor::SYNTAX_PROTO2; + placeholder->syntax_ = FileDescriptor::SYNTAX_UNKNOWN; placeholder->finished_building_ = true; // All other fields are zero or nullptr. @@ -4489,9 +4509,8 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( BUILD_ARRAY(proto, result, extension, BuildExtension, nullptr); // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result); } @@ -4532,8 +4551,10 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( // Again, see comments at InternalSetLazilyBuildDependencies about error - // checking. - if (!unused_dependency_.empty() && !pool_->lazily_build_dependencies_) { + // checking. Also, don't log unused dependencies if there were previous + // errors, since the results might be inaccurate. + if (!had_errors_ && !unused_dependency_.empty() && + !pool_->lazily_build_dependencies_) { LogUnusedDependency(proto, result); } @@ -4571,6 +4592,12 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, result->containing_type_ = parent; result->is_placeholder_ = false; result->is_unqualified_placeholder_ = false; + result->well_known_type_ = Descriptor::WELLKNOWNTYPE_UNSPECIFIED; + + auto it = pool_->tables_->well_known_types_.find(*full_name); + if (it != pool_->tables_->well_known_types_.end()) { + result->well_known_type_ = it->second; + } // Build oneofs first so that fields and extension ranges can refer to them. BUILD_ARRAY(proto, result, oneof_decl, BuildOneof, result); @@ -4592,9 +4619,8 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, } // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result, DescriptorProto::kOptionsFieldNumber, "google.protobuf.MessageOptions"); @@ -4610,9 +4636,9 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, AddError(result->full_name(), proto.reserved_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Reserved range $0 to $1 overlaps with " - "already-defined range $2 to $3.", - range2.start(), range2.end() - 1, - range1.start(), range1.end() - 1)); + "already-defined range $2 to $3.", + range2.start(), range2.end() - 1, + range1.start(), range1.end() - 1)); } } } @@ -4624,11 +4650,12 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, reserved_name_set.insert(name); } else { AddError(name, proto, DescriptorPool::ErrorCollector::NAME, - strings::Substitute( - "Field name \"$0\" is reserved multiple times.", name)); + strings::Substitute("Field name \"$0\" is reserved multiple times.", + name)); } } + for (int i = 0; i < result->field_count(); i++) { const FieldDescriptor* field = result->field(i); for (int j = 0; j < result->extension_range_count(); j++) { @@ -4648,7 +4675,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, AddError(field->full_name(), proto.reserved_range(j), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Field \"$0\" uses reserved number $1.", - field->name(), field->number())); + field->name(), field->number())); } } if (reserved_name_set.find(field->name()) != reserved_name_set.end()) { @@ -4657,10 +4684,11 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, DescriptorPool::ErrorCollector::NAME, strings::Substitute("Field name \"$0\" is reserved.", field->name())); } + } // Check that extension ranges don't overlap and don't include - // reserved field numbers. + // reserved field numbers or names. for (int i = 0; i < result->extension_range_count(); i++) { const Descriptor::ExtensionRange* range1 = result->extension_range(i); for (int j = 0; j < result->reserved_range_count(); j++) { @@ -4669,9 +4697,9 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, AddError(result->full_name(), proto.extension_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension range $0 to $1 overlaps with " - "reserved range $2 to $3.", - range1->start, range1->end - 1, - range2->start, range2->end - 1)); + "reserved range $2 to $3.", + range1->start, range1->end - 1, range2->start, + range2->end - 1)); } } for (int j = i + 1; j < result->extension_range_count(); j++) { @@ -4680,16 +4708,16 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, AddError(result->full_name(), proto.extension_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension range $0 to $1 overlaps with " - "already-defined range $2 to $3.", - range2->start, range2->end - 1, - range1->start, range1->end - 1)); + "already-defined range $2 to $3.", + range2->start, range2->end - 1, range1->start, + range1->end - 1)); } } } } void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, - const Descriptor* parent, + Descriptor* parent, FieldDescriptor* result, bool is_extension) { const std::string& scope = @@ -4702,6 +4730,15 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, result->file_ = file_; result->number_ = proto.number(); result->is_extension_ = is_extension; + result->proto3_optional_ = proto.proto3_optional(); + + if (proto.proto3_optional() && + file_->syntax() != FileDescriptor::SYNTAX_PROTO3) { + AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, + "The [proto3_optional=true] option may only be set on proto3" + "fields, not " + + result->full_name()); + } // If .proto files follow the style guide then the name should already be // lower-cased. If that's the case we can just reuse the string we @@ -4736,17 +4773,18 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, result->label_ = static_cast( implicit_cast(proto.label())); - // An extension cannot have a required field (b/13365836). - if (result->is_extension_ && - result->label_ == FieldDescriptor::LABEL_REQUIRED) { - AddError(result->full_name(), proto, - // Error location `TYPE`: we would really like to indicate - // `LABEL`, but the `ErrorLocation` enum has no entry for this, and - // we don't necessarily know about all implementations of the - // `ErrorCollector` interface to extend them to handle the new - // error location type properly. - DescriptorPool::ErrorCollector::TYPE, - "The extension " + result->full_name() + " cannot be required."); + if (result->label_ == FieldDescriptor::LABEL_REQUIRED) { + // An extension cannot have a required field (b/13365836). + if (result->is_extension_) { + AddError(result->full_name(), proto, + // Error location `TYPE`: we would really like to indicate + // `LABEL`, but the `ErrorLocation` enum has no entry for this, + // and we don't necessarily know about all implementations of the + // `ErrorCollector` interface to extend them to handle the new + // error location type properly. + DescriptorPool::ErrorCollector::TYPE, + "The extension " + result->full_name() + " cannot be required."); + } } // Some of these may be filled in when cross-linking. @@ -4910,7 +4948,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, // on extension numbers. AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Field numbers cannot be greater than $0.", - FieldDescriptor::kMaxNumber)); + FieldDescriptor::kMaxNumber)); } else if (result->number() >= FieldDescriptor::kFirstReservedNumber && result->number() <= FieldDescriptor::kLastReservedNumber) { AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, @@ -4953,8 +4991,8 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, strings::Substitute("FieldDescriptorProto.oneof_index $0 is " - "out of range for type \"$1\".", - proto.oneof_index(), parent->name())); + "out of range for type \"$1\".", + proto.oneof_index(), parent->name())); result->containing_oneof_ = nullptr; } else { result->containing_oneof_ = parent->oneof_decl(proto.oneof_index()); @@ -4965,9 +5003,8 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, } // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result, FieldDescriptorProto::kOptionsFieldNumber, "google.protobuf.FieldOptions"); @@ -4997,9 +5034,8 @@ void DescriptorBuilder::BuildExtensionRange( "Extension range end number must be greater than start number."); } - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { std::vector options_path; parent->GetLocationPath(&options_path); options_path.push_back(DescriptorProto::kExtensionRangeFieldNumber); @@ -5169,9 +5205,8 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, CheckEnumValueUniqueness(proto, result); // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result, EnumDescriptorProto::kOptionsFieldNumber, "google.protobuf.EnumOptions"); @@ -5189,9 +5224,9 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, AddError(result->full_name(), proto.reserved_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Reserved range $0 to $1 overlaps with " - "already-defined range $2 to $3.", - range2.start(), range2.end(), - range1.start(), range1.end())); + "already-defined range $2 to $3.", + range2.start(), range2.end(), range1.start(), + range1.end())); } } } @@ -5203,8 +5238,8 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, reserved_name_set.insert(name); } else { AddError(name, proto, DescriptorPool::ErrorCollector::NAME, - strings::Substitute( - "Enum value \"$0\" is reserved multiple times.", name)); + strings::Substitute("Enum value \"$0\" is reserved multiple times.", + name)); } } @@ -5213,11 +5248,10 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, for (int j = 0; j < result->reserved_range_count(); j++) { const EnumDescriptor::ReservedRange* range = result->reserved_range(j); if (range->start <= value->number() && value->number() <= range->end) { - AddError( - value->full_name(), proto.reserved_range(j), - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Enum value \"$0\" uses reserved number $1.", - value->name(), value->number())); + AddError(value->full_name(), proto.reserved_range(j), + DescriptorPool::ErrorCollector::NUMBER, + strings::Substitute("Enum value \"$0\" uses reserved number $1.", + value->name(), value->number())); } } if (reserved_name_set.find(value->name()) != reserved_name_set.end()) { @@ -5248,9 +5282,8 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, ValidateSymbolName(proto.name(), *full_name, proto); // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result, EnumValueDescriptorProto::kOptionsFieldNumber, "google.protobuf.EnumValueOptions"); @@ -5314,9 +5347,8 @@ void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto, BUILD_ARRAY(proto, result, method, BuildMethod, result); // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result, ServiceDescriptorProto::kOptionsFieldNumber, "google.protobuf.ServiceOptions"); @@ -5343,9 +5375,8 @@ void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto, result->output_type_.Init(); // Copy options. - if (!proto.has_options()) { - result->options_ = nullptr; // Will set to default_instance later. - } else { + result->options_ = nullptr; // Set to default_instance later if necessary. + if (proto.has_options()) { AllocateOptions(proto.options(), result, MethodDescriptorProto::kOptionsFieldNumber, "google.protobuf.MethodOptions"); @@ -5519,9 +5550,9 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field, AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("\"$0\" does not declare $1 as an " - "extension number.", - field->containing_type()->full_name(), - field->number())); + "extension number.", + field->containing_type()->full_name(), + field->number())); } } } @@ -5702,16 +5733,16 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field, AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension number $0 has already been used " - "in \"$1\" by extension \"$2\".", - field->number(), containing_type_name, - conflicting_field->full_name())); + "in \"$1\" by extension \"$2\".", + field->number(), containing_type_name, + conflicting_field->full_name())); } else { AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Field number $0 has already been used in " - "\"$1\" by field \"$2\".", - field->number(), containing_type_name, - conflicting_field->name())); + "\"$1\" by field \"$2\".", + field->number(), containing_type_name, + conflicting_field->name())); } } else { if (field->is_extension()) { @@ -5951,7 +5982,8 @@ void DescriptorBuilder::ValidateProto3Field(FieldDescriptor* field, } if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM && field->enum_type() && - field->enum_type()->file()->syntax() != FileDescriptor::SYNTAX_PROTO3) { + field->enum_type()->file()->syntax() != FileDescriptor::SYNTAX_PROTO3 && + field->enum_type()->file()->syntax() != FileDescriptor::SYNTAX_UNKNOWN) { // Proto3 messages can only use Proto3 enum types; otherwise we can't // guarantee that the default value is zero. AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, @@ -5988,12 +6020,15 @@ void DescriptorBuilder::ValidateMessageOptions(Descriptor* message, : FieldDescriptor::kMaxNumber); for (int i = 0; i < message->extension_range_count(); ++i) { if (message->extension_range(i)->end > max_extension_range + 1) { - AddError( - message->full_name(), proto.extension_range(i), - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Extension numbers cannot be greater than $0.", - max_extension_range)); + AddError(message->full_name(), proto.extension_range(i), + DescriptorPool::ErrorCollector::NUMBER, + strings::Substitute("Extension numbers cannot be greater than $0.", + max_extension_range)); } + + ValidateExtensionRangeOptions(message->full_name(), + message->extension_ranges_ + i, + proto.extension_range(i)); } } @@ -6108,6 +6143,12 @@ void DescriptorBuilder::ValidateEnumValueOptions( const EnumValueDescriptorProto& /* proto */) { // Nothing to do so far. } + +void DescriptorBuilder::ValidateExtensionRangeOptions( + const std::string& full_name, Descriptor::ExtensionRange* extension_range, + const DescriptorProto_ExtensionRange& proto) { +} + void DescriptorBuilder::ValidateServiceOptions( ServiceDescriptor* service, const ServiceDescriptorProto& proto) { if (IsLite(service->file()) && @@ -6303,6 +6344,7 @@ DescriptorBuilder::OptionInterpreter::OptionInterpreter( DescriptorBuilder::OptionInterpreter::~OptionInterpreter() {} + bool DescriptorBuilder::OptionInterpreter::InterpretOptions( OptionsToInterpret* options_to_interpret) { // Note that these may be in different pools, so we can't use the same @@ -6382,6 +6424,8 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions( options->GetReflection()->Swap(unparsed_options.get(), options); } } + + return !failed; } @@ -7170,13 +7214,20 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto, const FileDescriptor* result) { if (!unused_dependency_.empty()) { + auto itr = pool_->unused_import_track_files_.find(proto.name()); + bool is_error = + itr != pool_->unused_import_track_files_.end() && itr->second; for (std::set::const_iterator it = unused_dependency_.begin(); it != unused_dependency_.end(); ++it) { - // Log warnings for unused imported files. std::string error_message = "Import " + (*it)->name() + " is unused."; - AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT, + if (is_error) { + AddError((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT, error_message); + } else { + AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT, + error_message); + } } } } diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 8a75142debcc..e84bc3eac50e 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -54,14 +54,15 @@ #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__ #define GOOGLE_PROTOBUF_DESCRIPTOR_H__ +#include #include #include #include #include + #include #include #include - #include // TYPE_BOOL is defined in the MacOS's ConditionalMacros.h. @@ -277,6 +278,36 @@ class PROTOBUF_EXPORT Descriptor { // with AllowUnknownDependencies() set. bool is_placeholder() const; + enum WellKnownType { + WELLKNOWNTYPE_UNSPECIFIED, // Not a well-known type. + + // Wrapper types. + WELLKNOWNTYPE_DOUBLEVALUE, // google.protobuf.DoubleValue + WELLKNOWNTYPE_FLOATVALUE, // google.protobuf.FloatValue + WELLKNOWNTYPE_INT64VALUE, // google.protobuf.Int64Value + WELLKNOWNTYPE_UINT64VALUE, // google.protobuf.UInt64Value + WELLKNOWNTYPE_INT32VALUE, // google.protobuf.Int32Value + WELLKNOWNTYPE_UINT32VALUE, // google.protobuf.UInt32Value + WELLKNOWNTYPE_STRINGVALUE, // google.protobuf.StringValue + WELLKNOWNTYPE_BYTESVALUE, // google.protobuf.BytesValue + WELLKNOWNTYPE_BOOLVALUE, // google.protobuf.BoolValue + + // Other well known types. + WELLKNOWNTYPE_ANY, // google.protobuf.Any + WELLKNOWNTYPE_FIELDMASK, // google.protobuf.FieldMask + WELLKNOWNTYPE_DURATION, // google.protobuf.Duration + WELLKNOWNTYPE_TIMESTAMP, // google.protobuf.Timestamp + WELLKNOWNTYPE_VALUE, // google.protobuf.Value + WELLKNOWNTYPE_LISTVALUE, // google.protobuf.ListValue + WELLKNOWNTYPE_STRUCT, // google.protobuf.Struct + + // New well-known types may be added in the future. + // Please make sure any switch() statements have a 'default' case. + __WELLKNOWNTYPE__DO_NOT_USE__ADD_DEFAULT_INSTEAD__, + }; + + WellKnownType well_known_type() const; + // Field stuff ----------------------------------------------------- // The number of fields in this message type. @@ -372,8 +403,30 @@ class PROTOBUF_EXPORT Descriptor { // Returns nullptr if no extension range contains the given number. const ExtensionRange* FindExtensionRangeContainingNumber(int number) const; - // The number of extensions -- extending *other* messages -- that were - // defined nested within this message type's scope. + // The number of extensions defined nested within this message type's scope. + // See doc: + // https://developers.google.com/protocol-buffers/docs/proto#nested-extensions + // + // Note that the extensions may be extending *other* messages. + // + // For example: + // message M1 { + // extensions 1 to max; + // } + // + // message M2 { + // extend M1 { + // optional int32 foo = 1; + // } + // } + // + // In this case, + // DescriptorPool::generated_pool() + // ->FindMessageTypeByName("M2") + // ->extension(0) + // will return "foo", even though "foo" is an extension of M1. + // To find all known extensions of a given message, instead use + // DescriptorPool::FindAllExtensions. int extension_count() const; // Get an extension by index, where 0 <= index < extension_count(). // These are returned in the order they were defined in the .proto file. @@ -484,6 +537,8 @@ class PROTOBUF_EXPORT Descriptor { bool is_placeholder_; // True if this is a placeholder and the type name wasn't fully-qualified. bool is_unqualified_placeholder_; + // Well known type. Stored as char to conserve space. + char well_known_type_; // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate() and AllocateArray() in descriptor.cc @@ -629,6 +684,18 @@ class PROTOBUF_EXPORT FieldDescriptor { bool is_map() const; // shorthand for type() == TYPE_MESSAGE && // message_type()->options().map_entry() + // Returns true if this field was syntactically written with "optional" in the + // .proto file. Excludes singular proto3 fields that do not have a label. + bool has_optional_keyword() const; + + // Returns true if this is a non-oneof field that tracks presence. + // This includes all "required" and "optional" fields in the .proto file, + // but excludes oneof fields and singular proto3 fields without "optional". + // + // In implementations that use hasbits, this method will probably indicate + // whether this field uses a hasbit. + bool is_singular_with_presence() const; + // Index of this field within the message's field array, or the file or // extension scope's extensions array. int index() const; @@ -756,9 +823,7 @@ class PROTOBUF_EXPORT FieldDescriptor { void CopyJsonNameTo(FieldDescriptorProto* proto) const; // See Descriptor::DebugString(). - enum PrintLabelFlag { PRINT_LABEL, OMIT_LABEL }; - void DebugString(int depth, PrintLabelFlag print_label_flag, - std::string* contents, + void DebugString(int depth, std::string* contents, const DebugStringOptions& options) const; // formats the default value appropriately and returns it as a string. @@ -790,6 +855,7 @@ class PROTOBUF_EXPORT FieldDescriptor { mutable Type type_; Label label_; bool has_default_value_; + bool proto3_optional_; // Whether the user has specified the json_name field option in the .proto // file. bool has_json_name_; @@ -850,6 +916,10 @@ class PROTOBUF_EXPORT OneofDescriptor { // Index of this oneof within the message's oneof array. int index() const; + // Returns whether this oneof was inserted by the compiler to wrap a proto3 + // optional field. If this returns true, code generators should *not* emit it. + bool is_synthetic() const; + // The .proto file in which this oneof was defined. Never nullptr. const FileDescriptor* file() const; // The Descriptor for the message containing this oneof. @@ -1783,8 +1853,9 @@ class PROTOBUF_EXPORT DescriptorPool { bool InternalIsFileLoaded(const std::string& filename) const; // Add a file to unused_import_track_files_. DescriptorBuilder will log - // warnings for those files if there is any unused import. - void AddUnusedImportTrackFile(const std::string& file_name); + // warnings or errors for those files if there is any unused import. + void AddUnusedImportTrackFile(const std::string& file_name, + bool is_error = false); void ClearUnusedImportTrackFiles(); private: @@ -1868,7 +1939,10 @@ class PROTOBUF_EXPORT DescriptorPool { bool allow_unknown_; bool enforce_weak_; bool disallow_enforce_utf8_; - std::set unused_import_track_files_; + + // Set of files to track for unused imports. The bool value when true means + // unused imports are treated as errors (and as warnings when false). + std::map unused_import_track_files_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool); }; @@ -2013,6 +2087,10 @@ PROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, extension, // A few accessors differ from the macros... +inline Descriptor::WellKnownType Descriptor::well_known_type() const { + return static_cast(well_known_type_); +} + inline bool Descriptor::IsExtensionNumber(int number) const { return FindExtensionRangeContainingNumber(number) != nullptr; } @@ -2082,6 +2160,19 @@ inline bool FieldDescriptor::is_map() const { return type() == TYPE_MESSAGE && is_map_message_type(); } +inline bool FieldDescriptor::has_optional_keyword() const { + return proto3_optional_ || + (file()->syntax() == FileDescriptor::SYNTAX_PROTO2 && is_optional() && + !containing_oneof()); +} + +inline bool FieldDescriptor::is_singular_with_presence() const { + if (is_repeated()) return false; + if (containing_oneof() && !containing_oneof()->is_synthetic()) return false; + return cpp_type() == CPPTYPE_MESSAGE || proto3_optional_ || + file()->syntax() == FileDescriptor::SYNTAX_PROTO2; +} + // To save space, index() is computed by looking at the descriptor's position // in the parent's array of children. inline int FieldDescriptor::index() const { @@ -2110,6 +2201,10 @@ inline int OneofDescriptor::index() const { return static_cast(this - containing_type_->oneof_decls_); } +inline bool OneofDescriptor::is_synthetic() const { + return field_count() == 1 && field(0)->proto3_optional_; +} + inline int EnumDescriptor::index() const { if (containing_type_ == nullptr) { return static_cast(this - file_->enum_types_); diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index c15d76c8a60b..7989c56fb8e0 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -670,16 +670,18 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fdescriptor PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, oneof_index_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, json_name_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, options_), + PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, proto3_optional_), 0, 6, - 8, 9, + 10, 2, 1, 3, 7, 4, 5, + 8, PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _has_bits_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ @@ -783,14 +785,14 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fdescriptor 10, 11, 12, - 19, + 18, 2, 13, 14, 15, 16, 17, - 18, + 19, 3, 4, 5, @@ -958,27 +960,27 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB { 47, 54, sizeof(PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, { 56, 71, sizeof(PROTOBUF_NAMESPACE_ID::DescriptorProto)}, { 81, 87, sizeof(PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, - { 88, 103, sizeof(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, - { 113, 120, sizeof(PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, - { 122, 129, sizeof(PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, - { 131, 141, sizeof(PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, - { 146, 154, sizeof(PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, - { 157, 165, sizeof(PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, - { 168, 179, sizeof(PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, - { 185, 211, sizeof(PROTOBUF_NAMESPACE_ID::FileOptions)}, - { 232, 242, sizeof(PROTOBUF_NAMESPACE_ID::MessageOptions)}, - { 247, 259, sizeof(PROTOBUF_NAMESPACE_ID::FieldOptions)}, - { 266, 272, sizeof(PROTOBUF_NAMESPACE_ID::OneofOptions)}, - { 273, 281, sizeof(PROTOBUF_NAMESPACE_ID::EnumOptions)}, - { 284, 291, sizeof(PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, - { 293, 300, sizeof(PROTOBUF_NAMESPACE_ID::ServiceOptions)}, - { 302, 310, sizeof(PROTOBUF_NAMESPACE_ID::MethodOptions)}, - { 313, 320, sizeof(PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, - { 322, 334, sizeof(PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, - { 341, 351, sizeof(PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, - { 356, 362, sizeof(PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, - { 363, 372, sizeof(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, - { 376, 382, sizeof(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, + { 88, 104, sizeof(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, + { 115, 122, sizeof(PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, + { 124, 131, sizeof(PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, + { 133, 143, sizeof(PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, + { 148, 156, sizeof(PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, + { 159, 167, sizeof(PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, + { 170, 181, sizeof(PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, + { 187, 213, sizeof(PROTOBUF_NAMESPACE_ID::FileOptions)}, + { 234, 244, sizeof(PROTOBUF_NAMESPACE_ID::MessageOptions)}, + { 249, 261, sizeof(PROTOBUF_NAMESPACE_ID::FieldOptions)}, + { 268, 274, sizeof(PROTOBUF_NAMESPACE_ID::OneofOptions)}, + { 275, 283, sizeof(PROTOBUF_NAMESPACE_ID::EnumOptions)}, + { 286, 293, sizeof(PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, + { 295, 302, sizeof(PROTOBUF_NAMESPACE_ID::ServiceOptions)}, + { 304, 312, sizeof(PROTOBUF_NAMESPACE_ID::MethodOptions)}, + { 315, 322, sizeof(PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, + { 324, 336, sizeof(PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, + { 343, 353, sizeof(PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, + { 358, 364, sizeof(PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, + { 365, 374, sizeof(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, + { 378, 384, sizeof(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { @@ -1046,7 +1048,7 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR "s\032+\n\rReservedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end" "\030\002 \001(\005\"g\n\025ExtensionRangeOptions\022C\n\024unint" "erpreted_option\030\347\007 \003(\0132$.google.protobuf" - ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\274\005\n\024Fiel" + ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\325\005\n\024Fiel" "dDescriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number" "\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf." "FieldDescriptorProto.Label\0228\n\004type\030\005 \001(\016" @@ -1054,115 +1056,116 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR "Type\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(" "\t\022\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030" "\t \001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(" - "\0132\035.google.protobuf.FieldOptions\"\266\002\n\004Typ" - "e\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTY" - "PE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT3" - "2\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022" - "\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_" - "GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020" - "\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYP" - "E_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_" - "SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LA" - "BEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LA" - "BEL_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014" - "\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.p" - "rotobuf.OneofOptions\"\244\002\n\023EnumDescriptorP" - "roto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).goog" - "le.protobuf.EnumValueDescriptorProto\022-\n\007" - "options\030\003 \001(\0132\034.google.protobuf.EnumOpti" - "ons\022N\n\016reserved_range\030\004 \003(\01326.google.pro" - "tobuf.EnumDescriptorProto.EnumReservedRa" - "nge\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumReserv" - "edRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n\030E" - "numValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n" - "\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.google." - "protobuf.EnumValueOptions\"\220\001\n\026ServiceDes" - "criptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002 \003" - "(\0132&.google.protobuf.MethodDescriptorPro" - "to\0220\n\007options\030\003 \001(\0132\037.google.protobuf.Se" - "rviceOptions\"\301\001\n\025MethodDescriptorProto\022\014" - "\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013outp" - "ut_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.google." - "protobuf.MethodOptions\022\037\n\020client_streami" - "ng\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 \001(" - "\010:\005false\"\246\006\n\013FileOptions\022\024\n\014java_package" - "\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023" - "java_multiple_files\030\n \001(\010:\005false\022)\n\035java" - "_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n\026j" - "ava_string_check_utf8\030\033 \001(\010:\005false\022F\n\014op" - "timize_for\030\t \001(\0162).google.protobuf.FileO" - "ptions.OptimizeMode:\005SPEED\022\022\n\ngo_package" - "\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005fal" - "se\022$\n\025java_generic_services\030\021 \001(\010:\005false" - "\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#\n\024" - "php_generic_services\030* \001(\010:\005false\022\031\n\ndep" - "recated\030\027 \001(\010:\005false\022\037\n\020cc_enable_arenas" - "\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix\030$ \001(\t" - "\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pref" - "ix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rph" - "p_namespace\030) \001(\t\022\036\n\026php_metadata_namesp" - "ace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unint" - "erpreted_option\030\347\007 \003(\0132$.google.protobuf" - ".UninterpretedOption\":\n\014OptimizeMode\022\t\n\005" - "SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003" - "*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\362\001\n\016MessageOptions\022&\n\027" - "message_set_wire_format\030\001 \001(\010:\005false\022.\n\037" - "no_standard_descriptor_accessor\030\002 \001(\010:\005f" - "alse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_e" - "ntry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption*" - "\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022" - ":\n\005ctype\030\001 \001(\0162#.google.protobuf.FieldOp" - "tions.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006j" - "stype\030\006 \001(\0162$.google.protobuf.FieldOptio" - "ns.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005fals" - "e\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001" - "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013" - "2$.google.protobuf.UninterpretedOption\"/" - "\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_" - "PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_S" - "TRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"" - "^\n\014OneofOptions\022C\n\024uninterpreted_option\030" + "\0132\035.google.protobuf.FieldOptions\022\027\n\017prot" + "o3_optional\030\021 \001(\010\"\266\002\n\004Type\022\017\n\013TYPE_DOUBL" + "E\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT64\020\003\022\017\n\013T" + "YPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014TYPE_FIX" + "ED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE_BOOL\020\010\022" + "\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n\022\020\n\014TYPE" + "_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TYPE_UINT3" + "2\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXED32\020\017\022\021\n" + "\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020\021\022\017\n\013TYP" + "E_SINT64\020\022\"C\n\005Label\022\022\n\016LABEL_OPTIONAL\020\001\022" + "\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABEL_REPEATED\020\003\"" + "T\n\024OneofDescriptorProto\022\014\n\004name\030\001 \001(\t\022.\n" + "\007options\030\002 \001(\0132\035.google.protobuf.OneofOp" + "tions\"\244\002\n\023EnumDescriptorProto\022\014\n\004name\030\001 " + "\001(\t\0228\n\005value\030\002 \003(\0132).google.protobuf.Enu" + "mValueDescriptorProto\022-\n\007options\030\003 \001(\0132\034" + ".google.protobuf.EnumOptions\022N\n\016reserved" + "_range\030\004 \003(\01326.google.protobuf.EnumDescr" + "iptorProto.EnumReservedRange\022\025\n\rreserved" + "_name\030\005 \003(\t\032/\n\021EnumReservedRange\022\r\n\005star" + "t\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n\030EnumValueDescrip" + "torProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\0222" + "\n\007options\030\003 \001(\0132!.google.protobuf.EnumVa" + "lueOptions\"\220\001\n\026ServiceDescriptorProto\022\014\n" + "\004name\030\001 \001(\t\0226\n\006method\030\002 \003(\0132&.google.pro" + "tobuf.MethodDescriptorProto\0220\n\007options\030\003" + " \001(\0132\037.google.protobuf.ServiceOptions\"\301\001" + "\n\025MethodDescriptorProto\022\014\n\004name\030\001 \001(\t\022\022\n" + "\ninput_type\030\002 \001(\t\022\023\n\013output_type\030\003 \001(\t\022/" + "\n\007options\030\004 \001(\0132\036.google.protobuf.Method" + "Options\022\037\n\020client_streaming\030\005 \001(\010:\005false" + "\022\037\n\020server_streaming\030\006 \001(\010:\005false\"\245\006\n\013Fi" + "leOptions\022\024\n\014java_package\030\001 \001(\t\022\034\n\024java_" + "outer_classname\030\010 \001(\t\022\"\n\023java_multiple_f" + "iles\030\n \001(\010:\005false\022)\n\035java_generate_equal" + "s_and_hash\030\024 \001(\010B\002\030\001\022%\n\026java_string_chec" + "k_utf8\030\033 \001(\010:\005false\022F\n\014optimize_for\030\t \001(" + "\0162).google.protobuf.FileOptions.Optimize" + "Mode:\005SPEED\022\022\n\ngo_package\030\013 \001(\t\022\"\n\023cc_ge" + "neric_services\030\020 \001(\010:\005false\022$\n\025java_gene" + "ric_services\030\021 \001(\010:\005false\022\"\n\023py_generic_" + "services\030\022 \001(\010:\005false\022#\n\024php_generic_ser" + "vices\030* \001(\010:\005false\022\031\n\ndeprecated\030\027 \001(\010:\005" + "false\022\036\n\020cc_enable_arenas\030\037 \001(\010:\004true\022\031\n" + "\021objc_class_prefix\030$ \001(\t\022\030\n\020csharp_names" + "pace\030% \001(\t\022\024\n\014swift_prefix\030\' \001(\t\022\030\n\020php_" + "class_prefix\030( \001(\t\022\025\n\rphp_namespace\030) \001(" + "\t\022\036\n\026php_metadata_namespace\030, \001(\t\022\024\n\014rub" + "y_package\030- \001(\t\022C\n\024uninterpreted_option\030" "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" - "tion*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow" - "_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" - "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." - "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J" - "\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030" - "\001 \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " - "\003(\0132$.google.protobuf.UninterpretedOptio" - "n*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprec" - "ated\030! \001(\010:\005false\022C\n\024uninterpreted_optio" - "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" - "Option*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\nd" - "eprecated\030! \001(\010:\005false\022_\n\021idempotency_le" - "vel\030\" \001(\0162/.google.protobuf.MethodOption" - "s.IdempotencyLevel:\023IDEMPOTENCY_UNKNOWN\022" + "tion\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_" + "SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020" + "\'\"\362\001\n\016MessageOptions\022&\n\027message_set_wire" + "_format\030\001 \001(\010:\005false\022.\n\037no_standard_desc" + "riptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprecat" + "ed\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024un" + "interpreted_option\030\347\007 \003(\0132$.google.proto" + "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t" + "J\004\010\t\020\n\"\236\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#" + ".google.protobuf.FieldOptions.CType:\006STR" + "ING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.go" + "ogle.protobuf.FieldOptions.JSType:\tJS_NO" + "RMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndeprecated\030" + "\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024uni" + "nterpreted_option\030\347\007 \003(\0132$.google.protob" + "uf.UninterpretedOption\"/\n\005CType\022\n\n\006STRIN" + "G\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSTyp" + "e\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NU" + "MBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022" "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." - "protobuf.UninterpretedOption\"P\n\020Idempote" - "ncyLevel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_" - "SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200" - "\002\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(\0132" - "-.google.protobuf.UninterpretedOption.Na" - "mePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022posi" - "tive_int_value\030\004 \001(\004\022\032\n\022negative_int_val" - "ue\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string" - "_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n" - "\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_exten" - "sion\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010locatio" - "n\030\001 \003(\0132(.google.protobuf.SourceCodeInfo" - ".Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001" - "\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003" - " \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leadi" - "ng_detached_comments\030\006 \003(\t\"\247\001\n\021Generated" - "CodeInfo\022A\n\nannotation\030\001 \003(\0132-.google.pr" - "otobuf.GeneratedCodeInfo.Annotation\032O\n\nA" - "nnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_fi" - "le\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\217\001\n" - "\023com.google.protobufB\020DescriptorProtosH\001" - "Z>github.com/golang/protobuf/protoc-gen-" - "go/descriptor;descriptor\370\001\001\242\002\003GPB\252\002\032Goog" - "le.Protobuf.Reflection" + "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"" + "\223\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\n" + "deprecated\030\003 \001(\010:\005false\022C\n\024uninterpreted" + "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" + "pretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumVal" + "ueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016" + "ServiceOptions\022\031\n\ndeprecated\030! \001(\010:\005fals" + "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" + "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" + "\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecated\030! \001(\010:" + "\005false\022_\n\021idempotency_level\030\" \001(\0162/.goog" + "le.protobuf.MethodOptions.IdempotencyLev" + "el:\023IDEMPOTENCY_UNKNOWN\022C\n\024uninterpreted" + "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" + "pretedOption\"P\n\020IdempotencyLevel\022\027\n\023IDEM" + "POTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016" + "\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterpre" + "tedOption\022;\n\004name\030\002 \003(\0132-.google.protobu" + "f.UninterpretedOption.NamePart\022\030\n\020identi" + "fier_value\030\003 \001(\t\022\032\n\022positive_int_value\030\004" + " \001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014doub" + "le_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017" + "aggregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tnam" + "e_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016S" + "ourceCodeInfo\022:\n\010location\030\001 \003(\0132(.google" + ".protobuf.SourceCodeInfo.Location\032\206\001\n\010Lo" + "cation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002" + "\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021trailing" + "_comments\030\004 \001(\t\022!\n\031leading_detached_comm" + "ents\030\006 \003(\t\"\247\001\n\021GeneratedCodeInfo\022A\n\nanno" + "tation\030\001 \003(\0132-.google.protobuf.Generated" + "CodeInfo.Annotation\032O\n\nAnnotation\022\020\n\004pat" + "h\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begi" + "n\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\217\001\n\023com.google.prot" + "obufB\020DescriptorProtosH\001Z>github.com/gol" + "ang/protobuf/protoc-gen-go/descriptor;de" + "scriptor\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Refl" + "ection" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps[1] = { }; @@ -1196,9 +1199,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", 6022, + false, false, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", 6046, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_sccs, descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps, 27, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, 27, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, @@ -1385,14 +1387,8 @@ class FileDescriptorSet::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -FileDescriptorSet::FileDescriptorSet() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet) -} FileDescriptorSet::FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), file_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -1400,10 +1396,9 @@ FileDescriptorSet::FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena) } FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), file_(from.file_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet) } @@ -1414,10 +1409,11 @@ void FileDescriptorSet::SharedCtor() { FileDescriptorSet::~FileDescriptorSet() { // @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorSet) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FileDescriptorSet::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void FileDescriptorSet::ArenaDtor(void* object) { @@ -1443,12 +1439,12 @@ void FileDescriptorSet::Clear() { file_.Clear(); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FileDescriptorSet::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1472,7 +1468,9 @@ const char* FileDescriptorSet::_InternalParse(const char* ptr, ::PROTOBUF_NAMESP ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1502,7 +1500,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FileDescriptorSet::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorSet) return target; @@ -1550,7 +1548,7 @@ void FileDescriptorSet::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1578,7 +1576,7 @@ bool FileDescriptorSet::IsInitialized() const { void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); file_.InternalSwap(&other->file_); } @@ -1626,40 +1624,8 @@ const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::_Internal::source_code_info(const FileDescriptorProto* msg) { return *msg->source_code_info_; } -void FileDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::FileOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000008u; - } else { - _has_bits_[0] &= ~0x00000008u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.options) -} -void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info( - PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { - if (GetArenaNoVirtual() == nullptr) { - delete source_code_info_; - } - source_code_info_ = source_code_info; - if (source_code_info) { - _has_bits_[0] |= 0x00000010u; - } else { - _has_bits_[0] &= ~0x00000010u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) -} -FileDescriptorProto::FileDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto) -} FileDescriptorProto::FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), dependency_(arena), message_type_(arena), enum_type_(arena), @@ -1673,7 +1639,6 @@ FileDescriptorProto::FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) } FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), dependency_(from.dependency_), message_type_(from.message_type_), @@ -1682,21 +1647,21 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) extension_(from.extension_), public_dependency_(from.public_dependency_), weak_dependency_(from.weak_dependency_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_package()) { package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_package(), - GetArenaNoVirtual()); + GetArena()); } syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_syntax()) { syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_syntax(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::FileOptions(*from.options_); @@ -1724,10 +1689,11 @@ void FileDescriptorProto::SharedCtor() { FileDescriptorProto::~FileDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FileDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -1784,13 +1750,13 @@ void FileDescriptorProto::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1943,7 +1909,9 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -2067,7 +2035,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FileDescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorProto) return target; @@ -2200,7 +2168,7 @@ void FileDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2258,7 +2226,7 @@ bool FileDescriptorProto::IsInitialized() const { void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); dependency_.InternalSwap(&other->dependency_); message_type_.InternalSwap(&other->message_type_); @@ -2267,14 +2235,15 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { extension_.InternalSwap(&other->extension_); public_dependency_.InternalSwap(&other->public_dependency_); weak_dependency_.InternalSwap(&other->weak_dependency_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - package_.Swap(&other->package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - syntax_.Swap(&other->syntax_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(options_, other->options_); - swap(source_code_info_, other->source_code_info_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + package_.Swap(&other->package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + syntax_.Swap(&other->syntax_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(FileDescriptorProto, source_code_info_) + + sizeof(FileDescriptorProto::source_code_info_) + - PROTOBUF_FIELD_OFFSET(FileDescriptorProto, options_)>( + reinterpret_cast(&options_), + reinterpret_cast(&other->options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const { @@ -2307,36 +2276,16 @@ const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::_Internal::options(const DescriptorProto_ExtensionRange* msg) { return *msg->options_; } -void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) -} -DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange) -} DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ExtensionRange) } DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions(*from.options_); } else { @@ -2358,10 +2307,11 @@ void DescriptorProto_ExtensionRange::SharedCtor() { DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ExtensionRange) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void DescriptorProto_ExtensionRange::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); if (this != internal_default_instance()) delete options_; } @@ -2397,13 +2347,13 @@ void DescriptorProto_ExtensionRange::Clear() { reinterpret_cast(&start_)) + sizeof(end_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -2438,7 +2388,9 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -2482,7 +2434,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* DescriptorProto_ExtensionRange::_InternalSeriali if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ExtensionRange) return target; @@ -2547,7 +2499,7 @@ void DescriptorProto_ExtensionRange::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Me void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2589,11 +2541,14 @@ bool DescriptorProto_ExtensionRange::IsInitialized() const { void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - swap(options_, other->options_); - swap(start_, other->start_); - swap(end_, other->end_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_) + + sizeof(DescriptorProto_ExtensionRange::end_) + - PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, options_)>( + reinterpret_cast(&options_), + reinterpret_cast(&other->options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { @@ -2616,23 +2571,16 @@ class DescriptorProto_ReservedRange::_Internal { } }; -DescriptorProto_ReservedRange::DescriptorProto_ReservedRange() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange) -} DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ReservedRange) } DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&start_, &from.start_, static_cast(reinterpret_cast(&end_) - reinterpret_cast(&start_)) + sizeof(end_)); @@ -2648,10 +2596,11 @@ void DescriptorProto_ReservedRange::SharedCtor() { DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ReservedRange) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void DescriptorProto_ReservedRange::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void DescriptorProto_ReservedRange::ArenaDtor(void* object) { @@ -2682,13 +2631,13 @@ void DescriptorProto_ReservedRange::Clear() { reinterpret_cast(&start_)) + sizeof(end_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -2716,7 +2665,9 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -2752,7 +2703,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* DescriptorProto_ReservedRange::_InternalSerializ if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ReservedRange) return target; @@ -2810,7 +2761,7 @@ void DescriptorProto_ReservedRange::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Mes void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2846,10 +2797,14 @@ bool DescriptorProto_ReservedRange::IsInitialized() const { void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - swap(start_, other->start_); - swap(end_, other->end_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, end_) + + sizeof(DescriptorProto_ReservedRange::end_) + - PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, start_)>( + reinterpret_cast(&start_), + reinterpret_cast(&other->start_)); } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const { @@ -2879,27 +2834,8 @@ const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::_Internal::options(const DescriptorProto* msg) { return *msg->options_; } -void DescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::MessageOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.options) -} -DescriptorProto::DescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto) -} DescriptorProto::DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), field_(arena), nested_type_(arena), enum_type_(arena), @@ -2914,7 +2850,6 @@ DescriptorProto::DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) } DescriptorProto::DescriptorProto(const DescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), field_(from.field_), nested_type_(from.nested_type_), @@ -2924,11 +2859,11 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from) oneof_decl_(from.oneof_decl_), reserved_range_(from.reserved_range_), reserved_name_(from.reserved_name_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::MessageOptions(*from.options_); @@ -2947,10 +2882,11 @@ void DescriptorProto::SharedCtor() { DescriptorProto::~DescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void DescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -2995,13 +2931,13 @@ void DescriptorProto::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -3131,7 +3067,9 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -3239,7 +3177,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* DescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto) return target; @@ -3354,7 +3292,7 @@ void DescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void DescriptorProto::MergeFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -3406,7 +3344,7 @@ bool DescriptorProto::IsInitialized() const { void DescriptorProto::InternalSwap(DescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); field_.InternalSwap(&other->field_); nested_type_.InternalSwap(&other->nested_type_); @@ -3416,8 +3354,7 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { oneof_decl_.InternalSwap(&other->oneof_decl_); reserved_range_.InternalSwap(&other->reserved_range_); reserved_name_.InternalSwap(&other->reserved_name_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(options_, other->options_); } @@ -3435,15 +3372,9 @@ class ExtensionRangeOptions::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -ExtensionRangeOptions::ExtensionRangeOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.ExtensionRangeOptions) -} ExtensionRangeOptions::ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -3451,10 +3382,9 @@ ExtensionRangeOptions::ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* are } ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); // @@protoc_insertion_point(copy_constructor:google.protobuf.ExtensionRangeOptions) } @@ -3466,10 +3396,11 @@ void ExtensionRangeOptions::SharedCtor() { ExtensionRangeOptions::~ExtensionRangeOptions() { // @@protoc_insertion_point(destructor:google.protobuf.ExtensionRangeOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void ExtensionRangeOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void ExtensionRangeOptions::ArenaDtor(void* object) { @@ -3496,12 +3427,12 @@ void ExtensionRangeOptions::Clear() { _extensions_.Clear(); uninterpreted_option_.Clear(); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -3531,7 +3462,9 @@ const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::PROTOBUF_NA CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -3565,7 +3498,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* ExtensionRangeOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ExtensionRangeOptions) return target; @@ -3616,7 +3549,7 @@ void ExtensionRangeOptions::MergeFrom(const ExtensionRangeOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -3649,7 +3582,7 @@ bool ExtensionRangeOptions::IsInitialized() const { void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); } @@ -3675,10 +3608,10 @@ class FieldDescriptorProto::_Internal { (*has_bits)[0] |= 64u; } static void set_has_label(HasBits* has_bits) { - (*has_bits)[0] |= 256u; + (*has_bits)[0] |= 512u; } static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 512u; + (*has_bits)[0] |= 1024u; } static void set_has_type_name(HasBits* has_bits) { (*has_bits)[0] |= 4u; @@ -3699,66 +3632,49 @@ class FieldDescriptorProto::_Internal { static void set_has_options(HasBits* has_bits) { (*has_bits)[0] |= 32u; } + static void set_has_proto3_optional(HasBits* has_bits) { + (*has_bits)[0] |= 256u; + } }; const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::_Internal::options(const FieldDescriptorProto* msg) { return *msg->options_; } -void FieldDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::FieldOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000020u; - } else { - _has_bits_[0] &= ~0x00000020u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.options) -} -FieldDescriptorProto::FieldDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto) -} FieldDescriptorProto::FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldDescriptorProto) } FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_extendee()) { extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_extendee(), - GetArenaNoVirtual()); + GetArena()); } type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_type_name()) { type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type_name(), - GetArenaNoVirtual()); + GetArena()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_default_value()) { default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_default_value(), - GetArenaNoVirtual()); + GetArena()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_json_name()) { json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_json_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::FieldOptions(*from.options_); @@ -3779,8 +3695,8 @@ void FieldDescriptorProto::SharedCtor() { default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ::memset(&options_, 0, static_cast( - reinterpret_cast(&oneof_index_) - - reinterpret_cast(&options_)) + sizeof(oneof_index_)); + reinterpret_cast(&proto3_optional_) - + reinterpret_cast(&options_)) + sizeof(proto3_optional_)); label_ = 1; type_ = 1; } @@ -3788,10 +3704,11 @@ void FieldDescriptorProto::SharedCtor() { FieldDescriptorProto::~FieldDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.FieldDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FieldDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -3848,18 +3765,19 @@ void FieldDescriptorProto::Clear() { reinterpret_cast(&oneof_index_) - reinterpret_cast(&number_)) + sizeof(oneof_index_)); } - if (cached_has_bits & 0x00000300u) { + if (cached_has_bits & 0x00000700u) { + proto3_optional_ = false; label_ = 1; type_ = 1; } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -3967,13 +3885,23 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM CHK_(ptr); } else goto handle_unusual; continue; + // optional bool proto3_optional = 17; + case 17: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 136)) { + _Internal::set_has_proto3_optional(&has_bits); + proto3_optional_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; default: { handle_unusual: if ((tag & 7) == 4 || tag == 0) { ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -4022,14 +3950,14 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FieldDescriptorProto::_InternalSerialize( } // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( 4, this->_internal_label(), target); } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( 5, this->_internal_type(), target); @@ -4079,9 +4007,15 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FieldDescriptorProto::_InternalSerialize( 10, this->_internal_json_name(), target); } + // optional bool proto3_optional = 17; + if (cached_has_bits & 0x00000100u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(17, this->_internal_proto3_optional(), target); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldDescriptorProto) return target; @@ -4154,15 +4088,20 @@ size_t FieldDescriptorProto::ByteSizeLong() const { } } - if (cached_has_bits & 0x00000300u) { - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; + if (cached_has_bits & 0x00000700u) { + // optional bool proto3_optional = 17; if (cached_has_bits & 0x00000100u) { + total_size += 2 + 1; + } + + // optional .google.protobuf.FieldDescriptorProto.Label label = 4; + if (cached_has_bits & 0x00000200u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_label()); } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); } @@ -4195,7 +4134,7 @@ void FieldDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& fro void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -4227,11 +4166,14 @@ void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { } _has_bits_[0] |= cached_has_bits; } - if (cached_has_bits & 0x00000300u) { + if (cached_has_bits & 0x00000700u) { if (cached_has_bits & 0x00000100u) { - label_ = from.label_; + proto3_optional_ = from.proto3_optional_; } if (cached_has_bits & 0x00000200u) { + label_ = from.label_; + } + if (cached_has_bits & 0x00000400u) { type_ = from.type_; } _has_bits_[0] |= cached_has_bits; @@ -4261,21 +4203,19 @@ bool FieldDescriptorProto::IsInitialized() const { void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - extendee_.Swap(&other->extendee_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - type_name_.Swap(&other->type_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(options_, other->options_); - swap(number_, other->number_); - swap(oneof_index_, other->oneof_index_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + extendee_.Swap(&other->extendee_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + type_name_.Swap(&other->type_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, proto3_optional_) + + sizeof(FieldDescriptorProto::proto3_optional_) + - PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, options_)>( + reinterpret_cast(&options_), + reinterpret_cast(&other->options_)); swap(label_, other->label_); swap(type_, other->type_); } @@ -4307,40 +4247,20 @@ const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::_Internal::options(const OneofDescriptorProto* msg) { return *msg->options_; } -void OneofDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::OneofOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.options) -} -OneofDescriptorProto::OneofDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto) -} OneofDescriptorProto::OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.OneofDescriptorProto) } OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::OneofOptions(*from.options_); @@ -4359,10 +4279,11 @@ void OneofDescriptorProto::SharedCtor() { OneofDescriptorProto::~OneofDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.OneofDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void OneofDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -4399,13 +4320,13 @@ void OneofDescriptorProto::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -4435,7 +4356,9 @@ const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -4477,7 +4400,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* OneofDescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofDescriptorProto) return target; @@ -4535,7 +4458,7 @@ void OneofDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& fro void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -4573,10 +4496,9 @@ bool OneofDescriptorProto::IsInitialized() const { void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(options_, other->options_); } @@ -4600,23 +4522,16 @@ class EnumDescriptorProto_EnumReservedRange::_Internal { } }; -EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) -} EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) } EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&start_, &from.start_, static_cast(reinterpret_cast(&end_) - reinterpret_cast(&start_)) + sizeof(end_)); @@ -4632,10 +4547,11 @@ void EnumDescriptorProto_EnumReservedRange::SharedCtor() { EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() { // @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void EnumDescriptorProto_EnumReservedRange::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) { @@ -4666,13 +4582,13 @@ void EnumDescriptorProto_EnumReservedRange::Clear() { reinterpret_cast(&start_)) + sizeof(end_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -4700,7 +4616,9 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -4736,7 +4654,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* EnumDescriptorProto_EnumReservedRange::_Internal if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto.EnumReservedRange) return target; @@ -4794,7 +4712,7 @@ void EnumDescriptorProto_EnumReservedRange::MergeFrom(const ::PROTOBUF_NAMESPACE void EnumDescriptorProto_EnumReservedRange::MergeFrom(const EnumDescriptorProto_EnumReservedRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -4830,10 +4748,14 @@ bool EnumDescriptorProto_EnumReservedRange::IsInitialized() const { void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_EnumReservedRange* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - swap(start_, other->start_); - swap(end_, other->end_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, end_) + + sizeof(EnumDescriptorProto_EnumReservedRange::end_) + - PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, start_)>( + reinterpret_cast(&start_), + reinterpret_cast(&other->start_)); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const { @@ -4863,27 +4785,8 @@ const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::_Internal::options(const EnumDescriptorProto* msg) { return *msg->options_; } -void EnumDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::EnumOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.options) -} -EnumDescriptorProto::EnumDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto) -} EnumDescriptorProto::EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), value_(arena), reserved_range_(arena), reserved_name_(arena) { @@ -4893,16 +4796,15 @@ EnumDescriptorProto::EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) } EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), value_(from.value_), reserved_range_(from.reserved_range_), reserved_name_(from.reserved_name_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::EnumOptions(*from.options_); @@ -4921,10 +4823,11 @@ void EnumDescriptorProto::SharedCtor() { EnumDescriptorProto::~EnumDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void EnumDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -4964,13 +4867,13 @@ void EnumDescriptorProto::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -5040,7 +4943,9 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -5108,7 +5013,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* EnumDescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto) return target; @@ -5188,7 +5093,7 @@ void EnumDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -5230,13 +5135,12 @@ bool EnumDescriptorProto::IsInitialized() const { void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); value_.InternalSwap(&other->value_); reserved_range_.InternalSwap(&other->reserved_range_); reserved_name_.InternalSwap(&other->reserved_name_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(options_, other->options_); } @@ -5270,40 +5174,20 @@ const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::_Internal::options(const EnumValueDescriptorProto* msg) { return *msg->options_; } -void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.options) -} -EnumValueDescriptorProto::EnumValueDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto) -} EnumValueDescriptorProto::EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueDescriptorProto) } EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from.options_); @@ -5325,10 +5209,11 @@ void EnumValueDescriptorProto::SharedCtor() { EnumValueDescriptorProto::~EnumValueDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.EnumValueDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void EnumValueDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -5366,13 +5251,13 @@ void EnumValueDescriptorProto::Clear() { } number_ = 0; _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -5410,7 +5295,9 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -5458,7 +5345,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* EnumValueDescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueDescriptorProto) return target; @@ -5523,7 +5410,7 @@ void EnumValueDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -5565,12 +5452,15 @@ bool EnumValueDescriptorProto::IsInitialized() const { void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(options_, other->options_); - swap(number_, other->number_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, number_) + + sizeof(EnumValueDescriptorProto::number_) + - PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, options_)>( + reinterpret_cast(&options_), + reinterpret_cast(&other->options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const { @@ -5600,27 +5490,8 @@ const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::_Internal::options(const ServiceDescriptorProto* msg) { return *msg->options_; } -void ServiceDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.options) -} -ServiceDescriptorProto::ServiceDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto) -} ServiceDescriptorProto::ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), method_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -5628,14 +5499,13 @@ ServiceDescriptorProto::ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* a } ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), method_(from.method_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::ServiceOptions(*from.options_); @@ -5654,10 +5524,11 @@ void ServiceDescriptorProto::SharedCtor() { ServiceDescriptorProto::~ServiceDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.ServiceDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void ServiceDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -5695,13 +5566,13 @@ void ServiceDescriptorProto::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -5743,7 +5614,9 @@ const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_N ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -5793,7 +5666,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* ServiceDescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceDescriptorProto) return target; @@ -5858,7 +5731,7 @@ void ServiceDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& f void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -5898,11 +5771,10 @@ bool ServiceDescriptorProto::IsInitialized() const { void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); method_.InternalSwap(&other->method_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(options_, other->options_); } @@ -5945,50 +5817,30 @@ const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::_Internal::options(const MethodDescriptorProto* msg) { return *msg->options_; } -void MethodDescriptorProto::unsafe_arena_set_allocated_options( - PROTOBUF_NAMESPACE_ID::MethodOptions* options) { - if (GetArenaNoVirtual() == nullptr) { - delete options_; - } - options_ = options; - if (options) { - _has_bits_[0] |= 0x00000008u; - } else { - _has_bits_[0] &= ~0x00000008u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.options) -} -MethodDescriptorProto::MethodDescriptorProto() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto) -} MethodDescriptorProto::MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.MethodDescriptorProto) } MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_input_type()) { input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_input_type(), - GetArenaNoVirtual()); + GetArena()); } output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_output_type()) { output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_output_type(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::MethodOptions(*from.options_); @@ -6014,10 +5866,11 @@ void MethodDescriptorProto::SharedCtor() { MethodDescriptorProto::~MethodDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.MethodDescriptorProto) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void MethodDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); output_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -6065,13 +5918,13 @@ void MethodDescriptorProto::Clear() { reinterpret_cast(&server_streaming_) - reinterpret_cast(&client_streaming_)) + sizeof(server_streaming_)); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -6139,7 +5992,9 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -6213,7 +6068,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* MethodDescriptorProto::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodDescriptorProto) return target; @@ -6295,7 +6150,7 @@ void MethodDescriptorProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& fr void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -6346,17 +6201,17 @@ bool MethodDescriptorProto::IsInitialized() const { void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - input_type_.Swap(&other->input_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - output_type_.Swap(&other->output_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(options_, other->options_); - swap(client_streaming_, other->client_streaming_); - swap(server_streaming_, other->server_streaming_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + input_type_.Swap(&other->input_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + output_type_.Swap(&other->output_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, server_streaming_) + + sizeof(MethodDescriptorProto::server_streaming_) + - PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, options_)>( + reinterpret_cast(&options_), + reinterpret_cast(&other->options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const { @@ -6387,7 +6242,7 @@ class FileOptions::_Internal { (*has_bits)[0] |= 4096u; } static void set_has_optimize_for(HasBits* has_bits) { - (*has_bits)[0] |= 524288u; + (*has_bits)[0] |= 262144u; } static void set_has_go_package(HasBits* has_bits) { (*has_bits)[0] |= 4u; @@ -6408,7 +6263,7 @@ class FileOptions::_Internal { (*has_bits)[0] |= 131072u; } static void set_has_cc_enable_arenas(HasBits* has_bits) { - (*has_bits)[0] |= 262144u; + (*has_bits)[0] |= 524288u; } static void set_has_objc_class_prefix(HasBits* has_bits) { (*has_bits)[0] |= 8u; @@ -6433,15 +6288,9 @@ class FileOptions::_Internal { } }; -FileOptions::FileOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FileOptions) -} FileOptions::FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -6449,64 +6298,63 @@ FileOptions::FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } FileOptions::FileOptions(const FileOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_java_package()) { java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_java_package(), - GetArenaNoVirtual()); + GetArena()); } java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_java_outer_classname()) { java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_java_outer_classname(), - GetArenaNoVirtual()); + GetArena()); } go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_go_package()) { go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_go_package(), - GetArenaNoVirtual()); + GetArena()); } objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_objc_class_prefix()) { objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_objc_class_prefix(), - GetArenaNoVirtual()); + GetArena()); } csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_csharp_namespace()) { csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_csharp_namespace(), - GetArenaNoVirtual()); + GetArena()); } swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_swift_prefix()) { swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_swift_prefix(), - GetArenaNoVirtual()); + GetArena()); } php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_php_class_prefix()) { php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_php_class_prefix(), - GetArenaNoVirtual()); + GetArena()); } php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_php_namespace()) { php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_php_namespace(), - GetArenaNoVirtual()); + GetArena()); } php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_php_metadata_namespace()) { php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_php_metadata_namespace(), - GetArenaNoVirtual()); + GetArena()); } ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_ruby_package()) { ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_ruby_package(), - GetArenaNoVirtual()); + GetArena()); } ::memcpy(&java_multiple_files_, &from.java_multiple_files_, - static_cast(reinterpret_cast(&optimize_for_) - - reinterpret_cast(&java_multiple_files_)) + sizeof(optimize_for_)); + static_cast(reinterpret_cast(&cc_enable_arenas_) - + reinterpret_cast(&java_multiple_files_)) + sizeof(cc_enable_arenas_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } @@ -6523,18 +6371,20 @@ void FileOptions::SharedCtor() { php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ::memset(&java_multiple_files_, 0, static_cast( - reinterpret_cast(&cc_enable_arenas_) - - reinterpret_cast(&java_multiple_files_)) + sizeof(cc_enable_arenas_)); + reinterpret_cast(&deprecated_) - + reinterpret_cast(&java_multiple_files_)) + sizeof(deprecated_)); optimize_for_ = 1; + cc_enable_arenas_ = true; } FileOptions::~FileOptions() { // @@protoc_insertion_point(destructor:google.protobuf.FileOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FileOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); java_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); go_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -6612,18 +6462,19 @@ void FileOptions::Clear() { } if (cached_has_bits & 0x000f0000u) { ::memset(&php_generic_services_, 0, static_cast( - reinterpret_cast(&cc_enable_arenas_) - - reinterpret_cast(&php_generic_services_)) + sizeof(cc_enable_arenas_)); + reinterpret_cast(&deprecated_) - + reinterpret_cast(&php_generic_services_)) + sizeof(deprecated_)); optimize_for_ = 1; + cc_enable_arenas_ = true; } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -6730,7 +6581,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID CHK_(ptr); } else goto handle_unusual; continue; - // optional bool cc_enable_arenas = 31 [default = false]; + // optional bool cc_enable_arenas = 31 [default = true]; case 31: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 248)) { _Internal::set_has_cc_enable_arenas(&has_bits); @@ -6847,7 +6698,9 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -6890,7 +6743,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FileOptions::_InternalSerialize( } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (cached_has_bits & 0x00080000u) { + if (cached_has_bits & 0x00040000u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( 9, this->_internal_optimize_for(), target); @@ -6948,8 +6801,8 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FileOptions::_InternalSerialize( target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(27, this->_internal_java_string_check_utf8(), target); } - // optional bool cc_enable_arenas = 31 [default = false]; - if (cached_has_bits & 0x00040000u) { + // optional bool cc_enable_arenas = 31 [default = true]; + if (cached_has_bits & 0x00080000u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(31, this->_internal_cc_enable_arenas(), target); } @@ -7044,7 +6897,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FileOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileOptions) return target; @@ -7183,15 +7036,15 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } - // optional bool cc_enable_arenas = 31 [default = false]; + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; if (cached_has_bits & 0x00040000u) { - total_size += 2 + 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_optimize_for()); } - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + // optional bool cc_enable_arenas = 31 [default = true]; if (cached_has_bits & 0x00080000u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_optimize_for()); + total_size += 2 + 1; } } @@ -7223,7 +7076,7 @@ void FileOptions::MergeFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -7290,10 +7143,10 @@ void FileOptions::MergeFrom(const FileOptions& from) { deprecated_ = from.deprecated_; } if (cached_has_bits & 0x00040000u) { - cc_enable_arenas_ = from.cc_enable_arenas_; + optimize_for_ = from.optimize_for_; } if (cached_has_bits & 0x00080000u) { - optimize_for_ = from.optimize_for_; + cc_enable_arenas_ = from.cc_enable_arenas_; } _has_bits_[0] |= cached_has_bits; } @@ -7325,39 +7178,27 @@ bool FileOptions::IsInitialized() const { void FileOptions::InternalSwap(FileOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - java_package_.Swap(&other->java_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - java_outer_classname_.Swap(&other->java_outer_classname_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - go_package_.Swap(&other->go_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - objc_class_prefix_.Swap(&other->objc_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - csharp_namespace_.Swap(&other->csharp_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swift_prefix_.Swap(&other->swift_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - php_class_prefix_.Swap(&other->php_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - php_namespace_.Swap(&other->php_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - php_metadata_namespace_.Swap(&other->php_metadata_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - ruby_package_.Swap(&other->ruby_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(java_multiple_files_, other->java_multiple_files_); - swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); - swap(java_string_check_utf8_, other->java_string_check_utf8_); - swap(cc_generic_services_, other->cc_generic_services_); - swap(java_generic_services_, other->java_generic_services_); - swap(py_generic_services_, other->py_generic_services_); - swap(php_generic_services_, other->php_generic_services_); - swap(deprecated_, other->deprecated_); - swap(cc_enable_arenas_, other->cc_enable_arenas_); + java_package_.Swap(&other->java_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + java_outer_classname_.Swap(&other->java_outer_classname_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + go_package_.Swap(&other->go_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + objc_class_prefix_.Swap(&other->objc_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + csharp_namespace_.Swap(&other->csharp_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + swift_prefix_.Swap(&other->swift_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + php_class_prefix_.Swap(&other->php_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + php_namespace_.Swap(&other->php_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + php_metadata_namespace_.Swap(&other->php_metadata_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ruby_package_.Swap(&other->ruby_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(FileOptions, deprecated_) + + sizeof(FileOptions::deprecated_) + - PROTOBUF_FIELD_OFFSET(FileOptions, java_multiple_files_)>( + reinterpret_cast(&java_multiple_files_), + reinterpret_cast(&other->java_multiple_files_)); swap(optimize_for_, other->optimize_for_); + swap(cc_enable_arenas_, other->cc_enable_arenas_); } ::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const { @@ -7386,15 +7227,9 @@ class MessageOptions::_Internal { } }; -MessageOptions::MessageOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions) -} MessageOptions::MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -7402,10 +7237,9 @@ MessageOptions::MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } MessageOptions::MessageOptions(const MessageOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&message_set_wire_format_, &from.message_set_wire_format_, static_cast(reinterpret_cast(&map_entry_) - @@ -7423,10 +7257,11 @@ void MessageOptions::SharedCtor() { MessageOptions::~MessageOptions() { // @@protoc_insertion_point(destructor:google.protobuf.MessageOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void MessageOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void MessageOptions::ArenaDtor(void* object) { @@ -7456,13 +7291,13 @@ void MessageOptions::Clear() { reinterpret_cast(&map_entry_) - reinterpret_cast(&message_set_wire_format_)) + sizeof(map_entry_)); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -7524,7 +7359,9 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -7584,7 +7421,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* MessageOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MessageOptions) return target; @@ -7658,7 +7495,7 @@ void MessageOptions::MergeFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -7707,13 +7544,15 @@ bool MessageOptions::IsInitialized() const { void MessageOptions::InternalSwap(MessageOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - swap(message_set_wire_format_, other->message_set_wire_format_); - swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); - swap(deprecated_, other->deprecated_); - swap(map_entry_, other->map_entry_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(MessageOptions, map_entry_) + + sizeof(MessageOptions::map_entry_) + - PROTOBUF_FIELD_OFFSET(MessageOptions, message_set_wire_format_)>( + reinterpret_cast(&message_set_wire_format_), + reinterpret_cast(&other->message_set_wire_format_)); } ::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const { @@ -7748,15 +7587,9 @@ class FieldOptions::_Internal { } }; -FieldOptions::FieldOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions) -} FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -7764,10 +7597,9 @@ FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } FieldOptions::FieldOptions(const FieldOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&ctype_, &from.ctype_, static_cast(reinterpret_cast(&jstype_) - @@ -7785,10 +7617,11 @@ void FieldOptions::SharedCtor() { FieldOptions::~FieldOptions() { // @@protoc_insertion_point(destructor:google.protobuf.FieldOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FieldOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void FieldOptions::ArenaDtor(void* object) { @@ -7821,13 +7654,13 @@ void FieldOptions::Clear() { reinterpret_cast(&ctype_)) + sizeof(jstype_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -7913,7 +7746,9 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -7987,7 +7822,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FieldOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldOptions) return target; @@ -8073,7 +7908,7 @@ void FieldOptions::MergeFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -8128,15 +7963,15 @@ bool FieldOptions::IsInitialized() const { void FieldOptions::InternalSwap(FieldOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - swap(ctype_, other->ctype_); - swap(packed_, other->packed_); - swap(lazy_, other->lazy_); - swap(deprecated_, other->deprecated_); - swap(weak_, other->weak_); - swap(jstype_, other->jstype_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(FieldOptions, jstype_) + + sizeof(FieldOptions::jstype_) + - PROTOBUF_FIELD_OFFSET(FieldOptions, ctype_)>( + reinterpret_cast(&ctype_), + reinterpret_cast(&other->ctype_)); } ::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const { @@ -8153,15 +7988,9 @@ class OneofOptions::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -OneofOptions::OneofOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions) -} OneofOptions::OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -8169,10 +7998,9 @@ OneofOptions::OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } OneofOptions::OneofOptions(const OneofOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions) } @@ -8184,10 +8012,11 @@ void OneofOptions::SharedCtor() { OneofOptions::~OneofOptions() { // @@protoc_insertion_point(destructor:google.protobuf.OneofOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void OneofOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void OneofOptions::ArenaDtor(void* object) { @@ -8214,12 +8043,12 @@ void OneofOptions::Clear() { _extensions_.Clear(); uninterpreted_option_.Clear(); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* OneofOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -8249,7 +8078,9 @@ const char* OneofOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -8283,7 +8114,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* OneofOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofOptions) return target; @@ -8334,7 +8165,7 @@ void OneofOptions::MergeFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -8367,7 +8198,7 @@ bool OneofOptions::IsInitialized() const { void OneofOptions::InternalSwap(OneofOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); } @@ -8392,15 +8223,9 @@ class EnumOptions::_Internal { } }; -EnumOptions::EnumOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions) -} EnumOptions::EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -8408,10 +8233,9 @@ EnumOptions::EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } EnumOptions::EnumOptions(const EnumOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&allow_alias_, &from.allow_alias_, static_cast(reinterpret_cast(&deprecated_) - @@ -8429,10 +8253,11 @@ void EnumOptions::SharedCtor() { EnumOptions::~EnumOptions() { // @@protoc_insertion_point(destructor:google.protobuf.EnumOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void EnumOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void EnumOptions::ArenaDtor(void* object) { @@ -8462,13 +8287,13 @@ void EnumOptions::Clear() { reinterpret_cast(&deprecated_) - reinterpret_cast(&allow_alias_)) + sizeof(deprecated_)); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -8514,7 +8339,9 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -8562,7 +8389,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* EnumOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumOptions) return target; @@ -8626,7 +8453,7 @@ void EnumOptions::MergeFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -8669,11 +8496,15 @@ bool EnumOptions::IsInitialized() const { void EnumOptions::InternalSwap(EnumOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - swap(allow_alias_, other->allow_alias_); - swap(deprecated_, other->deprecated_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(EnumOptions, deprecated_) + + sizeof(EnumOptions::deprecated_) + - PROTOBUF_FIELD_OFFSET(EnumOptions, allow_alias_)>( + reinterpret_cast(&allow_alias_), + reinterpret_cast(&other->allow_alias_)); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const { @@ -8693,15 +8524,9 @@ class EnumValueOptions::_Internal { } }; -EnumValueOptions::EnumValueOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions) -} EnumValueOptions::EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -8709,10 +8534,9 @@ EnumValueOptions::EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); deprecated_ = from.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions) @@ -8726,10 +8550,11 @@ void EnumValueOptions::SharedCtor() { EnumValueOptions::~EnumValueOptions() { // @@protoc_insertion_point(destructor:google.protobuf.EnumValueOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void EnumValueOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void EnumValueOptions::ArenaDtor(void* object) { @@ -8757,13 +8582,13 @@ void EnumValueOptions::Clear() { uninterpreted_option_.Clear(); deprecated_ = false; _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -8801,7 +8626,9 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPA CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -8843,7 +8670,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* EnumValueOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueOptions) return target; @@ -8900,7 +8727,7 @@ void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -8936,7 +8763,7 @@ bool EnumValueOptions::IsInitialized() const { void EnumValueOptions::InternalSwap(EnumValueOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(deprecated_, other->deprecated_); @@ -8959,15 +8786,9 @@ class ServiceOptions::_Internal { } }; -ServiceOptions::ServiceOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions) -} ServiceOptions::ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -8975,10 +8796,9 @@ ServiceOptions::ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } ServiceOptions::ServiceOptions(const ServiceOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); deprecated_ = from.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions) @@ -8992,10 +8812,11 @@ void ServiceOptions::SharedCtor() { ServiceOptions::~ServiceOptions() { // @@protoc_insertion_point(destructor:google.protobuf.ServiceOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void ServiceOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void ServiceOptions::ArenaDtor(void* object) { @@ -9023,13 +8844,13 @@ void ServiceOptions::Clear() { uninterpreted_option_.Clear(); deprecated_ = false; _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -9067,7 +8888,9 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -9109,7 +8932,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* ServiceOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceOptions) return target; @@ -9166,7 +8989,7 @@ void ServiceOptions::MergeFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -9202,7 +9025,7 @@ bool ServiceOptions::IsInitialized() const { void ServiceOptions::InternalSwap(ServiceOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(deprecated_, other->deprecated_); @@ -9228,15 +9051,9 @@ class MethodOptions::_Internal { } }; -MethodOptions::MethodOptions() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions) -} MethodOptions::MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), _extensions_(arena), - _internal_metadata_(arena), uninterpreted_option_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -9244,10 +9061,9 @@ MethodOptions::MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena) } MethodOptions::MethodOptions(const MethodOptions& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), uninterpreted_option_(from.uninterpreted_option_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&deprecated_, &from.deprecated_, static_cast(reinterpret_cast(&idempotency_level_) - @@ -9265,10 +9081,11 @@ void MethodOptions::SharedCtor() { MethodOptions::~MethodOptions() { // @@protoc_insertion_point(destructor:google.protobuf.MethodOptions) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void MethodOptions::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void MethodOptions::ArenaDtor(void* object) { @@ -9301,13 +9118,13 @@ void MethodOptions::Clear() { reinterpret_cast(&deprecated_)) + sizeof(idempotency_level_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -9357,7 +9174,9 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ CHK_(ptr != nullptr); continue; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -9406,7 +9225,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* MethodOptions::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodOptions) return target; @@ -9471,7 +9290,7 @@ void MethodOptions::MergeFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -9514,11 +9333,15 @@ bool MethodOptions::IsInitialized() const { void MethodOptions::InternalSwap(MethodOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - swap(deprecated_, other->deprecated_); - swap(idempotency_level_, other->idempotency_level_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(MethodOptions, idempotency_level_) + + sizeof(MethodOptions::idempotency_level_) + - PROTOBUF_FIELD_OFFSET(MethodOptions, deprecated_)>( + reinterpret_cast(&deprecated_), + reinterpret_cast(&other->deprecated_)); } ::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const { @@ -9539,29 +9362,25 @@ class UninterpretedOption_NamePart::_Internal { static void set_has_is_extension(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } }; -UninterpretedOption_NamePart::UninterpretedOption_NamePart() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart) -} UninterpretedOption_NamePart::UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption.NamePart) } UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name_part()) { name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name_part(), - GetArenaNoVirtual()); + GetArena()); } is_extension_ = from.is_extension_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) @@ -9576,10 +9395,11 @@ void UninterpretedOption_NamePart::SharedCtor() { UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { // @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption.NamePart) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void UninterpretedOption_NamePart::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -9610,13 +9430,13 @@ void UninterpretedOption_NamePart::Clear() { } is_extension_ = false; _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -9647,7 +9467,9 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROT ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -9687,7 +9509,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* UninterpretedOption_NamePart::_InternalSerialize if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption.NamePart) return target; @@ -9758,7 +9580,7 @@ void UninterpretedOption_NamePart::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Mess void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -9789,16 +9611,15 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& } bool UninterpretedOption_NamePart::IsInitialized() const { - if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; + if (_Internal::MissingRequiredFields(_has_bits_)) return false; return true; } void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_part_.Swap(&other->name_part_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_part_.Swap(&other->name_part_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(is_extension_, other->is_extension_); } @@ -9834,14 +9655,8 @@ class UninterpretedOption::_Internal { } }; -UninterpretedOption::UninterpretedOption() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption) -} UninterpretedOption::UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), name_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -9849,24 +9664,23 @@ UninterpretedOption::UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena) } UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), name_(from.name_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_identifier_value()) { identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_identifier_value(), - GetArenaNoVirtual()); + GetArena()); } string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_string_value()) { string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_string_value(), - GetArenaNoVirtual()); + GetArena()); } aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_aggregate_value()) { aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_aggregate_value(), - GetArenaNoVirtual()); + GetArena()); } ::memcpy(&positive_int_value_, &from.positive_int_value_, static_cast(reinterpret_cast(&double_value_) - @@ -9887,10 +9701,11 @@ void UninterpretedOption::SharedCtor() { UninterpretedOption::~UninterpretedOption() { // @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void UninterpretedOption::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); identifier_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); string_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); aggregate_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -9936,13 +9751,13 @@ void UninterpretedOption::Clear() { reinterpret_cast(&positive_int_value_)) + sizeof(double_value_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -10020,7 +9835,9 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -10096,7 +9913,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* UninterpretedOption::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption) return target; @@ -10187,7 +10004,7 @@ void UninterpretedOption::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -10237,18 +10054,18 @@ bool UninterpretedOption::IsInitialized() const { void UninterpretedOption::InternalSwap(UninterpretedOption* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); name_.InternalSwap(&other->name_); - identifier_value_.Swap(&other->identifier_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - string_value_.Swap(&other->string_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - aggregate_value_.Swap(&other->aggregate_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(positive_int_value_, other->positive_int_value_); - swap(negative_int_value_, other->negative_int_value_); - swap(double_value_, other->double_value_); + identifier_value_.Swap(&other->identifier_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + string_value_.Swap(&other->string_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + aggregate_value_.Swap(&other->aggregate_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(UninterpretedOption, double_value_) + + sizeof(UninterpretedOption::double_value_) + - PROTOBUF_FIELD_OFFSET(UninterpretedOption, positive_int_value_)>( + reinterpret_cast(&positive_int_value_), + reinterpret_cast(&other->positive_int_value_)); } ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const { @@ -10271,14 +10088,8 @@ class SourceCodeInfo_Location::_Internal { } }; -SourceCodeInfo_Location::SourceCodeInfo_Location() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location) -} SourceCodeInfo_Location::SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), path_(arena), span_(arena), leading_detached_comments_(arena) { @@ -10288,21 +10099,20 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* } SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), path_(from.path_), span_(from.span_), leading_detached_comments_(from.leading_detached_comments_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_leading_comments()) { leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_leading_comments(), - GetArenaNoVirtual()); + GetArena()); } trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_trailing_comments()) { trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_trailing_comments(), - GetArenaNoVirtual()); + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } @@ -10316,10 +10126,11 @@ void SourceCodeInfo_Location::SharedCtor() { SourceCodeInfo_Location::~SourceCodeInfo_Location() { // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo.Location) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void SourceCodeInfo_Location::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); trailing_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -10358,13 +10169,13 @@ void SourceCodeInfo_Location::Clear() { } } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -10434,7 +10245,9 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -10506,7 +10319,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* SourceCodeInfo_Location::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo.Location) return target; @@ -10602,7 +10415,7 @@ void SourceCodeInfo_Location::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -10640,15 +10453,13 @@ bool SourceCodeInfo_Location::IsInitialized() const { void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); path_.InternalSwap(&other->path_); span_.InternalSwap(&other->span_); leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); - leading_comments_.Swap(&other->leading_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - trailing_comments_.Swap(&other->trailing_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + leading_comments_.Swap(&other->leading_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + trailing_comments_.Swap(&other->trailing_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const { @@ -10665,14 +10476,8 @@ class SourceCodeInfo::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -SourceCodeInfo::SourceCodeInfo() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) -} SourceCodeInfo::SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), location_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -10680,10 +10485,9 @@ SourceCodeInfo::SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena) } SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), location_(from.location_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) } @@ -10694,10 +10498,11 @@ void SourceCodeInfo::SharedCtor() { SourceCodeInfo::~SourceCodeInfo() { // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void SourceCodeInfo::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void SourceCodeInfo::ArenaDtor(void* object) { @@ -10723,12 +10528,12 @@ void SourceCodeInfo::Clear() { location_.Clear(); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SourceCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -10752,7 +10557,9 @@ const char* SourceCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -10782,7 +10589,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* SourceCodeInfo::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) return target; @@ -10830,7 +10637,7 @@ void SourceCodeInfo::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -10857,7 +10664,7 @@ bool SourceCodeInfo::IsInitialized() const { void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); location_.InternalSwap(&other->location_); } @@ -10885,14 +10692,8 @@ class GeneratedCodeInfo_Annotation::_Internal { } }; -GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation) -} GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), path_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -10900,14 +10701,13 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ } GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), path_(from.path_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_source_file()) { source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_source_file(), - GetArenaNoVirtual()); + GetArena()); } ::memcpy(&begin_, &from.begin_, static_cast(reinterpret_cast(&end_) - @@ -10926,10 +10726,11 @@ void GeneratedCodeInfo_Annotation::SharedCtor() { GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { // @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo.Annotation) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void GeneratedCodeInfo_Annotation::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); source_file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -10965,13 +10766,13 @@ void GeneratedCodeInfo_Annotation::Clear() { reinterpret_cast(&begin_)) + sizeof(end_)); } _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -11020,7 +10821,9 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -11075,7 +10878,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* GeneratedCodeInfo_Annotation::_InternalSerialize if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo.Annotation) return target; @@ -11155,7 +10958,7 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Mess void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -11195,13 +10998,16 @@ bool GeneratedCodeInfo_Annotation::IsInitialized() const { void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); path_.InternalSwap(&other->path_); - source_file_.Swap(&other->source_file_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(begin_, other->begin_); - swap(end_, other->end_); + source_file_.Swap(&other->source_file_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_) + + sizeof(GeneratedCodeInfo_Annotation::end_) + - PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_)>( + reinterpret_cast(&begin_), + reinterpret_cast(&other->begin_)); } ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { @@ -11218,14 +11024,8 @@ class GeneratedCodeInfo::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -GeneratedCodeInfo::GeneratedCodeInfo() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo) -} GeneratedCodeInfo::GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), annotation_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -11233,10 +11033,9 @@ GeneratedCodeInfo::GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena) } GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), _has_bits_(from._has_bits_), annotation_(from.annotation_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo) } @@ -11247,10 +11046,11 @@ void GeneratedCodeInfo::SharedCtor() { GeneratedCodeInfo::~GeneratedCodeInfo() { // @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void GeneratedCodeInfo::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void GeneratedCodeInfo::ArenaDtor(void* object) { @@ -11276,12 +11076,12 @@ void GeneratedCodeInfo::Clear() { annotation_.Clear(); _has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -11305,7 +11105,9 @@ const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESP ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -11335,7 +11137,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* GeneratedCodeInfo::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo) return target; @@ -11383,7 +11185,7 @@ void GeneratedCodeInfo::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -11410,7 +11212,7 @@ bool GeneratedCodeInfo::IsInitialized() const { void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); annotation_.InternalSwap(&other->annotation_); } diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index e7bae0da64d6..ee50d37c9292 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -330,10 +330,10 @@ inline bool MethodOptions_IdempotencyLevel_Parse( } // =================================================================== -class PROTOBUF_EXPORT FileDescriptorSet : +class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { public: - FileDescriptorSet(); + inline FileDescriptorSet() : FileDescriptorSet(nullptr) {}; virtual ~FileDescriptorSet(); FileDescriptorSet(const FileDescriptorSet& from); @@ -347,7 +347,7 @@ class PROTOBUF_EXPORT FileDescriptorSet : return *this; } inline FileDescriptorSet& operator=(FileDescriptorSet&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -356,18 +356,12 @@ class PROTOBUF_EXPORT FileDescriptorSet : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -392,7 +386,7 @@ class PROTOBUF_EXPORT FileDescriptorSet : } inline void Swap(FileDescriptorSet* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -400,7 +394,7 @@ class PROTOBUF_EXPORT FileDescriptorSet : } void UnsafeArenaSwap(FileDescriptorSet* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -440,13 +434,6 @@ class PROTOBUF_EXPORT FileDescriptorSet : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -487,7 +474,6 @@ class PROTOBUF_EXPORT FileDescriptorSet : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -498,10 +484,10 @@ class PROTOBUF_EXPORT FileDescriptorSet : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FileDescriptorProto : +class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { public: - FileDescriptorProto(); + inline FileDescriptorProto() : FileDescriptorProto(nullptr) {}; virtual ~FileDescriptorProto(); FileDescriptorProto(const FileDescriptorProto& from); @@ -515,7 +501,7 @@ class PROTOBUF_EXPORT FileDescriptorProto : return *this; } inline FileDescriptorProto& operator=(FileDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -524,18 +510,12 @@ class PROTOBUF_EXPORT FileDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -560,7 +540,7 @@ class PROTOBUF_EXPORT FileDescriptorProto : } inline void Swap(FileDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -568,7 +548,7 @@ class PROTOBUF_EXPORT FileDescriptorProto : } void UnsafeArenaSwap(FileDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -608,13 +588,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -911,7 +884,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -933,10 +905,10 @@ class PROTOBUF_EXPORT FileDescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : +class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { public: - DescriptorProto_ExtensionRange(); + inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {}; virtual ~DescriptorProto_ExtensionRange(); DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from); @@ -950,7 +922,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : return *this; } inline DescriptorProto_ExtensionRange& operator=(DescriptorProto_ExtensionRange&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -959,18 +931,12 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -995,7 +961,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : } inline void Swap(DescriptorProto_ExtensionRange* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1003,7 +969,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : } void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1043,13 +1009,6 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1118,7 +1077,6 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1131,10 +1089,10 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT DescriptorProto_ReservedRange : +class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { public: - DescriptorProto_ReservedRange(); + inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {}; virtual ~DescriptorProto_ReservedRange(); DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from); @@ -1148,7 +1106,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : return *this; } inline DescriptorProto_ReservedRange& operator=(DescriptorProto_ReservedRange&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1157,18 +1115,12 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1193,7 +1145,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : } inline void Swap(DescriptorProto_ReservedRange* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1201,7 +1153,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : } void UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1241,13 +1193,6 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1297,7 +1242,6 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1309,10 +1253,10 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT DescriptorProto : +class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { public: - DescriptorProto(); + inline DescriptorProto() : DescriptorProto(nullptr) {}; virtual ~DescriptorProto(); DescriptorProto(const DescriptorProto& from); @@ -1326,7 +1270,7 @@ class PROTOBUF_EXPORT DescriptorProto : return *this; } inline DescriptorProto& operator=(DescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1335,18 +1279,12 @@ class PROTOBUF_EXPORT DescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1371,7 +1309,7 @@ class PROTOBUF_EXPORT DescriptorProto : } inline void Swap(DescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1379,7 +1317,7 @@ class PROTOBUF_EXPORT DescriptorProto : } void UnsafeArenaSwap(DescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1419,13 +1357,6 @@ class PROTOBUF_EXPORT DescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1657,7 +1588,6 @@ class PROTOBUF_EXPORT DescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1677,10 +1607,10 @@ class PROTOBUF_EXPORT DescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ExtensionRangeOptions : +class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ { public: - ExtensionRangeOptions(); + inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {}; virtual ~ExtensionRangeOptions(); ExtensionRangeOptions(const ExtensionRangeOptions& from); @@ -1694,7 +1624,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : return *this; } inline ExtensionRangeOptions& operator=(ExtensionRangeOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1703,18 +1633,12 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1739,7 +1663,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : } inline void Swap(ExtensionRangeOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1747,7 +1671,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : } void UnsafeArenaSwap(ExtensionRangeOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1787,13 +1711,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1837,7 +1754,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1848,10 +1764,10 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FieldDescriptorProto : +class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { public: - FieldDescriptorProto(); + inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {}; virtual ~FieldDescriptorProto(); FieldDescriptorProto(const FieldDescriptorProto& from); @@ -1865,7 +1781,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto : return *this; } inline FieldDescriptorProto& operator=(FieldDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1874,18 +1790,12 @@ class PROTOBUF_EXPORT FieldDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1910,7 +1820,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto : } inline void Swap(FieldDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1918,7 +1828,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto : } void UnsafeArenaSwap(FieldDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1958,13 +1868,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -2083,6 +1986,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto : kOptionsFieldNumber = 8, kNumberFieldNumber = 3, kOneofIndexFieldNumber = 9, + kProto3OptionalFieldNumber = 17, kLabelFieldNumber = 4, kTypeFieldNumber = 5, }; @@ -2275,6 +2179,19 @@ class PROTOBUF_EXPORT FieldDescriptorProto : void _internal_set_oneof_index(::PROTOBUF_NAMESPACE_ID::int32 value); public: + // optional bool proto3_optional = 17; + bool has_proto3_optional() const; + private: + bool _internal_has_proto3_optional() const; + public: + void clear_proto3_optional(); + bool proto3_optional() const; + void set_proto3_optional(bool value); + private: + bool _internal_proto3_optional() const; + void _internal_set_proto3_optional(bool value); + public: + // optional .google.protobuf.FieldDescriptorProto.Label label = 4; bool has_label() const; private: @@ -2305,7 +2222,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -2319,16 +2235,17 @@ class PROTOBUF_EXPORT FieldDescriptorProto : PROTOBUF_NAMESPACE_ID::FieldOptions* options_; ::PROTOBUF_NAMESPACE_ID::int32 number_; ::PROTOBUF_NAMESPACE_ID::int32 oneof_index_; + bool proto3_optional_; int label_; int type_; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT OneofDescriptorProto : +class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { public: - OneofDescriptorProto(); + inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {}; virtual ~OneofDescriptorProto(); OneofDescriptorProto(const OneofDescriptorProto& from); @@ -2342,7 +2259,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto : return *this; } inline OneofDescriptorProto& operator=(OneofDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -2351,18 +2268,12 @@ class PROTOBUF_EXPORT OneofDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -2387,7 +2298,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto : } inline void Swap(OneofDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2395,7 +2306,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto : } void UnsafeArenaSwap(OneofDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -2435,13 +2346,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -2512,7 +2416,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -2524,10 +2427,10 @@ class PROTOBUF_EXPORT OneofDescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : +class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ { public: - EnumDescriptorProto_EnumReservedRange(); + inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {}; virtual ~EnumDescriptorProto_EnumReservedRange(); EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from); @@ -2541,7 +2444,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : return *this; } inline EnumDescriptorProto_EnumReservedRange& operator=(EnumDescriptorProto_EnumReservedRange&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -2550,18 +2453,12 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -2586,7 +2483,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : } inline void Swap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2594,7 +2491,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : } void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -2634,13 +2531,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -2690,7 +2580,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -2702,10 +2591,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumDescriptorProto : +class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { public: - EnumDescriptorProto(); + inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {}; virtual ~EnumDescriptorProto(); EnumDescriptorProto(const EnumDescriptorProto& from); @@ -2719,7 +2608,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto : return *this; } inline EnumDescriptorProto& operator=(EnumDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -2728,18 +2617,12 @@ class PROTOBUF_EXPORT EnumDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -2764,7 +2647,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto : } inline void Swap(EnumDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2772,7 +2655,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto : } void UnsafeArenaSwap(EnumDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -2812,13 +2695,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -2954,7 +2830,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -2969,10 +2844,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumValueDescriptorProto : +class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { public: - EnumValueDescriptorProto(); + inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {}; virtual ~EnumValueDescriptorProto(); EnumValueDescriptorProto(const EnumValueDescriptorProto& from); @@ -2986,7 +2861,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : return *this; } inline EnumValueDescriptorProto& operator=(EnumValueDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -2995,18 +2870,12 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -3031,7 +2900,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : } inline void Swap(EnumValueDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3039,7 +2908,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : } void UnsafeArenaSwap(EnumValueDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -3079,13 +2948,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -3170,7 +3032,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -3183,10 +3044,10 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ServiceDescriptorProto : +class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { public: - ServiceDescriptorProto(); + inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {}; virtual ~ServiceDescriptorProto(); ServiceDescriptorProto(const ServiceDescriptorProto& from); @@ -3200,7 +3061,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : return *this; } inline ServiceDescriptorProto& operator=(ServiceDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -3209,18 +3070,12 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -3245,7 +3100,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : } inline void Swap(ServiceDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3253,7 +3108,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : } void UnsafeArenaSwap(ServiceDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -3293,13 +3148,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -3389,7 +3237,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -3402,10 +3249,10 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT MethodDescriptorProto : +class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { public: - MethodDescriptorProto(); + inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {}; virtual ~MethodDescriptorProto(); MethodDescriptorProto(const MethodDescriptorProto& from); @@ -3419,7 +3266,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto : return *this; } inline MethodDescriptorProto& operator=(MethodDescriptorProto&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -3428,18 +3275,12 @@ class PROTOBUF_EXPORT MethodDescriptorProto : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -3464,7 +3305,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto : } inline void Swap(MethodDescriptorProto* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3472,7 +3313,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto : } void UnsafeArenaSwap(MethodDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -3512,13 +3353,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -3677,7 +3511,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -3693,10 +3526,10 @@ class PROTOBUF_EXPORT MethodDescriptorProto : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FileOptions : +class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { public: - FileOptions(); + inline FileOptions() : FileOptions(nullptr) {}; virtual ~FileOptions(); FileOptions(const FileOptions& from); @@ -3710,7 +3543,7 @@ class PROTOBUF_EXPORT FileOptions : return *this; } inline FileOptions& operator=(FileOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -3719,18 +3552,12 @@ class PROTOBUF_EXPORT FileOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -3755,7 +3582,7 @@ class PROTOBUF_EXPORT FileOptions : } inline void Swap(FileOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3763,7 +3590,7 @@ class PROTOBUF_EXPORT FileOptions : } void UnsafeArenaSwap(FileOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -3803,13 +3630,6 @@ class PROTOBUF_EXPORT FileOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -3877,8 +3697,8 @@ class PROTOBUF_EXPORT FileOptions : kPyGenericServicesFieldNumber = 18, kPhpGenericServicesFieldNumber = 42, kDeprecatedFieldNumber = 23, - kCcEnableArenasFieldNumber = 31, kOptimizeForFieldNumber = 9, + kCcEnableArenasFieldNumber = 31, }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; @@ -4292,19 +4112,6 @@ class PROTOBUF_EXPORT FileOptions : void _internal_set_deprecated(bool value); public: - // optional bool cc_enable_arenas = 31 [default = false]; - bool has_cc_enable_arenas() const; - private: - bool _internal_has_cc_enable_arenas() const; - public: - void clear_cc_enable_arenas(); - bool cc_enable_arenas() const; - void set_cc_enable_arenas(bool value); - private: - bool _internal_cc_enable_arenas() const; - void _internal_set_cc_enable_arenas(bool value); - public: - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool has_optimize_for() const; private: @@ -4318,6 +4125,19 @@ class PROTOBUF_EXPORT FileOptions : void _internal_set_optimize_for(PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value); public: + // optional bool cc_enable_arenas = 31 [default = true]; + bool has_cc_enable_arenas() const; + private: + bool _internal_has_cc_enable_arenas() const; + public: + void clear_cc_enable_arenas(); + bool cc_enable_arenas() const; + void set_cc_enable_arenas(bool value); + private: + bool _internal_cc_enable_arenas() const; + void _internal_set_cc_enable_arenas(bool value); + public: + GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) private: @@ -4325,7 +4145,6 @@ class PROTOBUF_EXPORT FileOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -4350,16 +4169,16 @@ class PROTOBUF_EXPORT FileOptions : bool py_generic_services_; bool php_generic_services_; bool deprecated_; - bool cc_enable_arenas_; int optimize_for_; + bool cc_enable_arenas_; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT MessageOptions : +class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { public: - MessageOptions(); + inline MessageOptions() : MessageOptions(nullptr) {}; virtual ~MessageOptions(); MessageOptions(const MessageOptions& from); @@ -4373,7 +4192,7 @@ class PROTOBUF_EXPORT MessageOptions : return *this; } inline MessageOptions& operator=(MessageOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -4382,18 +4201,12 @@ class PROTOBUF_EXPORT MessageOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -4418,7 +4231,7 @@ class PROTOBUF_EXPORT MessageOptions : } inline void Swap(MessageOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4426,7 +4239,7 @@ class PROTOBUF_EXPORT MessageOptions : } void UnsafeArenaSwap(MessageOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -4466,13 +4279,6 @@ class PROTOBUF_EXPORT MessageOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -4572,7 +4378,6 @@ class PROTOBUF_EXPORT MessageOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -4587,10 +4392,10 @@ class PROTOBUF_EXPORT MessageOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FieldOptions : +class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { public: - FieldOptions(); + inline FieldOptions() : FieldOptions(nullptr) {}; virtual ~FieldOptions(); FieldOptions(const FieldOptions& from); @@ -4604,7 +4409,7 @@ class PROTOBUF_EXPORT FieldOptions : return *this; } inline FieldOptions& operator=(FieldOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -4613,18 +4418,12 @@ class PROTOBUF_EXPORT FieldOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -4649,7 +4448,7 @@ class PROTOBUF_EXPORT FieldOptions : } inline void Swap(FieldOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4657,7 +4456,7 @@ class PROTOBUF_EXPORT FieldOptions : } void UnsafeArenaSwap(FieldOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -4697,13 +4496,6 @@ class PROTOBUF_EXPORT FieldOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -4895,7 +4687,6 @@ class PROTOBUF_EXPORT FieldOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -4912,10 +4703,10 @@ class PROTOBUF_EXPORT FieldOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT OneofOptions : +class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { public: - OneofOptions(); + inline OneofOptions() : OneofOptions(nullptr) {}; virtual ~OneofOptions(); OneofOptions(const OneofOptions& from); @@ -4929,7 +4720,7 @@ class PROTOBUF_EXPORT OneofOptions : return *this; } inline OneofOptions& operator=(OneofOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -4938,18 +4729,12 @@ class PROTOBUF_EXPORT OneofOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -4974,7 +4759,7 @@ class PROTOBUF_EXPORT OneofOptions : } inline void Swap(OneofOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4982,7 +4767,7 @@ class PROTOBUF_EXPORT OneofOptions : } void UnsafeArenaSwap(OneofOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -5022,13 +4807,6 @@ class PROTOBUF_EXPORT OneofOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -5072,7 +4850,6 @@ class PROTOBUF_EXPORT OneofOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -5083,10 +4860,10 @@ class PROTOBUF_EXPORT OneofOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumOptions : +class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { public: - EnumOptions(); + inline EnumOptions() : EnumOptions(nullptr) {}; virtual ~EnumOptions(); EnumOptions(const EnumOptions& from); @@ -5100,7 +4877,7 @@ class PROTOBUF_EXPORT EnumOptions : return *this; } inline EnumOptions& operator=(EnumOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -5109,18 +4886,12 @@ class PROTOBUF_EXPORT EnumOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -5145,7 +4916,7 @@ class PROTOBUF_EXPORT EnumOptions : } inline void Swap(EnumOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5153,7 +4924,7 @@ class PROTOBUF_EXPORT EnumOptions : } void UnsafeArenaSwap(EnumOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -5193,13 +4964,6 @@ class PROTOBUF_EXPORT EnumOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -5271,7 +5035,6 @@ class PROTOBUF_EXPORT EnumOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -5284,10 +5047,10 @@ class PROTOBUF_EXPORT EnumOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumValueOptions : +class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { public: - EnumValueOptions(); + inline EnumValueOptions() : EnumValueOptions(nullptr) {}; virtual ~EnumValueOptions(); EnumValueOptions(const EnumValueOptions& from); @@ -5301,7 +5064,7 @@ class PROTOBUF_EXPORT EnumValueOptions : return *this; } inline EnumValueOptions& operator=(EnumValueOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -5310,18 +5073,12 @@ class PROTOBUF_EXPORT EnumValueOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -5346,7 +5103,7 @@ class PROTOBUF_EXPORT EnumValueOptions : } inline void Swap(EnumValueOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5354,7 +5111,7 @@ class PROTOBUF_EXPORT EnumValueOptions : } void UnsafeArenaSwap(EnumValueOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -5394,13 +5151,6 @@ class PROTOBUF_EXPORT EnumValueOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -5458,7 +5208,6 @@ class PROTOBUF_EXPORT EnumValueOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -5470,10 +5219,10 @@ class PROTOBUF_EXPORT EnumValueOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ServiceOptions : +class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { public: - ServiceOptions(); + inline ServiceOptions() : ServiceOptions(nullptr) {}; virtual ~ServiceOptions(); ServiceOptions(const ServiceOptions& from); @@ -5487,7 +5236,7 @@ class PROTOBUF_EXPORT ServiceOptions : return *this; } inline ServiceOptions& operator=(ServiceOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -5496,18 +5245,12 @@ class PROTOBUF_EXPORT ServiceOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -5532,7 +5275,7 @@ class PROTOBUF_EXPORT ServiceOptions : } inline void Swap(ServiceOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5540,7 +5283,7 @@ class PROTOBUF_EXPORT ServiceOptions : } void UnsafeArenaSwap(ServiceOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -5580,13 +5323,6 @@ class PROTOBUF_EXPORT ServiceOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -5644,7 +5380,6 @@ class PROTOBUF_EXPORT ServiceOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -5656,10 +5391,10 @@ class PROTOBUF_EXPORT ServiceOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT MethodOptions : +class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { public: - MethodOptions(); + inline MethodOptions() : MethodOptions(nullptr) {}; virtual ~MethodOptions(); MethodOptions(const MethodOptions& from); @@ -5673,7 +5408,7 @@ class PROTOBUF_EXPORT MethodOptions : return *this; } inline MethodOptions& operator=(MethodOptions&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -5682,18 +5417,12 @@ class PROTOBUF_EXPORT MethodOptions : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -5718,7 +5447,7 @@ class PROTOBUF_EXPORT MethodOptions : } inline void Swap(MethodOptions* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5726,7 +5455,7 @@ class PROTOBUF_EXPORT MethodOptions : } void UnsafeArenaSwap(MethodOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -5766,13 +5495,6 @@ class PROTOBUF_EXPORT MethodOptions : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -5876,7 +5598,6 @@ class PROTOBUF_EXPORT MethodOptions : ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -5889,10 +5610,10 @@ class PROTOBUF_EXPORT MethodOptions : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT UninterpretedOption_NamePart : +class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { public: - UninterpretedOption_NamePart(); + inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {}; virtual ~UninterpretedOption_NamePart(); UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from); @@ -5906,7 +5627,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : return *this; } inline UninterpretedOption_NamePart& operator=(UninterpretedOption_NamePart&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -5915,18 +5636,12 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -5951,7 +5666,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : } inline void Swap(UninterpretedOption_NamePart* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5959,7 +5674,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : } void UnsafeArenaSwap(UninterpretedOption_NamePart* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -5999,13 +5714,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -6074,7 +5782,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -6086,10 +5793,10 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT UninterpretedOption : +class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { public: - UninterpretedOption(); + inline UninterpretedOption() : UninterpretedOption(nullptr) {}; virtual ~UninterpretedOption(); UninterpretedOption(const UninterpretedOption& from); @@ -6103,7 +5810,7 @@ class PROTOBUF_EXPORT UninterpretedOption : return *this; } inline UninterpretedOption& operator=(UninterpretedOption&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -6112,18 +5819,12 @@ class PROTOBUF_EXPORT UninterpretedOption : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -6148,7 +5849,7 @@ class PROTOBUF_EXPORT UninterpretedOption : } inline void Swap(UninterpretedOption* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -6156,7 +5857,7 @@ class PROTOBUF_EXPORT UninterpretedOption : } void UnsafeArenaSwap(UninterpretedOption* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -6196,13 +5897,6 @@ class PROTOBUF_EXPORT UninterpretedOption : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -6377,7 +6071,6 @@ class PROTOBUF_EXPORT UninterpretedOption : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -6394,10 +6087,10 @@ class PROTOBUF_EXPORT UninterpretedOption : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT SourceCodeInfo_Location : +class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { public: - SourceCodeInfo_Location(); + inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {}; virtual ~SourceCodeInfo_Location(); SourceCodeInfo_Location(const SourceCodeInfo_Location& from); @@ -6411,7 +6104,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : return *this; } inline SourceCodeInfo_Location& operator=(SourceCodeInfo_Location&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -6420,18 +6113,12 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -6456,7 +6143,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : } inline void Swap(SourceCodeInfo_Location* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -6464,7 +6151,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : } void UnsafeArenaSwap(SourceCodeInfo_Location* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -6504,13 +6191,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -6663,7 +6343,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -6680,10 +6359,10 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT SourceCodeInfo : +class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { public: - SourceCodeInfo(); + inline SourceCodeInfo() : SourceCodeInfo(nullptr) {}; virtual ~SourceCodeInfo(); SourceCodeInfo(const SourceCodeInfo& from); @@ -6697,7 +6376,7 @@ class PROTOBUF_EXPORT SourceCodeInfo : return *this; } inline SourceCodeInfo& operator=(SourceCodeInfo&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -6706,18 +6385,12 @@ class PROTOBUF_EXPORT SourceCodeInfo : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -6742,7 +6415,7 @@ class PROTOBUF_EXPORT SourceCodeInfo : } inline void Swap(SourceCodeInfo* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -6750,7 +6423,7 @@ class PROTOBUF_EXPORT SourceCodeInfo : } void UnsafeArenaSwap(SourceCodeInfo* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -6790,13 +6463,6 @@ class PROTOBUF_EXPORT SourceCodeInfo : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -6839,7 +6505,6 @@ class PROTOBUF_EXPORT SourceCodeInfo : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -6850,10 +6515,10 @@ class PROTOBUF_EXPORT SourceCodeInfo : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : +class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { public: - GeneratedCodeInfo_Annotation(); + inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {}; virtual ~GeneratedCodeInfo_Annotation(); GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from); @@ -6867,7 +6532,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : return *this; } inline GeneratedCodeInfo_Annotation& operator=(GeneratedCodeInfo_Annotation&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -6876,18 +6541,12 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -6912,7 +6571,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : } inline void Swap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -6920,7 +6579,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : } void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -6960,13 +6619,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -7069,7 +6721,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -7084,10 +6735,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT GeneratedCodeInfo : +class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { public: - GeneratedCodeInfo(); + inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {}; virtual ~GeneratedCodeInfo(); GeneratedCodeInfo(const GeneratedCodeInfo& from); @@ -7101,7 +6752,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : return *this; } inline GeneratedCodeInfo& operator=(GeneratedCodeInfo&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -7110,18 +6761,12 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -7146,7 +6791,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : } inline void Swap(GeneratedCodeInfo* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -7154,7 +6799,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : } void UnsafeArenaSwap(GeneratedCodeInfo* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -7194,13 +6839,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -7243,7 +6881,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -7315,7 +6952,7 @@ inline bool FileDescriptorProto::has_name() const { return _internal_has_name(); } inline void FileDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& FileDescriptorProto::name() const { @@ -7335,31 +6972,31 @@ inline const std::string& FileDescriptorProto::_internal_name() const { } inline void FileDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name) } inline void FileDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name) } inline void FileDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) } inline std::string* FileDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name) @@ -7367,7 +7004,7 @@ inline std::string* FileDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -7376,26 +7013,26 @@ inline void FileDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name) } inline std::string* FileDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.name) } @@ -7408,7 +7045,7 @@ inline bool FileDescriptorProto::has_package() const { return _internal_has_package(); } inline void FileDescriptorProto::clear_package() { - package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& FileDescriptorProto::package() const { @@ -7428,31 +7065,31 @@ inline const std::string& FileDescriptorProto::_internal_package() const { } inline void FileDescriptorProto::_internal_set_package(const std::string& value) { _has_bits_[0] |= 0x00000002u; - package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileDescriptorProto::set_package(std::string&& value) { _has_bits_[0] |= 0x00000002u; package_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package) } inline void FileDescriptorProto::set_package(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package) } inline void FileDescriptorProto::set_package(const char* value, size_t size) { _has_bits_[0] |= 0x00000002u; package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) } inline std::string* FileDescriptorProto::_internal_mutable_package() { _has_bits_[0] |= 0x00000002u; - return package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileDescriptorProto::release_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package) @@ -7460,7 +7097,7 @@ inline std::string* FileDescriptorProto::release_package() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileDescriptorProto::set_allocated_package(std::string* package) { if (package != nullptr) { @@ -7469,26 +7106,26 @@ inline void FileDescriptorProto::set_allocated_package(std::string* package) { _has_bits_[0] &= ~0x00000002u; } package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), package, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package) } inline std::string* FileDescriptorProto::unsafe_arena_release_package() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.package) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000002u; return package_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileDescriptorProto::unsafe_arena_set_allocated_package( std::string* package) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (package != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } package_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - package, GetArenaNoVirtual()); + package, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.package) } @@ -7838,9 +7475,22 @@ inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::options() // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) return _internal_options(); } +inline void FileDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::FileOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000008u; + } else { + _has_bits_[0] &= ~0x00000008u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -7855,7 +7505,7 @@ inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::unsafe_arena_rel inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000008u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -7865,7 +7515,7 @@ inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::mutable_options( return _internal_mutable_options(); } inline void FileDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::FileOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -7906,9 +7556,22 @@ inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::source_ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info) return _internal_source_code_info(); } +inline void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info( + PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_code_info_); + } + source_code_info_ = source_code_info; + if (source_code_info) { + _has_bits_[0] |= 0x00000010u; + } else { + _has_bits_[0] &= ~0x00000010u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) +} inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_source_code_info() { auto temp = unsafe_arena_release_source_code_info(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -7923,7 +7586,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::unsafe_arena_ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::_internal_mutable_source_code_info() { _has_bits_[0] |= 0x00000010u; if (source_code_info_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); source_code_info_ = p; } return source_code_info_; @@ -7933,7 +7596,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::mutable_sourc return _internal_mutable_source_code_info(); } inline void FileDescriptorProto::set_allocated_source_code_info(PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete source_code_info_; } @@ -7961,7 +7624,7 @@ inline bool FileDescriptorProto::has_syntax() const { return _internal_has_syntax(); } inline void FileDescriptorProto::clear_syntax() { - syntax_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + syntax_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& FileDescriptorProto::syntax() const { @@ -7981,31 +7644,31 @@ inline const std::string& FileDescriptorProto::_internal_syntax() const { } inline void FileDescriptorProto::_internal_set_syntax(const std::string& value) { _has_bits_[0] |= 0x00000004u; - syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileDescriptorProto::set_syntax(std::string&& value) { _has_bits_[0] |= 0x00000004u; syntax_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax) } inline void FileDescriptorProto::set_syntax(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000004u; syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax) } inline void FileDescriptorProto::set_syntax(const char* value, size_t size) { _has_bits_[0] |= 0x00000004u; syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) } inline std::string* FileDescriptorProto::_internal_mutable_syntax() { _has_bits_[0] |= 0x00000004u; - return syntax_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return syntax_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileDescriptorProto::release_syntax() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax) @@ -8013,7 +7676,7 @@ inline std::string* FileDescriptorProto::release_syntax() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return syntax_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return syntax_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileDescriptorProto::set_allocated_syntax(std::string* syntax) { if (syntax != nullptr) { @@ -8022,26 +7685,26 @@ inline void FileDescriptorProto::set_allocated_syntax(std::string* syntax) { _has_bits_[0] &= ~0x00000004u; } syntax_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), syntax, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } inline std::string* FileDescriptorProto::unsafe_arena_release_syntax() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.syntax) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000004u; return syntax_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileDescriptorProto::unsafe_arena_set_allocated_syntax( std::string* syntax) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (syntax != nullptr) { _has_bits_[0] |= 0x00000004u; } else { _has_bits_[0] &= ~0x00000004u; } syntax_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - syntax, GetArenaNoVirtual()); + syntax, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.syntax) } @@ -8127,9 +7790,22 @@ inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_Exten // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.options) return _internal_options(); } +inline void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) +} inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -8144,7 +7820,7 @@ inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRa inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::_internal_mutable_options() { _has_bits_[0] |= 0x00000001u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -8154,7 +7830,7 @@ inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRa return _internal_mutable_options(); } inline void DescriptorProto_ExtensionRange::set_allocated_options(PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -8246,7 +7922,7 @@ inline bool DescriptorProto::has_name() const { return _internal_has_name(); } inline void DescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& DescriptorProto::name() const { @@ -8266,31 +7942,31 @@ inline const std::string& DescriptorProto::_internal_name() const { } inline void DescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void DescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name) } inline void DescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name) } inline void DescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) } inline std::string* DescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* DescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name) @@ -8298,7 +7974,7 @@ inline std::string* DescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void DescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -8307,26 +7983,26 @@ inline void DescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name) } inline std::string* DescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.DescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void DescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.name) } @@ -8586,9 +8262,22 @@ inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::options() c // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) return _internal_options(); } +inline void DescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::MessageOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -8603,7 +8292,7 @@ inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::unsafe_arena_rele inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -8613,7 +8302,7 @@ inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::mutable_options() return _internal_mutable_options(); } inline void DescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::MessageOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -8801,7 +8490,7 @@ inline bool FieldDescriptorProto::has_name() const { return _internal_has_name(); } inline void FieldDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& FieldDescriptorProto::name() const { @@ -8821,31 +8510,31 @@ inline const std::string& FieldDescriptorProto::_internal_name() const { } inline void FieldDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FieldDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name) } inline void FieldDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name) } inline void FieldDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) } inline std::string* FieldDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FieldDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name) @@ -8853,7 +8542,7 @@ inline std::string* FieldDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FieldDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -8862,26 +8551,26 @@ inline void FieldDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name) } inline std::string* FieldDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FieldDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.name) } @@ -8915,7 +8604,7 @@ inline void FieldDescriptorProto::set_number(::PROTOBUF_NAMESPACE_ID::int32 valu // optional .google.protobuf.FieldDescriptorProto.Label label = 4; inline bool FieldDescriptorProto::_internal_has_label() const { - bool value = (_has_bits_[0] & 0x00000100u) != 0; + bool value = (_has_bits_[0] & 0x00000200u) != 0; return value; } inline bool FieldDescriptorProto::has_label() const { @@ -8923,7 +8612,7 @@ inline bool FieldDescriptorProto::has_label() const { } inline void FieldDescriptorProto::clear_label() { label_ = 1; - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000200u; } inline PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::_internal_label() const { return static_cast< PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label >(label_); @@ -8934,7 +8623,7 @@ inline PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::l } inline void FieldDescriptorProto::_internal_set_label(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) { assert(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label_IsValid(value)); - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000200u; label_ = value; } inline void FieldDescriptorProto::set_label(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) { @@ -8944,7 +8633,7 @@ inline void FieldDescriptorProto::set_label(PROTOBUF_NAMESPACE_ID::FieldDescript // optional .google.protobuf.FieldDescriptorProto.Type type = 5; inline bool FieldDescriptorProto::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000200u) != 0; + bool value = (_has_bits_[0] & 0x00000400u) != 0; return value; } inline bool FieldDescriptorProto::has_type() const { @@ -8952,7 +8641,7 @@ inline bool FieldDescriptorProto::has_type() const { } inline void FieldDescriptorProto::clear_type() { type_ = 1; - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000400u; } inline PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::_internal_type() const { return static_cast< PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type >(type_); @@ -8963,7 +8652,7 @@ inline PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::ty } inline void FieldDescriptorProto::_internal_set_type(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) { assert(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type_IsValid(value)); - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000400u; type_ = value; } inline void FieldDescriptorProto::set_type(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) { @@ -8980,7 +8669,7 @@ inline bool FieldDescriptorProto::has_type_name() const { return _internal_has_type_name(); } inline void FieldDescriptorProto::clear_type_name() { - type_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + type_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& FieldDescriptorProto::type_name() const { @@ -9000,31 +8689,31 @@ inline const std::string& FieldDescriptorProto::_internal_type_name() const { } inline void FieldDescriptorProto::_internal_set_type_name(const std::string& value) { _has_bits_[0] |= 0x00000004u; - type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FieldDescriptorProto::set_type_name(std::string&& value) { _has_bits_[0] |= 0x00000004u; type_name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name) } inline void FieldDescriptorProto::set_type_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000004u; type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name) } inline void FieldDescriptorProto::set_type_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000004u; type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) } inline std::string* FieldDescriptorProto::_internal_mutable_type_name() { _has_bits_[0] |= 0x00000004u; - return type_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return type_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FieldDescriptorProto::release_type_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name) @@ -9032,7 +8721,7 @@ inline std::string* FieldDescriptorProto::release_type_name() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return type_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return type_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FieldDescriptorProto::set_allocated_type_name(std::string* type_name) { if (type_name != nullptr) { @@ -9041,26 +8730,26 @@ inline void FieldDescriptorProto::set_allocated_type_name(std::string* type_name _has_bits_[0] &= ~0x00000004u; } type_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name) } inline std::string* FieldDescriptorProto::unsafe_arena_release_type_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.type_name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000004u; return type_name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FieldDescriptorProto::unsafe_arena_set_allocated_type_name( std::string* type_name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (type_name != nullptr) { _has_bits_[0] |= 0x00000004u; } else { _has_bits_[0] &= ~0x00000004u; } type_name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - type_name, GetArenaNoVirtual()); + type_name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.type_name) } @@ -9073,7 +8762,7 @@ inline bool FieldDescriptorProto::has_extendee() const { return _internal_has_extendee(); } inline void FieldDescriptorProto::clear_extendee() { - extendee_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + extendee_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& FieldDescriptorProto::extendee() const { @@ -9093,31 +8782,31 @@ inline const std::string& FieldDescriptorProto::_internal_extendee() const { } inline void FieldDescriptorProto::_internal_set_extendee(const std::string& value) { _has_bits_[0] |= 0x00000002u; - extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FieldDescriptorProto::set_extendee(std::string&& value) { _has_bits_[0] |= 0x00000002u; extendee_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee) } inline void FieldDescriptorProto::set_extendee(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee) } inline void FieldDescriptorProto::set_extendee(const char* value, size_t size) { _has_bits_[0] |= 0x00000002u; extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) } inline std::string* FieldDescriptorProto::_internal_mutable_extendee() { _has_bits_[0] |= 0x00000002u; - return extendee_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return extendee_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FieldDescriptorProto::release_extendee() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee) @@ -9125,7 +8814,7 @@ inline std::string* FieldDescriptorProto::release_extendee() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return extendee_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return extendee_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FieldDescriptorProto::set_allocated_extendee(std::string* extendee) { if (extendee != nullptr) { @@ -9134,26 +8823,26 @@ inline void FieldDescriptorProto::set_allocated_extendee(std::string* extendee) _has_bits_[0] &= ~0x00000002u; } extendee_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), extendee, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee) } inline std::string* FieldDescriptorProto::unsafe_arena_release_extendee() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.extendee) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000002u; return extendee_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FieldDescriptorProto::unsafe_arena_set_allocated_extendee( std::string* extendee) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (extendee != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } extendee_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - extendee, GetArenaNoVirtual()); + extendee, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.extendee) } @@ -9166,7 +8855,7 @@ inline bool FieldDescriptorProto::has_default_value() const { return _internal_has_default_value(); } inline void FieldDescriptorProto::clear_default_value() { - default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000008u; } inline const std::string& FieldDescriptorProto::default_value() const { @@ -9186,31 +8875,31 @@ inline const std::string& FieldDescriptorProto::_internal_default_value() const } inline void FieldDescriptorProto::_internal_set_default_value(const std::string& value) { _has_bits_[0] |= 0x00000008u; - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FieldDescriptorProto::set_default_value(std::string&& value) { _has_bits_[0] |= 0x00000008u; default_value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value) } inline void FieldDescriptorProto::set_default_value(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000008u; default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value) } inline void FieldDescriptorProto::set_default_value(const char* value, size_t size) { _has_bits_[0] |= 0x00000008u; default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) } inline std::string* FieldDescriptorProto::_internal_mutable_default_value() { _has_bits_[0] |= 0x00000008u; - return default_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return default_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FieldDescriptorProto::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value) @@ -9218,7 +8907,7 @@ inline std::string* FieldDescriptorProto::release_default_value() { return nullptr; } _has_bits_[0] &= ~0x00000008u; - return default_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return default_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FieldDescriptorProto::set_allocated_default_value(std::string* default_value) { if (default_value != nullptr) { @@ -9227,26 +8916,26 @@ inline void FieldDescriptorProto::set_allocated_default_value(std::string* defau _has_bits_[0] &= ~0x00000008u; } default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value) } inline std::string* FieldDescriptorProto::unsafe_arena_release_default_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.default_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000008u; return default_value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FieldDescriptorProto::unsafe_arena_set_allocated_default_value( std::string* default_value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (default_value != nullptr) { _has_bits_[0] |= 0x00000008u; } else { _has_bits_[0] &= ~0x00000008u; } default_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - default_value, GetArenaNoVirtual()); + default_value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.default_value) } @@ -9287,7 +8976,7 @@ inline bool FieldDescriptorProto::has_json_name() const { return _internal_has_json_name(); } inline void FieldDescriptorProto::clear_json_name() { - json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000010u; } inline const std::string& FieldDescriptorProto::json_name() const { @@ -9307,31 +8996,31 @@ inline const std::string& FieldDescriptorProto::_internal_json_name() const { } inline void FieldDescriptorProto::_internal_set_json_name(const std::string& value) { _has_bits_[0] |= 0x00000010u; - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FieldDescriptorProto::set_json_name(std::string&& value) { _has_bits_[0] |= 0x00000010u; json_name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name) } inline void FieldDescriptorProto::set_json_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000010u; json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name) } inline void FieldDescriptorProto::set_json_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000010u; json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) } inline std::string* FieldDescriptorProto::_internal_mutable_json_name() { _has_bits_[0] |= 0x00000010u; - return json_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return json_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FieldDescriptorProto::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name) @@ -9339,7 +9028,7 @@ inline std::string* FieldDescriptorProto::release_json_name() { return nullptr; } _has_bits_[0] &= ~0x00000010u; - return json_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return json_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FieldDescriptorProto::set_allocated_json_name(std::string* json_name) { if (json_name != nullptr) { @@ -9348,26 +9037,26 @@ inline void FieldDescriptorProto::set_allocated_json_name(std::string* json_name _has_bits_[0] &= ~0x00000010u; } json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name) } inline std::string* FieldDescriptorProto::unsafe_arena_release_json_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.json_name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000010u; return json_name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FieldDescriptorProto::unsafe_arena_set_allocated_json_name( std::string* json_name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (json_name != nullptr) { _has_bits_[0] |= 0x00000010u; } else { _has_bits_[0] &= ~0x00000010u; } json_name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - json_name, GetArenaNoVirtual()); + json_name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.json_name) } @@ -9393,9 +9082,22 @@ inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::options( // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) return _internal_options(); } +inline void FieldDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::FieldOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000020u; + } else { + _has_bits_[0] &= ~0x00000020u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -9410,7 +9112,7 @@ inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::unsafe_arena_r inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000020u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -9420,7 +9122,7 @@ inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::mutable_option return _internal_mutable_options(); } inline void FieldDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::FieldOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -9439,6 +9141,34 @@ inline void FieldDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::F // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } +// optional bool proto3_optional = 17; +inline bool FieldDescriptorProto::_internal_has_proto3_optional() const { + bool value = (_has_bits_[0] & 0x00000100u) != 0; + return value; +} +inline bool FieldDescriptorProto::has_proto3_optional() const { + return _internal_has_proto3_optional(); +} +inline void FieldDescriptorProto::clear_proto3_optional() { + proto3_optional_ = false; + _has_bits_[0] &= ~0x00000100u; +} +inline bool FieldDescriptorProto::_internal_proto3_optional() const { + return proto3_optional_; +} +inline bool FieldDescriptorProto::proto3_optional() const { + // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.proto3_optional) + return _internal_proto3_optional(); +} +inline void FieldDescriptorProto::_internal_set_proto3_optional(bool value) { + _has_bits_[0] |= 0x00000100u; + proto3_optional_ = value; +} +inline void FieldDescriptorProto::set_proto3_optional(bool value) { + _internal_set_proto3_optional(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.proto3_optional) +} + // ------------------------------------------------------------------- // OneofDescriptorProto @@ -9452,7 +9182,7 @@ inline bool OneofDescriptorProto::has_name() const { return _internal_has_name(); } inline void OneofDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& OneofDescriptorProto::name() const { @@ -9472,31 +9202,31 @@ inline const std::string& OneofDescriptorProto::_internal_name() const { } inline void OneofDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void OneofDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name) } inline void OneofDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name) } inline void OneofDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) } inline std::string* OneofDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* OneofDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name) @@ -9504,7 +9234,7 @@ inline std::string* OneofDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void OneofDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -9513,26 +9243,26 @@ inline void OneofDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name) } inline std::string* OneofDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.OneofDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void OneofDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.name) } @@ -9558,9 +9288,22 @@ inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::options( // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) return _internal_options(); } +inline void OneofDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::OneofOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -9575,7 +9318,7 @@ inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::unsafe_arena_r inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -9585,7 +9328,7 @@ inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::mutable_option return _internal_mutable_options(); } inline void OneofDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::OneofOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -9677,7 +9420,7 @@ inline bool EnumDescriptorProto::has_name() const { return _internal_has_name(); } inline void EnumDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& EnumDescriptorProto::name() const { @@ -9697,31 +9440,31 @@ inline const std::string& EnumDescriptorProto::_internal_name() const { } inline void EnumDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void EnumDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name) } inline void EnumDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name) } inline void EnumDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) } inline std::string* EnumDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* EnumDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name) @@ -9729,7 +9472,7 @@ inline std::string* EnumDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void EnumDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -9738,26 +9481,26 @@ inline void EnumDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name) } inline std::string* EnumDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void EnumDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.name) } @@ -9822,9 +9565,22 @@ inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::options() // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) return _internal_options(); } +inline void EnumDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::EnumOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -9839,7 +9595,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::unsafe_arena_rel inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -9849,7 +9605,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::mutable_options( return _internal_mutable_options(); } inline void EnumDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::EnumOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -9994,7 +9750,7 @@ inline bool EnumValueDescriptorProto::has_name() const { return _internal_has_name(); } inline void EnumValueDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& EnumValueDescriptorProto::name() const { @@ -10014,31 +9770,31 @@ inline const std::string& EnumValueDescriptorProto::_internal_name() const { } inline void EnumValueDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void EnumValueDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name) } inline void EnumValueDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name) } inline void EnumValueDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) } inline std::string* EnumValueDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* EnumValueDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name) @@ -10046,7 +9802,7 @@ inline std::string* EnumValueDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void EnumValueDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -10055,26 +9811,26 @@ inline void EnumValueDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name) } inline std::string* EnumValueDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValueDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void EnumValueDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.name) } @@ -10128,9 +9884,22 @@ inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto:: // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) return _internal_options(); } +inline void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -10145,7 +9914,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::unsafe inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -10155,7 +9924,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::mutabl return _internal_mutable_options(); } inline void EnumValueDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -10187,7 +9956,7 @@ inline bool ServiceDescriptorProto::has_name() const { return _internal_has_name(); } inline void ServiceDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& ServiceDescriptorProto::name() const { @@ -10207,31 +9976,31 @@ inline const std::string& ServiceDescriptorProto::_internal_name() const { } inline void ServiceDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void ServiceDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name) } inline void ServiceDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name) } inline void ServiceDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) } inline std::string* ServiceDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* ServiceDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name) @@ -10239,7 +10008,7 @@ inline std::string* ServiceDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void ServiceDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -10248,26 +10017,26 @@ inline void ServiceDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name) } inline std::string* ServiceDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.ServiceDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void ServiceDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.name) } @@ -10332,9 +10101,22 @@ inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::opti // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) return _internal_options(); } +inline void ServiceDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -10349,7 +10131,7 @@ inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::unsafe_are inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -10359,7 +10141,7 @@ inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::mutable_op return _internal_mutable_options(); } inline void ServiceDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -10391,7 +10173,7 @@ inline bool MethodDescriptorProto::has_name() const { return _internal_has_name(); } inline void MethodDescriptorProto::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& MethodDescriptorProto::name() const { @@ -10411,31 +10193,31 @@ inline const std::string& MethodDescriptorProto::_internal_name() const { } inline void MethodDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void MethodDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name) } inline void MethodDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name) } inline void MethodDescriptorProto::set_name(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) } inline std::string* MethodDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* MethodDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name) @@ -10443,7 +10225,7 @@ inline std::string* MethodDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void MethodDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -10452,26 +10234,26 @@ inline void MethodDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name) } inline std::string* MethodDescriptorProto::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void MethodDescriptorProto::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.name) } @@ -10484,7 +10266,7 @@ inline bool MethodDescriptorProto::has_input_type() const { return _internal_has_input_type(); } inline void MethodDescriptorProto::clear_input_type() { - input_type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + input_type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& MethodDescriptorProto::input_type() const { @@ -10504,31 +10286,31 @@ inline const std::string& MethodDescriptorProto::_internal_input_type() const { } inline void MethodDescriptorProto::_internal_set_input_type(const std::string& value) { _has_bits_[0] |= 0x00000002u; - input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void MethodDescriptorProto::set_input_type(std::string&& value) { _has_bits_[0] |= 0x00000002u; input_type_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type) } inline void MethodDescriptorProto::set_input_type(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type) } inline void MethodDescriptorProto::set_input_type(const char* value, size_t size) { _has_bits_[0] |= 0x00000002u; input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) } inline std::string* MethodDescriptorProto::_internal_mutable_input_type() { _has_bits_[0] |= 0x00000002u; - return input_type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return input_type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* MethodDescriptorProto::release_input_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type) @@ -10536,7 +10318,7 @@ inline std::string* MethodDescriptorProto::release_input_type() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return input_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return input_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void MethodDescriptorProto::set_allocated_input_type(std::string* input_type) { if (input_type != nullptr) { @@ -10545,26 +10327,26 @@ inline void MethodDescriptorProto::set_allocated_input_type(std::string* input_t _has_bits_[0] &= ~0x00000002u; } input_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), input_type, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type) } inline std::string* MethodDescriptorProto::unsafe_arena_release_input_type() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.input_type) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000002u; return input_type_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void MethodDescriptorProto::unsafe_arena_set_allocated_input_type( std::string* input_type) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (input_type != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } input_type_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - input_type, GetArenaNoVirtual()); + input_type, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.input_type) } @@ -10577,7 +10359,7 @@ inline bool MethodDescriptorProto::has_output_type() const { return _internal_has_output_type(); } inline void MethodDescriptorProto::clear_output_type() { - output_type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + output_type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& MethodDescriptorProto::output_type() const { @@ -10597,31 +10379,31 @@ inline const std::string& MethodDescriptorProto::_internal_output_type() const { } inline void MethodDescriptorProto::_internal_set_output_type(const std::string& value) { _has_bits_[0] |= 0x00000004u; - output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void MethodDescriptorProto::set_output_type(std::string&& value) { _has_bits_[0] |= 0x00000004u; output_type_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type) } inline void MethodDescriptorProto::set_output_type(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000004u; output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type) } inline void MethodDescriptorProto::set_output_type(const char* value, size_t size) { _has_bits_[0] |= 0x00000004u; output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) } inline std::string* MethodDescriptorProto::_internal_mutable_output_type() { _has_bits_[0] |= 0x00000004u; - return output_type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return output_type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* MethodDescriptorProto::release_output_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type) @@ -10629,7 +10411,7 @@ inline std::string* MethodDescriptorProto::release_output_type() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return output_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return output_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void MethodDescriptorProto::set_allocated_output_type(std::string* output_type) { if (output_type != nullptr) { @@ -10638,26 +10420,26 @@ inline void MethodDescriptorProto::set_allocated_output_type(std::string* output _has_bits_[0] &= ~0x00000004u; } output_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), output_type, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type) } inline std::string* MethodDescriptorProto::unsafe_arena_release_output_type() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.output_type) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000004u; return output_type_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void MethodDescriptorProto::unsafe_arena_set_allocated_output_type( std::string* output_type) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (output_type != nullptr) { _has_bits_[0] |= 0x00000004u; } else { _has_bits_[0] &= ~0x00000004u; } output_type_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - output_type, GetArenaNoVirtual()); + output_type, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.output_type) } @@ -10683,9 +10465,22 @@ inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::option // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) return _internal_options(); } +inline void MethodDescriptorProto::unsafe_arena_set_allocated_options( + PROTOBUF_NAMESPACE_ID::MethodOptions* options) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + } + options_ = options; + if (options) { + _has_bits_[0] |= 0x00000008u; + } else { + _has_bits_[0] &= ~0x00000008u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.options) +} inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::release_options() { auto temp = unsafe_arena_release_options(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -10700,7 +10495,7 @@ inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::unsafe_arena inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000008u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); options_ = p; } return options_; @@ -10710,7 +10505,7 @@ inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::mutable_opti return _internal_mutable_options(); } inline void MethodDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::MethodOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete options_; } @@ -10798,7 +10593,7 @@ inline bool FileOptions::has_java_package() const { return _internal_has_java_package(); } inline void FileOptions::clear_java_package() { - java_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + java_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& FileOptions::java_package() const { @@ -10818,31 +10613,31 @@ inline const std::string& FileOptions::_internal_java_package() const { } inline void FileOptions::_internal_set_java_package(const std::string& value) { _has_bits_[0] |= 0x00000001u; - java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_java_package(std::string&& value) { _has_bits_[0] |= 0x00000001u; java_package_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package) } inline void FileOptions::set_java_package(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package) } inline void FileOptions::set_java_package(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) } inline std::string* FileOptions::_internal_mutable_java_package() { _has_bits_[0] |= 0x00000001u; - return java_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return java_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_java_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package) @@ -10850,7 +10645,7 @@ inline std::string* FileOptions::release_java_package() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return java_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return java_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_java_package(std::string* java_package) { if (java_package != nullptr) { @@ -10859,26 +10654,26 @@ inline void FileOptions::set_allocated_java_package(std::string* java_package) { _has_bits_[0] &= ~0x00000001u; } java_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_package, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package) } inline std::string* FileOptions::unsafe_arena_release_java_package() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.java_package) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return java_package_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_java_package( std::string* java_package) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (java_package != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } java_package_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - java_package, GetArenaNoVirtual()); + java_package, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.java_package) } @@ -10891,7 +10686,7 @@ inline bool FileOptions::has_java_outer_classname() const { return _internal_has_java_outer_classname(); } inline void FileOptions::clear_java_outer_classname() { - java_outer_classname_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + java_outer_classname_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& FileOptions::java_outer_classname() const { @@ -10911,31 +10706,31 @@ inline const std::string& FileOptions::_internal_java_outer_classname() const { } inline void FileOptions::_internal_set_java_outer_classname(const std::string& value) { _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_java_outer_classname(std::string&& value) { _has_bits_[0] |= 0x00000002u; java_outer_classname_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname) } inline void FileOptions::set_java_outer_classname(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname) } inline void FileOptions::set_java_outer_classname(const char* value, size_t size) { _has_bits_[0] |= 0x00000002u; java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) } inline std::string* FileOptions::_internal_mutable_java_outer_classname() { _has_bits_[0] |= 0x00000002u; - return java_outer_classname_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return java_outer_classname_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_java_outer_classname() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname) @@ -10943,7 +10738,7 @@ inline std::string* FileOptions::release_java_outer_classname() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return java_outer_classname_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return java_outer_classname_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_java_outer_classname(std::string* java_outer_classname) { if (java_outer_classname != nullptr) { @@ -10952,26 +10747,26 @@ inline void FileOptions::set_allocated_java_outer_classname(std::string* java_ou _has_bits_[0] &= ~0x00000002u; } java_outer_classname_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_outer_classname, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname) } inline std::string* FileOptions::unsafe_arena_release_java_outer_classname() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.java_outer_classname) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000002u; return java_outer_classname_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_java_outer_classname( std::string* java_outer_classname) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (java_outer_classname != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } java_outer_classname_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - java_outer_classname, GetArenaNoVirtual()); + java_outer_classname, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.java_outer_classname) } @@ -11061,7 +10856,7 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::_internal_has_optimize_for() const { - bool value = (_has_bits_[0] & 0x00080000u) != 0; + bool value = (_has_bits_[0] & 0x00040000u) != 0; return value; } inline bool FileOptions::has_optimize_for() const { @@ -11069,7 +10864,7 @@ inline bool FileOptions::has_optimize_for() const { } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; - _has_bits_[0] &= ~0x00080000u; + _has_bits_[0] &= ~0x00040000u; } inline PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::_internal_optimize_for() const { return static_cast< PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode >(optimize_for_); @@ -11080,7 +10875,7 @@ inline PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::optimize_for } inline void FileOptions::_internal_set_optimize_for(PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) { assert(PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode_IsValid(value)); - _has_bits_[0] |= 0x00080000u; + _has_bits_[0] |= 0x00040000u; optimize_for_ = value; } inline void FileOptions::set_optimize_for(PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) { @@ -11097,7 +10892,7 @@ inline bool FileOptions::has_go_package() const { return _internal_has_go_package(); } inline void FileOptions::clear_go_package() { - go_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + go_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& FileOptions::go_package() const { @@ -11117,31 +10912,31 @@ inline const std::string& FileOptions::_internal_go_package() const { } inline void FileOptions::_internal_set_go_package(const std::string& value) { _has_bits_[0] |= 0x00000004u; - go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_go_package(std::string&& value) { _has_bits_[0] |= 0x00000004u; go_package_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package) } inline void FileOptions::set_go_package(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000004u; go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package) } inline void FileOptions::set_go_package(const char* value, size_t size) { _has_bits_[0] |= 0x00000004u; go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) } inline std::string* FileOptions::_internal_mutable_go_package() { _has_bits_[0] |= 0x00000004u; - return go_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return go_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_go_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package) @@ -11149,7 +10944,7 @@ inline std::string* FileOptions::release_go_package() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return go_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return go_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_go_package(std::string* go_package) { if (go_package != nullptr) { @@ -11158,26 +10953,26 @@ inline void FileOptions::set_allocated_go_package(std::string* go_package) { _has_bits_[0] &= ~0x00000004u; } go_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), go_package, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package) } inline std::string* FileOptions::unsafe_arena_release_go_package() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.go_package) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000004u; return go_package_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_go_package( std::string* go_package) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (go_package != nullptr) { _has_bits_[0] |= 0x00000004u; } else { _has_bits_[0] &= ~0x00000004u; } go_package_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - go_package, GetArenaNoVirtual()); + go_package, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.go_package) } @@ -11321,17 +11116,17 @@ inline void FileOptions::set_deprecated(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated) } -// optional bool cc_enable_arenas = 31 [default = false]; +// optional bool cc_enable_arenas = 31 [default = true]; inline bool FileOptions::_internal_has_cc_enable_arenas() const { - bool value = (_has_bits_[0] & 0x00040000u) != 0; + bool value = (_has_bits_[0] & 0x00080000u) != 0; return value; } inline bool FileOptions::has_cc_enable_arenas() const { return _internal_has_cc_enable_arenas(); } inline void FileOptions::clear_cc_enable_arenas() { - cc_enable_arenas_ = false; - _has_bits_[0] &= ~0x00040000u; + cc_enable_arenas_ = true; + _has_bits_[0] &= ~0x00080000u; } inline bool FileOptions::_internal_cc_enable_arenas() const { return cc_enable_arenas_; @@ -11341,7 +11136,7 @@ inline bool FileOptions::cc_enable_arenas() const { return _internal_cc_enable_arenas(); } inline void FileOptions::_internal_set_cc_enable_arenas(bool value) { - _has_bits_[0] |= 0x00040000u; + _has_bits_[0] |= 0x00080000u; cc_enable_arenas_ = value; } inline void FileOptions::set_cc_enable_arenas(bool value) { @@ -11358,7 +11153,7 @@ inline bool FileOptions::has_objc_class_prefix() const { return _internal_has_objc_class_prefix(); } inline void FileOptions::clear_objc_class_prefix() { - objc_class_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + objc_class_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000008u; } inline const std::string& FileOptions::objc_class_prefix() const { @@ -11378,31 +11173,31 @@ inline const std::string& FileOptions::_internal_objc_class_prefix() const { } inline void FileOptions::_internal_set_objc_class_prefix(const std::string& value) { _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_objc_class_prefix(std::string&& value) { _has_bits_[0] |= 0x00000008u; objc_class_prefix_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix) } inline void FileOptions::set_objc_class_prefix(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000008u; objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix) } inline void FileOptions::set_objc_class_prefix(const char* value, size_t size) { _has_bits_[0] |= 0x00000008u; objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) } inline std::string* FileOptions::_internal_mutable_objc_class_prefix() { _has_bits_[0] |= 0x00000008u; - return objc_class_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return objc_class_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_objc_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix) @@ -11410,7 +11205,7 @@ inline std::string* FileOptions::release_objc_class_prefix() { return nullptr; } _has_bits_[0] &= ~0x00000008u; - return objc_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return objc_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_objc_class_prefix(std::string* objc_class_prefix) { if (objc_class_prefix != nullptr) { @@ -11419,26 +11214,26 @@ inline void FileOptions::set_allocated_objc_class_prefix(std::string* objc_class _has_bits_[0] &= ~0x00000008u; } objc_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), objc_class_prefix, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) } inline std::string* FileOptions::unsafe_arena_release_objc_class_prefix() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.objc_class_prefix) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000008u; return objc_class_prefix_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_objc_class_prefix( std::string* objc_class_prefix) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (objc_class_prefix != nullptr) { _has_bits_[0] |= 0x00000008u; } else { _has_bits_[0] &= ~0x00000008u; } objc_class_prefix_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - objc_class_prefix, GetArenaNoVirtual()); + objc_class_prefix, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.objc_class_prefix) } @@ -11451,7 +11246,7 @@ inline bool FileOptions::has_csharp_namespace() const { return _internal_has_csharp_namespace(); } inline void FileOptions::clear_csharp_namespace() { - csharp_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + csharp_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000010u; } inline const std::string& FileOptions::csharp_namespace() const { @@ -11471,31 +11266,31 @@ inline const std::string& FileOptions::_internal_csharp_namespace() const { } inline void FileOptions::_internal_set_csharp_namespace(const std::string& value) { _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_csharp_namespace(std::string&& value) { _has_bits_[0] |= 0x00000010u; csharp_namespace_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace) } inline void FileOptions::set_csharp_namespace(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000010u; csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) } inline void FileOptions::set_csharp_namespace(const char* value, size_t size) { _has_bits_[0] |= 0x00000010u; csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) } inline std::string* FileOptions::_internal_mutable_csharp_namespace() { _has_bits_[0] |= 0x00000010u; - return csharp_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return csharp_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_csharp_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace) @@ -11503,7 +11298,7 @@ inline std::string* FileOptions::release_csharp_namespace() { return nullptr; } _has_bits_[0] &= ~0x00000010u; - return csharp_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return csharp_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_csharp_namespace(std::string* csharp_namespace) { if (csharp_namespace != nullptr) { @@ -11512,26 +11307,26 @@ inline void FileOptions::set_allocated_csharp_namespace(std::string* csharp_name _has_bits_[0] &= ~0x00000010u; } csharp_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), csharp_namespace, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } inline std::string* FileOptions::unsafe_arena_release_csharp_namespace() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.csharp_namespace) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000010u; return csharp_namespace_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_csharp_namespace( std::string* csharp_namespace) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (csharp_namespace != nullptr) { _has_bits_[0] |= 0x00000010u; } else { _has_bits_[0] &= ~0x00000010u; } csharp_namespace_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - csharp_namespace, GetArenaNoVirtual()); + csharp_namespace, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.csharp_namespace) } @@ -11544,7 +11339,7 @@ inline bool FileOptions::has_swift_prefix() const { return _internal_has_swift_prefix(); } inline void FileOptions::clear_swift_prefix() { - swift_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + swift_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000020u; } inline const std::string& FileOptions::swift_prefix() const { @@ -11564,31 +11359,31 @@ inline const std::string& FileOptions::_internal_swift_prefix() const { } inline void FileOptions::_internal_set_swift_prefix(const std::string& value) { _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_swift_prefix(std::string&& value) { _has_bits_[0] |= 0x00000020u; swift_prefix_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix) } inline void FileOptions::set_swift_prefix(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000020u; swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) } inline void FileOptions::set_swift_prefix(const char* value, size_t size) { _has_bits_[0] |= 0x00000020u; swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) } inline std::string* FileOptions::_internal_mutable_swift_prefix() { _has_bits_[0] |= 0x00000020u; - return swift_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return swift_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_swift_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) @@ -11596,7 +11391,7 @@ inline std::string* FileOptions::release_swift_prefix() { return nullptr; } _has_bits_[0] &= ~0x00000020u; - return swift_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return swift_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_swift_prefix(std::string* swift_prefix) { if (swift_prefix != nullptr) { @@ -11605,26 +11400,26 @@ inline void FileOptions::set_allocated_swift_prefix(std::string* swift_prefix) { _has_bits_[0] &= ~0x00000020u; } swift_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), swift_prefix, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) } inline std::string* FileOptions::unsafe_arena_release_swift_prefix() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.swift_prefix) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000020u; return swift_prefix_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_swift_prefix( std::string* swift_prefix) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (swift_prefix != nullptr) { _has_bits_[0] |= 0x00000020u; } else { _has_bits_[0] &= ~0x00000020u; } swift_prefix_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - swift_prefix, GetArenaNoVirtual()); + swift_prefix, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.swift_prefix) } @@ -11637,7 +11432,7 @@ inline bool FileOptions::has_php_class_prefix() const { return _internal_has_php_class_prefix(); } inline void FileOptions::clear_php_class_prefix() { - php_class_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + php_class_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000040u; } inline const std::string& FileOptions::php_class_prefix() const { @@ -11657,31 +11452,31 @@ inline const std::string& FileOptions::_internal_php_class_prefix() const { } inline void FileOptions::_internal_set_php_class_prefix(const std::string& value) { _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_php_class_prefix(std::string&& value) { _has_bits_[0] |= 0x00000040u; php_class_prefix_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix) } inline void FileOptions::set_php_class_prefix(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000040u; php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix) } inline void FileOptions::set_php_class_prefix(const char* value, size_t size) { _has_bits_[0] |= 0x00000040u; php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) } inline std::string* FileOptions::_internal_mutable_php_class_prefix() { _has_bits_[0] |= 0x00000040u; - return php_class_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return php_class_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_php_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) @@ -11689,7 +11484,7 @@ inline std::string* FileOptions::release_php_class_prefix() { return nullptr; } _has_bits_[0] &= ~0x00000040u; - return php_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return php_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_php_class_prefix(std::string* php_class_prefix) { if (php_class_prefix != nullptr) { @@ -11698,26 +11493,26 @@ inline void FileOptions::set_allocated_php_class_prefix(std::string* php_class_p _has_bits_[0] &= ~0x00000040u; } php_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_class_prefix, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) } inline std::string* FileOptions::unsafe_arena_release_php_class_prefix() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.php_class_prefix) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000040u; return php_class_prefix_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_php_class_prefix( std::string* php_class_prefix) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (php_class_prefix != nullptr) { _has_bits_[0] |= 0x00000040u; } else { _has_bits_[0] &= ~0x00000040u; } php_class_prefix_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - php_class_prefix, GetArenaNoVirtual()); + php_class_prefix, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_class_prefix) } @@ -11730,7 +11525,7 @@ inline bool FileOptions::has_php_namespace() const { return _internal_has_php_namespace(); } inline void FileOptions::clear_php_namespace() { - php_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + php_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000080u; } inline const std::string& FileOptions::php_namespace() const { @@ -11750,31 +11545,31 @@ inline const std::string& FileOptions::_internal_php_namespace() const { } inline void FileOptions::_internal_set_php_namespace(const std::string& value) { _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_php_namespace(std::string&& value) { _has_bits_[0] |= 0x00000080u; php_namespace_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_namespace) } inline void FileOptions::set_php_namespace(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000080u; php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_namespace) } inline void FileOptions::set_php_namespace(const char* value, size_t size) { _has_bits_[0] |= 0x00000080u; php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace) } inline std::string* FileOptions::_internal_mutable_php_namespace() { _has_bits_[0] |= 0x00000080u; - return php_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return php_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_php_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace) @@ -11782,7 +11577,7 @@ inline std::string* FileOptions::release_php_namespace() { return nullptr; } _has_bits_[0] &= ~0x00000080u; - return php_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return php_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_php_namespace(std::string* php_namespace) { if (php_namespace != nullptr) { @@ -11791,26 +11586,26 @@ inline void FileOptions::set_allocated_php_namespace(std::string* php_namespace) _has_bits_[0] &= ~0x00000080u; } php_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_namespace, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace) } inline std::string* FileOptions::unsafe_arena_release_php_namespace() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.php_namespace) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000080u; return php_namespace_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_php_namespace( std::string* php_namespace) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (php_namespace != nullptr) { _has_bits_[0] |= 0x00000080u; } else { _has_bits_[0] &= ~0x00000080u; } php_namespace_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - php_namespace, GetArenaNoVirtual()); + php_namespace, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_namespace) } @@ -11823,7 +11618,7 @@ inline bool FileOptions::has_php_metadata_namespace() const { return _internal_has_php_metadata_namespace(); } inline void FileOptions::clear_php_metadata_namespace() { - php_metadata_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + php_metadata_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000100u; } inline const std::string& FileOptions::php_metadata_namespace() const { @@ -11843,31 +11638,31 @@ inline const std::string& FileOptions::_internal_php_metadata_namespace() const } inline void FileOptions::_internal_set_php_metadata_namespace(const std::string& value) { _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_php_metadata_namespace(std::string&& value) { _has_bits_[0] |= 0x00000100u; php_metadata_namespace_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_metadata_namespace) } inline void FileOptions::set_php_metadata_namespace(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000100u; php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_metadata_namespace) } inline void FileOptions::set_php_metadata_namespace(const char* value, size_t size) { _has_bits_[0] |= 0x00000100u; php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_metadata_namespace) } inline std::string* FileOptions::_internal_mutable_php_metadata_namespace() { _has_bits_[0] |= 0x00000100u; - return php_metadata_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return php_metadata_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_php_metadata_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_metadata_namespace) @@ -11875,7 +11670,7 @@ inline std::string* FileOptions::release_php_metadata_namespace() { return nullptr; } _has_bits_[0] &= ~0x00000100u; - return php_metadata_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return php_metadata_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_php_metadata_namespace(std::string* php_metadata_namespace) { if (php_metadata_namespace != nullptr) { @@ -11884,26 +11679,26 @@ inline void FileOptions::set_allocated_php_metadata_namespace(std::string* php_m _has_bits_[0] &= ~0x00000100u; } php_metadata_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_metadata_namespace, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_metadata_namespace) } inline std::string* FileOptions::unsafe_arena_release_php_metadata_namespace() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.php_metadata_namespace) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000100u; return php_metadata_namespace_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_php_metadata_namespace( std::string* php_metadata_namespace) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (php_metadata_namespace != nullptr) { _has_bits_[0] |= 0x00000100u; } else { _has_bits_[0] &= ~0x00000100u; } php_metadata_namespace_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - php_metadata_namespace, GetArenaNoVirtual()); + php_metadata_namespace, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_metadata_namespace) } @@ -11916,7 +11711,7 @@ inline bool FileOptions::has_ruby_package() const { return _internal_has_ruby_package(); } inline void FileOptions::clear_ruby_package() { - ruby_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + ruby_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000200u; } inline const std::string& FileOptions::ruby_package() const { @@ -11936,31 +11731,31 @@ inline const std::string& FileOptions::_internal_ruby_package() const { } inline void FileOptions::_internal_set_ruby_package(const std::string& value) { _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void FileOptions::set_ruby_package(std::string&& value) { _has_bits_[0] |= 0x00000200u; ruby_package_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.ruby_package) } inline void FileOptions::set_ruby_package(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000200u; ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.ruby_package) } inline void FileOptions::set_ruby_package(const char* value, size_t size) { _has_bits_[0] |= 0x00000200u; ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.ruby_package) } inline std::string* FileOptions::_internal_mutable_ruby_package() { _has_bits_[0] |= 0x00000200u; - return ruby_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return ruby_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* FileOptions::release_ruby_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.ruby_package) @@ -11968,7 +11763,7 @@ inline std::string* FileOptions::release_ruby_package() { return nullptr; } _has_bits_[0] &= ~0x00000200u; - return ruby_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return ruby_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void FileOptions::set_allocated_ruby_package(std::string* ruby_package) { if (ruby_package != nullptr) { @@ -11977,26 +11772,26 @@ inline void FileOptions::set_allocated_ruby_package(std::string* ruby_package) { _has_bits_[0] &= ~0x00000200u; } ruby_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ruby_package, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.ruby_package) } inline std::string* FileOptions::unsafe_arena_release_ruby_package() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.ruby_package) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000200u; return ruby_package_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void FileOptions::unsafe_arena_set_allocated_ruby_package( std::string* ruby_package) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (ruby_package != nullptr) { _has_bits_[0] |= 0x00000200u; } else { _has_bits_[0] &= ~0x00000200u; } ruby_package_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ruby_package, GetArenaNoVirtual()); + ruby_package, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.ruby_package) } @@ -12804,7 +12599,7 @@ inline bool UninterpretedOption_NamePart::has_name_part() const { return _internal_has_name_part(); } inline void UninterpretedOption_NamePart::clear_name_part() { - name_part_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_part_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& UninterpretedOption_NamePart::name_part() const { @@ -12824,31 +12619,31 @@ inline const std::string& UninterpretedOption_NamePart::_internal_name_part() co } inline void UninterpretedOption_NamePart::_internal_set_name_part(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void UninterpretedOption_NamePart::set_name_part(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_part_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part) } inline void UninterpretedOption_NamePart::set_name_part(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) } inline void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) } inline std::string* UninterpretedOption_NamePart::_internal_mutable_name_part() { _has_bits_[0] |= 0x00000001u; - return name_part_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_part_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* UninterpretedOption_NamePart::release_name_part() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) @@ -12856,7 +12651,7 @@ inline std::string* UninterpretedOption_NamePart::release_name_part() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_part_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_part_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void UninterpretedOption_NamePart::set_allocated_name_part(std::string* name_part) { if (name_part != nullptr) { @@ -12865,26 +12660,26 @@ inline void UninterpretedOption_NamePart::set_allocated_name_part(std::string* n _has_bits_[0] &= ~0x00000001u; } name_part_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name_part, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) } inline std::string* UninterpretedOption_NamePart::unsafe_arena_release_name_part() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.NamePart.name_part) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return name_part_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void UninterpretedOption_NamePart::unsafe_arena_set_allocated_name_part( std::string* name_part) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name_part != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } name_part_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name_part, GetArenaNoVirtual()); + name_part, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) } @@ -12968,7 +12763,7 @@ inline bool UninterpretedOption::has_identifier_value() const { return _internal_has_identifier_value(); } inline void UninterpretedOption::clear_identifier_value() { - identifier_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + identifier_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& UninterpretedOption::identifier_value() const { @@ -12988,31 +12783,31 @@ inline const std::string& UninterpretedOption::_internal_identifier_value() cons } inline void UninterpretedOption::_internal_set_identifier_value(const std::string& value) { _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void UninterpretedOption::set_identifier_value(std::string&& value) { _has_bits_[0] |= 0x00000001u; identifier_value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value) } inline void UninterpretedOption::set_identifier_value(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value) } inline void UninterpretedOption::set_identifier_value(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) } inline std::string* UninterpretedOption::_internal_mutable_identifier_value() { _has_bits_[0] |= 0x00000001u; - return identifier_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return identifier_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* UninterpretedOption::release_identifier_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value) @@ -13020,7 +12815,7 @@ inline std::string* UninterpretedOption::release_identifier_value() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return identifier_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return identifier_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void UninterpretedOption::set_allocated_identifier_value(std::string* identifier_value) { if (identifier_value != nullptr) { @@ -13029,26 +12824,26 @@ inline void UninterpretedOption::set_allocated_identifier_value(std::string* ide _has_bits_[0] &= ~0x00000001u; } identifier_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), identifier_value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value) } inline std::string* UninterpretedOption::unsafe_arena_release_identifier_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.identifier_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return identifier_value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void UninterpretedOption::unsafe_arena_set_allocated_identifier_value( std::string* identifier_value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (identifier_value != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } identifier_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - identifier_value, GetArenaNoVirtual()); + identifier_value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.identifier_value) } @@ -13145,7 +12940,7 @@ inline bool UninterpretedOption::has_string_value() const { return _internal_has_string_value(); } inline void UninterpretedOption::clear_string_value() { - string_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + string_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& UninterpretedOption::string_value() const { @@ -13165,31 +12960,31 @@ inline const std::string& UninterpretedOption::_internal_string_value() const { } inline void UninterpretedOption::_internal_set_string_value(const std::string& value) { _has_bits_[0] |= 0x00000002u; - string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void UninterpretedOption::set_string_value(std::string&& value) { _has_bits_[0] |= 0x00000002u; string_value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value) } inline void UninterpretedOption::set_string_value(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value) } inline void UninterpretedOption::set_string_value(const void* value, size_t size) { _has_bits_[0] |= 0x00000002u; string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) } inline std::string* UninterpretedOption::_internal_mutable_string_value() { _has_bits_[0] |= 0x00000002u; - return string_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return string_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* UninterpretedOption::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value) @@ -13197,7 +12992,7 @@ inline std::string* UninterpretedOption::release_string_value() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void UninterpretedOption::set_allocated_string_value(std::string* string_value) { if (string_value != nullptr) { @@ -13206,26 +13001,26 @@ inline void UninterpretedOption::set_allocated_string_value(std::string* string_ _has_bits_[0] &= ~0x00000002u; } string_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value) } inline std::string* UninterpretedOption::unsafe_arena_release_string_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.string_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000002u; return string_value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void UninterpretedOption::unsafe_arena_set_allocated_string_value( std::string* string_value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (string_value != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } string_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - string_value, GetArenaNoVirtual()); + string_value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.string_value) } @@ -13238,7 +13033,7 @@ inline bool UninterpretedOption::has_aggregate_value() const { return _internal_has_aggregate_value(); } inline void UninterpretedOption::clear_aggregate_value() { - aggregate_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + aggregate_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& UninterpretedOption::aggregate_value() const { @@ -13258,31 +13053,31 @@ inline const std::string& UninterpretedOption::_internal_aggregate_value() const } inline void UninterpretedOption::_internal_set_aggregate_value(const std::string& value) { _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void UninterpretedOption::set_aggregate_value(std::string&& value) { _has_bits_[0] |= 0x00000004u; aggregate_value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value) } inline void UninterpretedOption::set_aggregate_value(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000004u; aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value) } inline void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { _has_bits_[0] |= 0x00000004u; aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) } inline std::string* UninterpretedOption::_internal_mutable_aggregate_value() { _has_bits_[0] |= 0x00000004u; - return aggregate_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return aggregate_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* UninterpretedOption::release_aggregate_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value) @@ -13290,7 +13085,7 @@ inline std::string* UninterpretedOption::release_aggregate_value() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return aggregate_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return aggregate_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void UninterpretedOption::set_allocated_aggregate_value(std::string* aggregate_value) { if (aggregate_value != nullptr) { @@ -13299,26 +13094,26 @@ inline void UninterpretedOption::set_allocated_aggregate_value(std::string* aggr _has_bits_[0] &= ~0x00000004u; } aggregate_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), aggregate_value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } inline std::string* UninterpretedOption::unsafe_arena_release_aggregate_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.aggregate_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000004u; return aggregate_value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void UninterpretedOption::unsafe_arena_set_allocated_aggregate_value( std::string* aggregate_value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (aggregate_value != nullptr) { _has_bits_[0] |= 0x00000004u; } else { _has_bits_[0] &= ~0x00000004u; } aggregate_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - aggregate_value, GetArenaNoVirtual()); + aggregate_value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } @@ -13429,7 +13224,7 @@ inline bool SourceCodeInfo_Location::has_leading_comments() const { return _internal_has_leading_comments(); } inline void SourceCodeInfo_Location::clear_leading_comments() { - leading_comments_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + leading_comments_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& SourceCodeInfo_Location::leading_comments() const { @@ -13449,31 +13244,31 @@ inline const std::string& SourceCodeInfo_Location::_internal_leading_comments() } inline void SourceCodeInfo_Location::_internal_set_leading_comments(const std::string& value) { _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void SourceCodeInfo_Location::set_leading_comments(std::string&& value) { _has_bits_[0] |= 0x00000001u; leading_comments_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline void SourceCodeInfo_Location::set_leading_comments(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline std::string* SourceCodeInfo_Location::_internal_mutable_leading_comments() { _has_bits_[0] |= 0x00000001u; - return leading_comments_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return leading_comments_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* SourceCodeInfo_Location::release_leading_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments) @@ -13481,7 +13276,7 @@ inline std::string* SourceCodeInfo_Location::release_leading_comments() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return leading_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return leading_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void SourceCodeInfo_Location::set_allocated_leading_comments(std::string* leading_comments) { if (leading_comments != nullptr) { @@ -13490,26 +13285,26 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(std::string* _has_bits_[0] &= ~0x00000001u; } leading_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), leading_comments, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline std::string* SourceCodeInfo_Location::unsafe_arena_release_leading_comments() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.SourceCodeInfo.Location.leading_comments) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return leading_comments_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void SourceCodeInfo_Location::unsafe_arena_set_allocated_leading_comments( std::string* leading_comments) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (leading_comments != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } leading_comments_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - leading_comments, GetArenaNoVirtual()); + leading_comments, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) } @@ -13522,7 +13317,7 @@ inline bool SourceCodeInfo_Location::has_trailing_comments() const { return _internal_has_trailing_comments(); } inline void SourceCodeInfo_Location::clear_trailing_comments() { - trailing_comments_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + trailing_comments_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& SourceCodeInfo_Location::trailing_comments() const { @@ -13542,31 +13337,31 @@ inline const std::string& SourceCodeInfo_Location::_internal_trailing_comments() } inline void SourceCodeInfo_Location::_internal_set_trailing_comments(const std::string& value) { _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void SourceCodeInfo_Location::set_trailing_comments(std::string&& value) { _has_bits_[0] |= 0x00000002u; trailing_comments_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline void SourceCodeInfo_Location::set_trailing_comments(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { _has_bits_[0] |= 0x00000002u; trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline std::string* SourceCodeInfo_Location::_internal_mutable_trailing_comments() { _has_bits_[0] |= 0x00000002u; - return trailing_comments_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return trailing_comments_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* SourceCodeInfo_Location::release_trailing_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) @@ -13574,7 +13369,7 @@ inline std::string* SourceCodeInfo_Location::release_trailing_comments() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return trailing_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return trailing_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void SourceCodeInfo_Location::set_allocated_trailing_comments(std::string* trailing_comments) { if (trailing_comments != nullptr) { @@ -13583,26 +13378,26 @@ inline void SourceCodeInfo_Location::set_allocated_trailing_comments(std::string _has_bits_[0] &= ~0x00000002u; } trailing_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), trailing_comments, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline std::string* SourceCodeInfo_Location::unsafe_arena_release_trailing_comments() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000002u; return trailing_comments_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void SourceCodeInfo_Location::unsafe_arena_set_allocated_trailing_comments( std::string* trailing_comments) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (trailing_comments != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } trailing_comments_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - trailing_comments, GetArenaNoVirtual()); + trailing_comments, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) } @@ -13783,7 +13578,7 @@ inline bool GeneratedCodeInfo_Annotation::has_source_file() const { return _internal_has_source_file(); } inline void GeneratedCodeInfo_Annotation::clear_source_file() { - source_file_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + source_file_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& GeneratedCodeInfo_Annotation::source_file() const { @@ -13803,31 +13598,31 @@ inline const std::string& GeneratedCodeInfo_Annotation::_internal_source_file() } inline void GeneratedCodeInfo_Annotation::_internal_set_source_file(const std::string& value) { _has_bits_[0] |= 0x00000001u; - source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void GeneratedCodeInfo_Annotation::set_source_file(std::string&& value) { _has_bits_[0] |= 0x00000001u; source_file_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline std::string* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() { _has_bits_[0] |= 0x00000001u; - return source_file_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return source_file_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) @@ -13835,7 +13630,7 @@ inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return source_file_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return source_file_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(std::string* source_file) { if (source_file != nullptr) { @@ -13844,26 +13639,26 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(std::string* _has_bits_[0] &= ~0x00000001u; } source_file_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), source_file, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline std::string* GeneratedCodeInfo_Annotation::unsafe_arena_release_source_file() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); _has_bits_[0] &= ~0x00000001u; return source_file_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void GeneratedCodeInfo_Annotation::unsafe_arena_set_allocated_source_file( std::string* source_file) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (source_file != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } source_file_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - source_file, GetArenaNoVirtual()); + source_file, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index a2102d7aa996..deb8f6894de3 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -129,6 +129,7 @@ message ExtensionRangeOptions { // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; + // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; } @@ -212,6 +213,18 @@ message FieldDescriptorProto { optional string json_name = 10; optional FieldOptions options = 8; + + // If true, this is a proto3 "optional". When a proto3 field is optional, it + // tracks presence regardless of field type. + // + // For message fields this doesn't create any semantic change, since + // non-repeated message fields always track presence. However it still + // indicates the semantic detail of whether the user wrote "optional" or not. + // This can be useful for round-tripping the .proto file. + // + // Proto2 optional fields do not set this flag, because they already indicate + // optional with `LABEL_OPTIONAL`. + optional bool proto3_optional = 17; } // Describes a oneof. @@ -393,7 +406,7 @@ message FileOptions { // Enables the use of arenas for the proto messages in this file. This applies // only to generated classes for C++. - optional bool cc_enable_arenas = 31 [default = false]; + optional bool cc_enable_arenas = 31 [default = true]; // Sets the objective c class prefix which is prepended to all objective c diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index b613148d3da0..30f8bdec5820 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -387,9 +387,10 @@ EncodedDescriptorDatabase::~EncodedDescriptorDatabase() { bool EncodedDescriptorDatabase::Add(const void* encoded_file_descriptor, int size) { - FileDescriptorProto file; - if (file.ParseFromArray(encoded_file_descriptor, size)) { - return index_.AddFile(file, std::make_pair(encoded_file_descriptor, size)); + google::protobuf::Arena arena; + auto* file = google::protobuf::Arena::CreateMessage(&arena); + if (file->ParseFromArray(encoded_file_descriptor, size)) { + return index_.AddFile(*file, std::make_pair(encoded_file_descriptor, size)); } else { GOOGLE_LOG(ERROR) << "Invalid file descriptor data passed to " "EncodedDescriptorDatabase::Add()."; diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 1cd2897d370e..4b8bbc1cc573 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -243,7 +243,7 @@ class MockErrorCollector : public DescriptorPool::ErrorCollector { } strings::SubstituteAndAppend(&text_, "$0: $1: $2: $3\n", filename, - element_name, location_name, message); + element_name, location_name, message); } // implements ErrorCollector --------------------------------------- @@ -287,8 +287,9 @@ class MockErrorCollector : public DescriptorPool::ErrorCollector { break; } - strings::SubstituteAndAppend(&warning_text_, "$0: $1: $2: $3\n", filename, - element_name, location_name, message); + strings::SubstituteAndAppend(&warning_text_, "$0: $1: $2: $3\n", + filename, element_name, location_name, + message); } }; @@ -490,7 +491,7 @@ TEST_F(FileDescriptorTest, BuildAgain) { } TEST_F(FileDescriptorTest, BuildAgainWithSyntax) { - // Test that if te call BuildFile again on the same input we get the same + // Test that if we call BuildFile again on the same input we get the same // FileDescriptor back even if syntax param is specified. FileDescriptorProto proto_syntax2; proto_syntax2.set_name("foo_syntax2"); @@ -2652,9 +2653,11 @@ TEST_F(MiscTest, FieldOptions) { enum DescriptorPoolMode { NO_DATABASE, FALLBACK_DATABASE }; class AllowUnknownDependenciesTest - : public testing::TestWithParam { + : public testing::TestWithParam< + std::tuple> { protected: - DescriptorPoolMode mode() { return GetParam(); } + DescriptorPoolMode mode() { return std::get<0>(GetParam()); } + const char* syntax() { return std::get<1>(GetParam()); } virtual void SetUp() { FileDescriptorProto foo_proto, bar_proto; @@ -2693,10 +2696,13 @@ class AllowUnknownDependenciesTest " }" "}", &foo_proto)); + foo_proto.set_syntax(syntax()); + ASSERT_TRUE( TextFormat::ParseFromString("name: 'bar.proto'" "message_type { name: 'Bar' }", &bar_proto)); + bar_proto.set_syntax(syntax()); // Collect pointers to stuff. bar_file_ = BuildFile(bar_proto); @@ -2969,7 +2975,9 @@ TEST_P(AllowUnknownDependenciesTest, } INSTANTIATE_TEST_SUITE_P(DatabaseSource, AllowUnknownDependenciesTest, - testing::Values(NO_DATABASE, FALLBACK_DATABASE)); + testing::Combine(testing::Values(NO_DATABASE, + FALLBACK_DATABASE), + testing::Values("proto2", "proto3"))); // =================================================================== @@ -3456,7 +3464,7 @@ TEST(CustomOptions, AggregateOptions) { method->options().GetExtension(protobuf_unittest::methodopt).s()); } -TEST(CustomOptions, UnusedImportWarning) { +TEST(CustomOptions, UnusedImportError) { DescriptorPool pool; FileDescriptorProto file_proto; @@ -3467,7 +3475,7 @@ TEST(CustomOptions, UnusedImportWarning) { &file_proto); ASSERT_TRUE(pool.BuildFile(file_proto) != nullptr); - pool.AddUnusedImportTrackFile("custom_options_import.proto"); + pool.AddUnusedImportTrackFile("custom_options_import.proto", true); ASSERT_TRUE(TextFormat::ParseFromString( "name: \"custom_options_import.proto\" " "package: \"protobuf_unittest\" " @@ -3475,13 +3483,12 @@ TEST(CustomOptions, UnusedImportWarning) { &file_proto)); MockErrorCollector error_collector; - EXPECT_TRUE(pool.BuildFileCollectingErrors(file_proto, &error_collector)); + EXPECT_FALSE(pool.BuildFileCollectingErrors(file_proto, &error_collector)); EXPECT_EQ( "custom_options_import.proto: " "google/protobuf/unittest_custom_options.proto: IMPORT: Import " "google/protobuf/unittest_custom_options.proto is unused.\n", - error_collector.warning_text_); - EXPECT_EQ("", error_collector.text_); + error_collector.text_); } // Verifies that proto files can correctly be parsed, even if the @@ -6502,6 +6509,28 @@ TEST_F(ValidationErrorTest, ValidateProto3JsonName) { } +TEST_F(ValidationErrorTest, UnusedImportWithOtherError) { + BuildFile( + "name: 'bar.proto' " + "message_type {" + " name: 'Bar'" + "}"); + + pool_.AddUnusedImportTrackFile("foo.proto", true); + BuildFileWithErrors( + "name: 'foo.proto' " + "dependency: 'bar.proto' " + "message_type {" + " name: 'Foo'" + " extension { name:'foo' number:1 label:LABEL_OPTIONAL type:TYPE_INT32" + " extendee: 'Baz' }" + "}", + + // Should not also contain unused import error. + "foo.proto: Foo.foo: EXTENDEE: \"Baz\" is not defined.\n"); +} + + // =================================================================== // DescriptorDatabase @@ -6950,22 +6979,21 @@ class ExponentialErrorDatabase : public DescriptorDatabase { } bool PopulateFile(int file_num, FileDescriptorProto* output) { - using strings::Substitute; GOOGLE_CHECK_GE(file_num, 0); output->Clear(); - output->set_name(Substitute("file$0.proto", file_num)); + output->set_name(strings::Substitute("file$0.proto", file_num)); // file0.proto doesn't define Message0 if (file_num > 0) { DescriptorProto* message = output->add_message_type(); - message->set_name(Substitute("Message$0", file_num)); + message->set_name(strings::Substitute("Message$0", file_num)); for (int i = 0; i < file_num; ++i) { - output->add_dependency(Substitute("file$0.proto", i)); + output->add_dependency(strings::Substitute("file$0.proto", i)); FieldDescriptorProto* field = message->add_field(); - field->set_name(Substitute("field$0", i)); + field->set_name(strings::Substitute("field$0", i)); field->set_number(i); field->set_label(FieldDescriptorProto::LABEL_OPTIONAL); field->set_type(FieldDescriptorProto::TYPE_MESSAGE); - field->set_type_name(Substitute("Message$0", i)); + field->set_type_name(strings::Substitute("Message$0", i)); } } return true; @@ -7140,8 +7168,8 @@ class SourceLocationTest : public testing::Test { static std::string PrintSourceLocation(const SourceLocation& loc) { return strings::Substitute("$0:$1-$2:$3", 1 + loc.start_line, - 1 + loc.start_column, 1 + loc.end_line, - 1 + loc.end_column); + 1 + loc.start_column, 1 + loc.end_line, + 1 + loc.end_column); } private: diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 6f829f49bfc9..26826620a998 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -69,9 +69,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Duration_google_2fprotobuf_2fduration_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fduration_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = { - &descriptor_table_google_2fprotobuf_2fduration_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", 227, + false, false, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", 227, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, descriptor_table_google_2fprotobuf_2fduration_2eproto_sccs, descriptor_table_google_2fprotobuf_2fduration_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fduration_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto, @@ -89,22 +88,15 @@ class Duration::_Internal { public: }; -Duration::Duration() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Duration) -} Duration::Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) } Duration::Duration(const Duration& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&seconds_, &from.seconds_, static_cast(reinterpret_cast(&nanos_) - reinterpret_cast(&seconds_)) + sizeof(nanos_)); @@ -120,10 +112,11 @@ void Duration::SharedCtor() { Duration::~Duration() { // @@protoc_insertion_point(destructor:google.protobuf.Duration) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Duration::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void Duration::ArenaDtor(void* object) { @@ -150,12 +143,12 @@ void Duration::Clear() { ::memset(&seconds_, 0, static_cast( reinterpret_cast(&nanos_) - reinterpret_cast(&seconds_)) + sizeof(nanos_)); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Duration::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -181,7 +174,9 @@ const char* Duration::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::i ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -215,7 +210,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Duration::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Duration) return target; @@ -270,7 +265,7 @@ void Duration::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Duration::MergeFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -302,9 +297,13 @@ bool Duration::IsInitialized() const { void Duration::InternalSwap(Duration* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - swap(seconds_, other->seconds_); - swap(nanos_, other->nanos_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Duration, nanos_) + + sizeof(Duration::nanos_) + - PROTOBUF_FIELD_OFFSET(Duration, seconds_)>( + reinterpret_cast(&seconds_), + reinterpret_cast(&other->seconds_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Duration::GetMetadata() const { diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index b2efc3c3f855..fcc21035ca08 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -66,10 +66,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Duration : +class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ { public: - Duration(); + inline Duration() : Duration(nullptr) {}; virtual ~Duration(); Duration(const Duration& from); @@ -83,7 +83,7 @@ class PROTOBUF_EXPORT Duration : return *this; } inline Duration& operator=(Duration&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -91,12 +91,6 @@ class PROTOBUF_EXPORT Duration : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -121,7 +115,7 @@ class PROTOBUF_EXPORT Duration : } inline void Swap(Duration* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -129,7 +123,7 @@ class PROTOBUF_EXPORT Duration : } void UnsafeArenaSwap(Duration* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -169,13 +163,6 @@ class PROTOBUF_EXPORT Duration : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -217,7 +204,6 @@ class PROTOBUF_EXPORT Duration : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 0ef5dd9a6d12..c82be66bc0c8 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -62,17 +62,19 @@ // Item 8 of "More Effective C++" discusses this in more detail, though // I don't have the book on me right now so I'm not sure. +#include + #include +#include #include #include -#include - #include #include -#include #include #include +#include +#include #include #include #include @@ -82,12 +84,13 @@ #include #include +#include // NOLINT + namespace google { namespace protobuf { using internal::DynamicMapField; using internal::ExtensionSet; -using internal::InternalMetadataWithArena; using internal::MapField; @@ -235,7 +238,6 @@ class DynamicMessage : public Message { int size; int has_bits_offset; int oneof_case_offset; - int internal_metadata_offset; int extensions_offset; // Not owned by the TypeInfo. @@ -274,7 +276,6 @@ class DynamicMessage : public Message { Message* New() const override; Message* New(Arena* arena) const override; - Arena* GetArena() const override { return arena_; } int GetCachedSize() const override; void SetCachedSize(int size) const override; @@ -295,6 +296,9 @@ class DynamicMessage : public Message { void SharedCtor(bool lock_factory); + // Needed to get the offset of the internal metadata member. + friend class DynamicMessageFactory; + inline bool is_prototype() const { return type_info_->prototype == this || // If type_info_->prototype is NULL, then we must be constructing @@ -321,7 +325,10 @@ DynamicMessage::DynamicMessage(const TypeInfo* type_info) } DynamicMessage::DynamicMessage(const TypeInfo* type_info, Arena* arena) - : type_info_(type_info), arena_(arena), cached_byte_size_(0) { + : Message(arena), + type_info_(type_info), + arena_(arena), + cached_byte_size_(0) { SharedCtor(true); } @@ -354,9 +361,6 @@ void DynamicMessage::SharedCtor(bool lock_factory) { uint32(0); } - new (OffsetToPointer(type_info_->internal_metadata_offset)) - InternalMetadataWithArena(arena_); - if (type_info_->extensions_offset != -1) { new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet(arena_); } @@ -458,9 +462,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) { DynamicMessage::~DynamicMessage() { const Descriptor* descriptor = type_info_->type; - reinterpret_cast( - OffsetToPointer(type_info_->internal_metadata_offset)) - ->~InternalMetadataWithArena(); + _internal_metadata_.Delete(); if (type_info_->extensions_offset != -1) { reinterpret_cast( @@ -749,11 +751,6 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( size += kMaxOneofUnionSize; } - // Add the InternalMetadataWithArena to the end. - size = AlignOffset(size); - type_info->internal_metadata_offset = size; - size += sizeof(InternalMetadataWithArena); - type_info->weak_field_map_offset = -1; // Align the final size to make sure no clever allocators think that @@ -790,15 +787,16 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( prototype); } - internal::ReflectionSchema schema = {type_info->prototype, - type_info->offsets.get(), - type_info->has_bits_indices.get(), - type_info->has_bits_offset, - type_info->internal_metadata_offset, - type_info->extensions_offset, - type_info->oneof_case_offset, - type_info->size, - type_info->weak_field_map_offset}; + internal::ReflectionSchema schema = { + type_info->prototype, + type_info->offsets.get(), + type_info->has_bits_indices.get(), + type_info->has_bits_offset, + PROTOBUF_FIELD_OFFSET(DynamicMessage, _internal_metadata_), + type_info->extensions_offset, + type_info->oneof_case_offset, + type_info->size, + type_info->weak_field_map_offset}; type_info->reflection.reset( new Reflection(type_info->type, schema, type_info->pool, this)); @@ -874,3 +872,5 @@ void DynamicMessageFactory::DeleteDefaultOneofInstance( } // namespace protobuf } // namespace google + +#include // NOLINT diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index ce7d1a052d58..855db18b011c 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -66,9 +66,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Empty_google_2fprotobuf_2fempty_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fempty_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = { - &descriptor_table_google_2fprotobuf_2fempty_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", 183, + false, false, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", 183, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, descriptor_table_google_2fprotobuf_2fempty_2eproto_sccs, descriptor_table_google_2fprotobuf_2fempty_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fempty_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto, @@ -86,22 +85,15 @@ class Empty::_Internal { public: }; -Empty::Empty() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Empty) -} Empty::Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty) } Empty::Empty(const Empty& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty) } @@ -111,10 +103,11 @@ void Empty::SharedCtor() { Empty::~Empty() { // @@protoc_insertion_point(destructor:google.protobuf.Empty) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Empty::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void Empty::ArenaDtor(void* object) { @@ -138,12 +131,12 @@ void Empty::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Empty::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -152,7 +145,9 @@ const char* Empty::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } // while @@ -172,7 +167,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Empty::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty) return target; @@ -213,7 +208,7 @@ void Empty::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Empty::MergeFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -239,7 +234,7 @@ bool Empty::IsInitialized() const { void Empty::InternalSwap(Empty* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); } ::PROTOBUF_NAMESPACE_ID::Metadata Empty::GetMetadata() const { diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 7d24d8975adc..8172d7a70759 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -66,10 +66,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Empty : +class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ { public: - Empty(); + inline Empty() : Empty(nullptr) {}; virtual ~Empty(); Empty(const Empty& from); @@ -83,7 +83,7 @@ class PROTOBUF_EXPORT Empty : return *this; } inline Empty& operator=(Empty&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -91,12 +91,6 @@ class PROTOBUF_EXPORT Empty : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -121,7 +115,7 @@ class PROTOBUF_EXPORT Empty : } inline void Swap(Empty* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -129,7 +123,7 @@ class PROTOBUF_EXPORT Empty : } void UnsafeArenaSwap(Empty* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -169,13 +163,6 @@ class PROTOBUF_EXPORT Empty : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -195,7 +182,6 @@ class PROTOBUF_EXPORT Empty : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index b4eb6e186cd1..3b1441e6656e 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -1063,7 +1063,7 @@ void ExtensionSet::InternalExtensionMergeFrom( } void ExtensionSet::Swap(ExtensionSet* x) { - if (GetArenaNoVirtual() == x->GetArenaNoVirtual()) { + if (GetArena() == x->GetArena()) { using std::swap; swap(flat_capacity_, x->flat_capacity_); swap(flat_size_, x->flat_size_); @@ -1091,7 +1091,7 @@ void ExtensionSet::SwapExtension(ExtensionSet* other, int number) { } if (this_ext != NULL && other_ext != NULL) { - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { using std::swap; swap(*this_ext, *other_ext); } else { @@ -1112,7 +1112,7 @@ void ExtensionSet::SwapExtension(ExtensionSet* other, int number) { } if (this_ext == NULL) { - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { *Insert(number).first = *other_ext; } else { InternalExtensionMergeFrom(number, *other_ext); @@ -1122,7 +1122,7 @@ void ExtensionSet::SwapExtension(ExtensionSet* other, int number) { } if (other_ext == NULL) { - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { *other->Insert(number).first = *this_ext; } else { other->InternalExtensionMergeFrom(number, *this_ext); @@ -1196,27 +1196,28 @@ bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input, } } -const char* ExtensionSet::ParseField( - uint64 tag, const char* ptr, const MessageLite* containing_type, - internal::InternalMetadataWithArenaLite* metadata, - internal::ParseContext* ctx) { +const char* ExtensionSet::ParseField(uint64 tag, const char* ptr, + const MessageLite* containing_type, + internal::InternalMetadata* metadata, + internal::ParseContext* ctx) { GeneratedExtensionFinder finder(containing_type); int number = tag >> 3; bool was_packed_on_wire; ExtensionInfo extension; if (!FindExtensionInfoFromFieldNumber(tag & 7, number, &finder, &extension, &was_packed_on_wire)) { - return UnknownFieldParse(tag, metadata->mutable_unknown_fields(), ptr, ctx); + return UnknownFieldParse( + tag, metadata->mutable_unknown_fields(), ptr, ctx); } - return ParseFieldWithExtensionInfo(number, was_packed_on_wire, extension, - metadata, ptr, ctx); + return ParseFieldWithExtensionInfo( + number, was_packed_on_wire, extension, metadata, ptr, ctx); } const char* ExtensionSet::ParseMessageSetItem( const char* ptr, const MessageLite* containing_type, - internal::InternalMetadataWithArenaLite* metadata, - internal::ParseContext* ctx) { - return ParseMessageSetItemTmpl(ptr, containing_type, metadata, ctx); + internal::InternalMetadata* metadata, internal::ParseContext* ctx) { + return ParseMessageSetItemTmpl(ptr, containing_type, + metadata, ctx); } bool ExtensionSet::ParseFieldWithExtensionInfo(int number, diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index 4dbf5abb8a0e..b30a9608af5b 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -79,8 +79,7 @@ namespace google { namespace protobuf { namespace internal { -class InternalMetadataWithArenaLite; -class InternalMetadataWithArena; +class InternalMetadata; // Used to store values of type WireFormatLite::FieldType without having to // #include wire_format_lite.h. Also, ensures that we use only one byte to @@ -292,7 +291,7 @@ class PROTOBUF_EXPORT ExtensionSet { MessageLite* UnsafeArenaReleaseMessage(const FieldDescriptor* descriptor, MessageFactory* factory); #undef desc - Arena* GetArenaNoVirtual() const { return arena_; } + Arena* GetArena() const { return arena_; } // repeated fields ------------------------------------------------- @@ -397,23 +396,24 @@ class PROTOBUF_EXPORT ExtensionSet { // Lite parser const char* ParseField(uint64 tag, const char* ptr, const MessageLite* containing_type, - internal::InternalMetadataWithArenaLite* metadata, + internal::InternalMetadata* metadata, internal::ParseContext* ctx); // Full parser const char* ParseField(uint64 tag, const char* ptr, const Message* containing_type, - internal::InternalMetadataWithArena* metadata, + internal::InternalMetadata* metadata, internal::ParseContext* ctx); - template + template const char* ParseMessageSet(const char* ptr, const Msg* containing_type, - Metadata* metadata, internal::ParseContext* ctx) { + InternalMetadata* metadata, + internal::ParseContext* ctx) { struct MessageSetItem { const char* _InternalParse(const char* ptr, ParseContext* ctx) { return me->ParseMessageSetItem(ptr, containing_type, metadata, ctx); } ExtensionSet* me; const Msg* containing_type; - Metadata* metadata; + InternalMetadata* metadata; } item{this, containing_type, metadata}; while (!ctx->Done(&ptr)) { uint32 tag; @@ -770,36 +770,37 @@ class PROTOBUF_EXPORT ExtensionSet { const internal::ParseContext* ctx, ExtensionInfo* extension, bool* was_packed_on_wire); // Used for MessageSet only - const char* ParseFieldMaybeLazily( - uint64 tag, const char* ptr, const MessageLite* containing_type, - internal::InternalMetadataWithArenaLite* metadata, - internal::ParseContext* ctx) { + const char* ParseFieldMaybeLazily(uint64 tag, const char* ptr, + const MessageLite* containing_type, + internal::InternalMetadata* metadata, + internal::ParseContext* ctx) { // Lite MessageSet doesn't implement lazy. return ParseField(tag, ptr, containing_type, metadata, ctx); } - const char* ParseFieldMaybeLazily( - uint64 tag, const char* ptr, const Message* containing_type, - internal::InternalMetadataWithArena* metadata, - internal::ParseContext* ctx); - const char* ParseMessageSetItem( - const char* ptr, const MessageLite* containing_type, - internal::InternalMetadataWithArenaLite* metadata, - internal::ParseContext* ctx); + const char* ParseFieldMaybeLazily(uint64 tag, const char* ptr, + const Message* containing_type, + internal::InternalMetadata* metadata, + internal::ParseContext* ctx); + const char* ParseMessageSetItem(const char* ptr, + const MessageLite* containing_type, + internal::InternalMetadata* metadata, + internal::ParseContext* ctx); const char* ParseMessageSetItem(const char* ptr, const Message* containing_type, - internal::InternalMetadataWithArena* metadata, + internal::InternalMetadata* metadata, internal::ParseContext* ctx); // Implemented in extension_set_inl.h to keep code out of the header file. template const char* ParseFieldWithExtensionInfo(int number, bool was_packed_on_wire, const ExtensionInfo& info, - T* metadata, const char* ptr, + internal::InternalMetadata* metadata, + const char* ptr, internal::ParseContext* ctx); - template + template const char* ParseMessageSetItemTmpl(const char* ptr, const Msg* containing_type, - Metadata* metadata, + internal::InternalMetadata* metadata, internal::ParseContext* ctx); // Hack: RepeatedPtrFieldBase declares ExtensionSet as a friend. This diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index 9b7ee4d0a43c..86e710c6f7d7 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -340,33 +340,33 @@ bool ExtensionSet::FindExtension(int wire_type, uint32 field, return true; } -const char* ExtensionSet::ParseField( - uint64 tag, const char* ptr, const Message* containing_type, - internal::InternalMetadataWithArena* metadata, - internal::ParseContext* ctx) { +const char* ExtensionSet::ParseField(uint64 tag, const char* ptr, + const Message* containing_type, + internal::InternalMetadata* metadata, + internal::ParseContext* ctx) { int number = tag >> 3; bool was_packed_on_wire; ExtensionInfo extension; if (!FindExtension(tag & 7, number, containing_type, ctx, &extension, &was_packed_on_wire)) { - return UnknownFieldParse(tag, metadata->mutable_unknown_fields(), ptr, ctx); + return UnknownFieldParse( + tag, metadata->mutable_unknown_fields(), ptr, ctx); } - return ParseFieldWithExtensionInfo(number, was_packed_on_wire, extension, - metadata, ptr, ctx); + return ParseFieldWithExtensionInfo( + number, was_packed_on_wire, extension, metadata, ptr, ctx); } const char* ExtensionSet::ParseFieldMaybeLazily( uint64 tag, const char* ptr, const Message* containing_type, - internal::InternalMetadataWithArena* metadata, - internal::ParseContext* ctx) { + internal::InternalMetadata* metadata, internal::ParseContext* ctx) { return ParseField(tag, ptr, containing_type, metadata, ctx); } const char* ExtensionSet::ParseMessageSetItem( const char* ptr, const Message* containing_type, - internal::InternalMetadataWithArena* metadata, - internal::ParseContext* ctx) { - return ParseMessageSetItemTmpl(ptr, containing_type, metadata, ctx); + internal::InternalMetadata* metadata, internal::ParseContext* ctx) { + return ParseMessageSetItemTmpl(ptr, containing_type, + metadata, ctx); } bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input, diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h index 087a3a442c82..9957f8baf71e 100644 --- a/src/google/protobuf/extension_set_inl.h +++ b/src/google/protobuf/extension_set_inl.h @@ -33,6 +33,7 @@ #include #include +#include namespace google { namespace protobuf { @@ -41,7 +42,7 @@ namespace internal { template const char* ExtensionSet::ParseFieldWithExtensionInfo( int number, bool was_packed_on_wire, const ExtensionInfo& extension, - T* metadata, const char* ptr, internal::ParseContext* ctx) { + InternalMetadata* metadata, const char* ptr, internal::ParseContext* ctx) { if (was_packed_on_wire) { switch (extension.type) { #define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE) \ @@ -66,7 +67,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( #undef HANDLE_TYPE case WireFormatLite::TYPE_ENUM: - return internal::PackedEnumParserArg( + return internal::PackedEnumParserArg( MutableRawRepeatedField(number, extension.type, extension.is_packed, extension.descriptor), ptr, ctx, extension.enum_validity_check.func, @@ -98,6 +99,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( HANDLE_VARINT_TYPE(INT64, Int64); HANDLE_VARINT_TYPE(UINT32, UInt32); HANDLE_VARINT_TYPE(UINT64, UInt64); + HANDLE_VARINT_TYPE(BOOL, Bool); #undef HANDLE_VARINT_TYPE #define HANDLE_SVARINT_TYPE(UPPERCASE, CPP_CAMELCASE, SIZE) \ case WireFormatLite::TYPE_##UPPERCASE: { \ @@ -136,7 +138,6 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( HANDLE_FIXED_TYPE(SFIXED64, Int64, int64); HANDLE_FIXED_TYPE(FLOAT, Float, float); HANDLE_FIXED_TYPE(DOUBLE, Double, double); - HANDLE_FIXED_TYPE(BOOL, Bool, bool); #undef HANDLE_FIXED_TYPE case WireFormatLite::TYPE_ENUM: { @@ -147,7 +148,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( if (!extension.enum_validity_check.func( extension.enum_validity_check.arg, value)) { - WriteVarint(number, val, metadata->mutable_unknown_fields()); + WriteVarint(number, val, metadata->mutable_unknown_fields()); } else if (extension.is_repeated) { AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed, value, extension.descriptor); @@ -200,11 +201,10 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( return ptr; } -template -const char* ExtensionSet::ParseMessageSetItemTmpl(const char* ptr, - const Msg* containing_type, - Metadata* metadata, - internal::ParseContext* ctx) { +template +const char* ExtensionSet::ParseMessageSetItemTmpl( + const char* ptr, const Msg* containing_type, + internal::InternalMetadata* metadata, internal::ParseContext* ctx) { std::string payload; uint32 type_id = 0; while (!ctx->Done(&ptr)) { @@ -220,7 +220,7 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(const char* ptr, if (!FindExtension(2, type_id, containing_type, ctx, &extension, &was_packed_on_wire)) { WriteLengthDelimited(type_id, payload, - metadata->mutable_unknown_fields()); + metadata->mutable_unknown_fields()); } else { MessageLite* value = extension.is_repeated diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index c08782b589d7..4bdd736d0927 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -1319,6 +1319,13 @@ TEST(ExtensionSetTest, DynamicExtensions) { } } +TEST(ExtensionSetTest, BoolExtension) { + unittest::TestAllExtensions msg; + uint8 wire_bytes[2] = {13 * 8, 42 /* out of bounds payload for bool */}; + EXPECT_TRUE(msg.ParseFromArray(wire_bytes, 2)); + EXPECT_TRUE(msg.GetExtension(protobuf_unittest::optional_bool_extension)); +} + } // namespace } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index dff19872adcf..42e077f3cf30 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -68,9 +68,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = { - &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", 230, + false, false, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", 230, &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_sccs, descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, @@ -88,14 +87,8 @@ class FieldMask::_Internal { public: }; -FieldMask::FieldMask() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FieldMask) -} FieldMask::FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), paths_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -103,9 +96,8 @@ FieldMask::FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena) } FieldMask::FieldMask(const FieldMask& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), paths_(from.paths_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask) } @@ -116,10 +108,11 @@ void FieldMask::SharedCtor() { FieldMask::~FieldMask() { // @@protoc_insertion_point(destructor:google.protobuf.FieldMask) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FieldMask::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void FieldMask::ArenaDtor(void* object) { @@ -144,12 +137,12 @@ void FieldMask::Clear() { (void) cached_has_bits; paths_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -175,7 +168,9 @@ const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -207,7 +202,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FieldMask::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldMask) return target; @@ -256,7 +251,7 @@ void FieldMask::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void FieldMask::MergeFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -283,7 +278,7 @@ bool FieldMask::IsInitialized() const { void FieldMask::InternalSwap(FieldMask* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); paths_.InternalSwap(&other->paths_); } diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index af6b8a9ebfdf..f5f1ff2d4d41 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -66,10 +66,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT FieldMask : +class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ { public: - FieldMask(); + inline FieldMask() : FieldMask(nullptr) {}; virtual ~FieldMask(); FieldMask(const FieldMask& from); @@ -83,7 +83,7 @@ class PROTOBUF_EXPORT FieldMask : return *this; } inline FieldMask& operator=(FieldMask&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -91,12 +91,6 @@ class PROTOBUF_EXPORT FieldMask : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -121,7 +115,7 @@ class PROTOBUF_EXPORT FieldMask : } inline void Swap(FieldMask* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -129,7 +123,7 @@ class PROTOBUF_EXPORT FieldMask : } void UnsafeArenaSwap(FieldMask* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -169,13 +163,6 @@ class PROTOBUF_EXPORT FieldMask : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -222,7 +209,6 @@ class PROTOBUF_EXPORT FieldMask : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index f44cde2c4a01..373192bd2a05 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -32,6 +32,8 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include + #include #include @@ -40,13 +42,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include @@ -60,7 +62,7 @@ using google::protobuf::internal::ExtensionSet; using google::protobuf::internal::GenericTypeHandler; using google::protobuf::internal::GetEmptyString; using google::protobuf::internal::InlinedStringField; -using google::protobuf::internal::InternalMetadataWithArena; +using google::protobuf::internal::InternalMetadata; using google::protobuf::internal::LazyField; using google::protobuf::internal::MapFieldBase; using google::protobuf::internal::MigrationSchema; @@ -100,21 +102,9 @@ const std::string& NameOfEnum(const EnumDescriptor* descriptor, int value) { namespace { -template -To* GetPointerAtOffset(Message* message, uint32 offset) { - return reinterpret_cast(reinterpret_cast(message) + offset); -} - -template -const To* GetConstPointerAtOffset(const Message* message, uint32 offset) { - return reinterpret_cast(reinterpret_cast(message) + - offset); -} - -template -const To& GetConstRefAtOffset(const Message& message, uint32 offset) { - return *GetConstPointerAtOffset(&message, offset); -} +using internal::GetConstPointerAtOffset; +using internal::GetConstRefAtOffset; +using internal::GetPointerAtOffset; void ReportReflectionUsageError(const Descriptor* descriptor, const FieldDescriptor* field, @@ -231,11 +221,13 @@ Reflection::Reflection(const Descriptor* descriptor, const UnknownFieldSet& Reflection::GetUnknownFields( const Message& message) const { - return GetInternalMetadataWithArena(message).unknown_fields(); + return GetInternalMetadata(message).unknown_fields( + UnknownFieldSet::default_instance); } UnknownFieldSet* Reflection::MutableUnknownFields(Message* message) const { - return MutableInternalMetadataWithArena(message)->mutable_unknown_fields(); + return MutableInternalMetadata(message) + ->mutable_unknown_fields(); } size_t Reflection::SpaceUsedLong(const Message& message) const { @@ -1026,6 +1018,14 @@ bool CreateUnknownEnumValues(const FileDescriptor* file) { } } // namespace +namespace internal { +bool CreateUnknownEnumValues(const FieldDescriptor* field) { + bool open_enum = false; + return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 || open_enum; +} +} // namespace internal +using internal::CreateUnknownEnumValues; + void Reflection::ListFields(const Message& message, std::vector* output) const { output->clear(); @@ -1323,7 +1323,7 @@ void Reflection::SetEnum(Message* message, const FieldDescriptor* field, void Reflection::SetEnumValue(Message* message, const FieldDescriptor* field, int value) const { USAGE_CHECK_ALL(SetEnumValue, SINGULAR, ENUM); - if (!CreateUnknownEnumValues(descriptor_->file())) { + if (!CreateUnknownEnumValues(field)) { // Check that the value is valid if we don't support direct storage of // unknown enum values. const EnumValueDescriptor* value_desc = @@ -1380,7 +1380,7 @@ void Reflection::SetRepeatedEnumValue(Message* message, const FieldDescriptor* field, int index, int value) const { USAGE_CHECK_ALL(SetRepeatedEnum, REPEATED, ENUM); - if (!CreateUnknownEnumValues(descriptor_->file())) { + if (!CreateUnknownEnumValues(field)) { // Check that the value is valid if we don't support direct storage of // unknown enum values. const EnumValueDescriptor* value_desc = @@ -1414,7 +1414,7 @@ void Reflection::AddEnum(Message* message, const FieldDescriptor* field, void Reflection::AddEnumValue(Message* message, const FieldDescriptor* field, int value) const { USAGE_CHECK_ALL(AddEnum, REPEATED, ENUM); - if (!CreateUnknownEnumValues(descriptor_->file())) { + if (!CreateUnknownEnumValues(field)) { // Check that the value is valid if we don't support direct storage of // unknown enum values. const EnumValueDescriptor* value_desc = @@ -1899,24 +1899,18 @@ ExtensionSet* Reflection::MutableExtensionSet(Message* message) const { } Arena* Reflection::GetArena(Message* message) const { - return GetInternalMetadataWithArena(*message).arena(); + return GetInternalMetadata(*message).arena(); } -const InternalMetadataWithArena& Reflection::GetInternalMetadataWithArena( +const InternalMetadata& Reflection::GetInternalMetadata( const Message& message) const { - return GetConstRefAtOffset( - message, schema_.GetMetadataOffset()); + return GetConstRefAtOffset(message, + schema_.GetMetadataOffset()); } -InternalMetadataWithArena* Reflection::MutableInternalMetadataWithArena( - Message* message) const { - return GetPointerAtOffset( - message, schema_.GetMetadataOffset()); -} - -template -const Type& Reflection::DefaultRaw(const FieldDescriptor* field) const { - return *reinterpret_cast(schema_.GetFieldDefault(field)); +InternalMetadata* Reflection::MutableInternalMetadata(Message* message) const { + return GetPointerAtOffset(message, + schema_.GetMetadataOffset()); } // Simple accessors for manipulating has_bits_. @@ -2331,7 +2325,7 @@ struct MetadataOwner { std::vector > metadata_arrays_; }; -void AssignDescriptorsImpl(const DescriptorTable* table) { +void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) { // Ensure the file descriptor is added to the pool. { // This only happens once per proto file. So a global mutex to serialize @@ -2341,6 +2335,25 @@ void AssignDescriptorsImpl(const DescriptorTable* table) { AddDescriptors(table); mu.Unlock(); } + if (eager) { + // Normally we do not want to eagerly build descriptors of our deps. + // However if this proto is optimized for code size (ie using reflection) + // and it has a message extending a custom option of a descriptor with that + // message being optimized for code size as well. Building the descriptors + // in this file requires parsing the serialized file descriptor, which now + // requires parsing the message extension, which potentially requires + // building the descriptor of the message extending one of the options. + // However we are already updating descriptor pool under a lock. To prevent + // this the compiler statically looks for this case and we just make sure we + // first build the descriptors of all our dependencies, preventing the + // deadlock. + int num_deps = table->num_deps; + for (int i = 0; i < num_deps; i++) { + // In case of weak fields deps[i] could be null. + if (table->deps[i]) AssignDescriptors(table->deps[i], true); + } + } + // Fill the arrays with pointers to descriptors and reflection classes. const FileDescriptor* file = DescriptorPool::internal_generated_pool()->FindFileByName( @@ -2378,7 +2391,8 @@ void AddDescriptorsImpl(const DescriptorTable* table) { // Ensure all dependent descriptors are registered to the generated descriptor // pool and message factory. - for (int i = 0; i < table->num_deps; i++) { + int num_deps = table->num_deps; + for (int i = 0; i < num_deps; i++) { // In case of weak fields deps[i] could be null. if (table->deps[i]) AddDescriptors(table->deps[i]); } @@ -2403,8 +2417,9 @@ void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) { namespace internal { -void AssignDescriptors(const DescriptorTable* table) { - call_once(*table->once, AssignDescriptorsImpl, table); +void AssignDescriptors(const DescriptorTable* table, bool eager) { + if (!eager) eager = table->is_eager; + call_once(*table->once, AssignDescriptorsImpl, table, eager); } void AddDescriptors(const DescriptorTable* table) { @@ -2412,8 +2427,8 @@ void AddDescriptors(const DescriptorTable* table) { // properly serialized. This function is only called pre-main by global // descriptors and we can assume single threaded access or it's called // by AssignDescriptorImpl which uses a mutex to sequence calls. - if (*table->is_initialized) return; - *table->is_initialized = true; + if (table->is_initialized) return; + table->is_initialized = true; AddDescriptorsImpl(table); } @@ -2426,11 +2441,12 @@ void UnknownFieldSetSerializer(const uint8* base, uint32 offset, uint32 tag, uint32 has_offset, io::CodedOutputStream* output) { const void* ptr = base + offset; - const InternalMetadataWithArena* metadata = - static_cast(ptr); + const InternalMetadata* metadata = static_cast(ptr); if (metadata->have_unknown_fields()) { - internal::WireFormat::SerializeUnknownFields(metadata->unknown_fields(), - output); + internal::WireFormat::SerializeUnknownFields( + metadata->unknown_fields( + UnknownFieldSet::default_instance), + output); } } diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index cbfab5e1c716..2c2e40ca906a 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -46,7 +46,6 @@ // is released to components. #include #include -#include #include #include #include @@ -73,8 +72,6 @@ namespace google { namespace protobuf { namespace internal { class DefaultEmptyOneof; -class ReflectionAccessor; - // Defined in other files. class ExtensionSet; // extension_set.h class WeakFieldMap; // weak_field_map.h @@ -262,8 +259,11 @@ struct MigrationSchema { int object_size; }; +struct SCCInfoBase; + struct PROTOBUF_EXPORT DescriptorTable { - bool* is_initialized; + mutable bool is_initialized; + bool is_eager; const char* descriptor; const char* filename; int size; // of serialized descriptor @@ -287,7 +287,8 @@ struct PROTOBUF_EXPORT DescriptorTable { // the descriptor objects. It also constructs the reflection objects. It is // called the first time anyone calls descriptor() or GetReflection() on one of // the types defined in the file. AssignDescriptors() is thread-safe. -void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table); +void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table, + bool eager = false); // AddDescriptors() is a file-level procedure which adds the encoded // FileDescriptorProto for this .proto file to the global DescriptorPool for diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index eea5da53d754..1c9d408db1e7 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -43,15 +43,15 @@ // rather than generated accessors. #include + #include +#include +#include #include #include #include #include - -#include -#include #include #include diff --git a/src/google/protobuf/generated_message_table_driven.cc b/src/google/protobuf/generated_message_table_driven.cc index fb82a8ec373c..56f1a6af841e 100644 --- a/src/google/protobuf/generated_message_table_driven.cc +++ b/src/google/protobuf/generated_message_table_driven.cc @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -47,8 +46,8 @@ namespace internal { namespace { UnknownFieldSet* MutableUnknownFields(MessageLite* msg, int64 arena_offset) { - return Raw(msg, arena_offset) - ->mutable_unknown_fields(); + return Raw(msg, arena_offset) + ->mutable_unknown_fields(); } struct UnknownFieldHandler { @@ -95,9 +94,8 @@ struct UnknownFieldHandler { bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) { - return MergePartialFromCodedStreamImpl(msg, table, - input); + return MergePartialFromCodedStreamImpl(msg, table, + input); } } // namespace internal diff --git a/src/google/protobuf/generated_message_table_driven_lite.cc b/src/google/protobuf/generated_message_table_driven_lite.cc index 82de6bc9b00c..02e6dacee6d6 100644 --- a/src/google/protobuf/generated_message_table_driven_lite.cc +++ b/src/google/protobuf/generated_message_table_driven_lite.cc @@ -44,8 +44,8 @@ namespace internal { namespace { std::string* MutableUnknownFields(MessageLite* msg, int64 arena_offset) { - return Raw(msg, arena_offset) - ->mutable_unknown_fields(); + return Raw(msg, arena_offset) + ->mutable_unknown_fields(); } struct UnknownFieldHandlerLite { @@ -97,9 +97,8 @@ struct UnknownFieldHandlerLite { bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) { - return MergePartialFromCodedStreamImpl( - msg, table, input); + return MergePartialFromCodedStreamImpl(msg, table, + input); } } // namespace internal diff --git a/src/google/protobuf/generated_message_table_driven_lite.h b/src/google/protobuf/generated_message_table_driven_lite.h index 8cf177be46e7..80f215880ceb 100644 --- a/src/google/protobuf/generated_message_table_driven_lite.h +++ b/src/google/protobuf/generated_message_table_driven_lite.h @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -82,15 +81,6 @@ inline const Type* Raw(const MessageLite* msg, int64 offset) { offset); } -template -inline Arena* GetArena(MessageLite* msg, int64 arena_offset) { - if (PROTOBUF_PREDICT_FALSE(arena_offset == -1)) { - return NULL; - } - - return Raw(msg, arena_offset)->arena(); -} - inline ExtensionSet* GetExtensionSet(MessageLite* msg, int64 extension_offset) { if (extension_offset == -1) { return NULL; @@ -304,8 +294,7 @@ static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg, return true; } -template +template inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input, MessageLite* msg, uint32* presence, uint32 presence_index, int64 offset, uint32 tag, @@ -328,8 +317,7 @@ inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input, AddField(msg, offset, value); break; case Cardinality_ONEOF: - ClearOneofField(table.fields[presence[presence_index]], - GetArena(msg, table.arena_offset), + ClearOneofField(table.fields[presence[presence_index]], msg->GetArena(), msg); SetOneofField(msg, presence, presence_index, offset, field_number, value); @@ -372,8 +360,7 @@ class MergePartialFromCodedStreamHelper { } }; -template +template bool MergePartialFromCodedStreamInlined(MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) { @@ -451,8 +438,8 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \ return false; \ } \ - ClearOneofField(table.fields[oneof_case[presence_index]], \ - GetArena(msg, table.arena_offset), msg); \ + ClearOneofField(table.fields[oneof_case[presence_index]], msg->GetArena(), \ + msg); \ SetOneofField(msg, oneof_case, presence_index, offset, field_number, \ value); \ break; \ @@ -480,8 +467,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, case WireFormatLite::TYPE_STRING: #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const void* default_ptr = table.aux[field_number].strings.default_ptr; if (PROTOBUF_PREDICT_FALSE( @@ -498,8 +484,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, case TYPE_STRING_INLINED: #endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const void* default_ptr = table.aux[field_number].strings.default_ptr; if (PROTOBUF_PREDICT_FALSE( @@ -516,8 +501,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, case WireFormatLite::TYPE_STRING | kOneofMask: #endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); uint32* oneof_case = Raw(msg, table.oneof_case_offset); const void* default_ptr = table.aux[field_number].strings.default_ptr; @@ -541,8 +525,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, case TYPE_STRING_INLINED | kRepeatedMask: #endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const void* default_ptr = table.aux[field_number].strings.default_ptr; if (PROTOBUF_PREDICT_FALSE( @@ -556,8 +539,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, } #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED case (WireFormatLite::TYPE_STRING): { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const void* default_ptr = table.aux[field_number].strings.default_ptr; const char* field_name = table.aux[field_number].strings.field_name; @@ -572,8 +554,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, } case TYPE_STRING_INLINED | kRepeatedMask: case (WireFormatLite::TYPE_STRING) | kRepeatedMask: { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const void* default_ptr = table.aux[field_number].strings.default_ptr; const char* field_name = table.aux[field_number].strings.field_name; @@ -587,8 +568,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, break; } case (WireFormatLite::TYPE_STRING) | kOneofMask: { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); uint32* oneof_case = Raw(msg, table.oneof_case_offset); const void* default_ptr = table.aux[field_number].strings.default_ptr; const char* field_name = table.aux[field_number].strings.field_name; @@ -609,8 +589,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED case WireFormatLite::TYPE_ENUM: { if (PROTOBUF_PREDICT_FALSE( - (!HandleEnum( + (!HandleEnum( table, input, msg, has_bits, presence_index, offset, tag, field_number)))) { return false; @@ -619,8 +598,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, } case WireFormatLite::TYPE_ENUM | kRepeatedMask: { if (PROTOBUF_PREDICT_FALSE( - (!HandleEnum( + (!HandleEnum( table, input, msg, has_bits, presence_index, offset, tag, field_number)))) { return false; @@ -630,10 +608,9 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, case WireFormatLite::TYPE_ENUM | kOneofMask: { uint32* oneof_case = Raw(msg, table.oneof_case_offset); if (PROTOBUF_PREDICT_FALSE( - (!HandleEnum(table, input, msg, oneof_case, - presence_index, offset, tag, - field_number)))) { + (!HandleEnum( + table, input, msg, oneof_case, presence_index, offset, + tag, field_number)))) { return false; } break; @@ -644,8 +621,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, MessageLite* submsg = *submsg_holder; if (submsg == NULL) { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const MessageLite* prototype = table.aux[field_number].messages.default_message(); submsg = prototype->New(arena); @@ -681,8 +657,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, MessageLite* submsg = *submsg_holder; if (submsg == NULL) { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const MessageLite* prototype = table.aux[field_number].messages.default_message(); if (prototype == NULL) { @@ -720,8 +695,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, break; } case WireFormatLite::TYPE_MESSAGE | kOneofMask: { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); uint32* oneof_case = Raw(msg, table.oneof_case_offset); MessageLite** submsg_holder = Raw(msg, offset); ResetOneofField( @@ -738,8 +712,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, } #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED case TYPE_STRING_INLINED: { - Arena* const arena = - GetArena(msg, table.arena_offset); + Arena* const arena = msg->GetArena(); const void* default_ptr = table.aux[field_number].strings.default_ptr; const char* field_name = table.aux[field_number].strings.field_name; @@ -813,7 +786,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, #undef HANDLE_PACKED_TYPE case WireFormatLite::TYPE_ENUM: { // To avoid unnecessarily calling MutableUnknownFields (which mutates - // InternalMetadataWithArena) when all inputs in the repeated series + // InternalMetadata) when all inputs in the repeated series // are valid, we implement our own parser rather than call // WireFormat::ReadPackedEnumPreserveUnknowns. uint32 length; @@ -876,23 +849,21 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg, } } -template +template bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) { // The main beneficial cutoff values are 1 and 2 byte tags. // Instantiate calls with the appropriate upper tag range if (table.max_field_number <= (0x7F >> 3)) { - return MergePartialFromCodedStreamInlined( + return MergePartialFromCodedStreamInlined( msg, table, input); } else if (table.max_field_number <= (0x3FFF >> 3)) { - return MergePartialFromCodedStreamInlined( + return MergePartialFromCodedStreamInlined( msg, table, input); } else { return MergePartialFromCodedStreamInlined< - UnknownFieldHandler, InternalMetadata, - std::numeric_limits::max()>(msg, table, input); + UnknownFieldHandler, std::numeric_limits::max()>(msg, table, + input); } } diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index bdeabddf3c89..15eb9d65283e 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -718,8 +718,8 @@ void UnknownFieldSerializerLite(const uint8* ptr, uint32 offset, uint32 tag, uint32 has_offset, io::CodedOutputStream* output) { output->WriteString( - reinterpret_cast(ptr + offset) - ->unknown_fields()); + reinterpret_cast(ptr + offset) + ->unknown_fields(&internal::GetEmptyString)); } MessageLite* DuplicateIfNonNullInternal(MessageLite* message) { diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 11cf9aa42f99..7cae4e126654 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -67,6 +67,7 @@ namespace google { namespace protobuf { class Arena; +class Message; namespace io { class CodedInputStream; @@ -149,6 +150,8 @@ PROTOBUF_EXPORT MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* submessage, Arena* submessage_arena); PROTOBUF_EXPORT void GenericSwap(MessageLite* m1, MessageLite* m2); +// We specialize GenericSwap for non-lite messages to benefit from reflection. +PROTOBUF_EXPORT void GenericSwap(Message* m1, Message* m2); template T* DuplicateIfNonNull(T* message) { diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h index a3348daacb6a..a2ae99d2dcfe 100644 --- a/src/google/protobuf/implicit_weak_message.h +++ b/src/google/protobuf/implicit_weak_message.h @@ -56,8 +56,8 @@ namespace internal { // message type does not get linked into the binary. class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { public: - ImplicitWeakMessage() : arena_(NULL) {} - explicit ImplicitWeakMessage(Arena* arena) : arena_(arena) {} + ImplicitWeakMessage() {} + explicit ImplicitWeakMessage(Arena* arena) : MessageLite(arena) {} static const ImplicitWeakMessage* default_instance(); @@ -68,8 +68,6 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { return Arena::CreateMessage(arena); } - Arena* GetArena() const override { return arena_; } - void Clear() override { data_.clear(); } bool IsInitialized() const override { return true; } @@ -93,7 +91,6 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { typedef void InternalArenaConstructable_; private: - Arena* const arena_; std::string data_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage); }; diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index a6e619e4f713..64336ebcefed 100755 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -194,8 +194,8 @@ class PROTOBUF_EXPORT Printer { ~Printer(); - // Link a substitution variable emitted by the last call to Print to the object - // described by descriptor. + // Link a substitution variable emitted by the last call to Print to the + // object described by descriptor. template void Annotate(const char* varname, const SomeDescriptor* descriptor) { Annotate(varname, varname, descriptor); diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index bc977015970a..48bcde5c0b07 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -83,16 +83,116 @@ class TypeDefinedMapFieldBase; class DynamicMapField; class GeneratedMessageReflection; + +// re-implement std::allocator to use arena allocator for memory allocation. +// Used for Map implementation. Users should not use this class +// directly. +template +class MapAllocator { + public: + using value_type = U; + using pointer = value_type*; + using const_pointer = const value_type*; + using reference = value_type&; + using const_reference = const value_type&; + using size_type = size_t; + using difference_type = ptrdiff_t; + + MapAllocator() : arena_(nullptr) {} + explicit MapAllocator(Arena* arena) : arena_(arena) {} + template + MapAllocator(const MapAllocator& allocator) // NOLINT(runtime/explicit) + : arena_(allocator.arena()) {} + + pointer allocate(size_type n, const void* /* hint */ = nullptr) { + // If arena is not given, malloc needs to be called which doesn't + // construct element object. + if (arena_ == nullptr) { + return static_cast(::operator new(n * sizeof(value_type))); + } else { + return reinterpret_cast( + Arena::CreateArray(arena_, n * sizeof(value_type))); + } + } + + void deallocate(pointer p, size_type n) { + if (arena_ == nullptr) { +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + ::operator delete(p, n * sizeof(value_type)); +#else + (void)n; + ::operator delete(p); +#endif + } + } + +#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ + !defined(GOOGLE_PROTOBUF_OS_NACL) && \ + !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) + template + void construct(NodeType* p, Args&&... args) { + // Clang 3.6 doesn't compile static casting to void* directly. (Issue + // #1266) According C++ standard 5.2.9/1: "The static_cast operator shall + // not cast away constness". So first the maybe const pointer is casted to + // const void* and after the const void* is const casted. + new (const_cast(static_cast(p))) + NodeType(std::forward(args)...); + } + + template + void destroy(NodeType* p) { + p->~NodeType(); + } +#else + void construct(pointer p, const_reference t) { new (p) value_type(t); } + + void destroy(pointer p) { p->~value_type(); } +#endif + + template + struct rebind { + using other = MapAllocator; + }; + + template + bool operator==(const MapAllocator& other) const { + return arena_ == other.arena_; + } + + template + bool operator!=(const MapAllocator& other) const { + return arena_ != other.arena_; + } + + // To support Visual Studio 2008 + size_type max_size() const { + // parentheses around (std::...:max) prevents macro warning of max() + return (std::numeric_limits::max)(); + } + + // To support gcc-4.4, which does not properly + // support templated friend classes + Arena* arena() const { return arena_; } + + private: + using DestructorSkippable_ = void; + Arena* const arena_; +}; + +template +struct DerefCompare { + bool operator()(const Key* n0, const Key* n1) const { return *n0 < *n1; } +}; + } // namespace internal // This is the class for Map's internal value_type. Instead of using // std::pair as value_type, we use this class which provides us more control of // its process of construction and destruction. template -class MapPair { - public: - typedef const Key first_type; - typedef T second_type; +struct MapPair { + using first_type = const Key; + using second_type = T; MapPair(const Key& other_first, const T& other_second) : first(other_first), second(other_second) {} @@ -103,7 +203,7 @@ class MapPair { // Implicitly convertible to std::pair of compatible types. template - operator std::pair() const { + operator std::pair() const { // NOLINT(runtime/explicit) return std::pair(first, second); } @@ -128,23 +228,23 @@ class MapPair { template class Map { public: - typedef Key key_type; - typedef T mapped_type; - typedef MapPair value_type; + using key_type = Key; + using mapped_type = T; + using value_type = MapPair; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; + using pointer = value_type*; + using const_pointer = const value_type*; + using reference = value_type&; + using const_reference = const value_type&; - typedef size_t size_type; - typedef hash hasher; + using size_type = size_t; + using hasher = hash; - Map() : arena_(NULL), default_enum_value_(0) { Init(); } + Map() : arena_(nullptr), default_enum_value_(0) { Init(); } explicit Map(Arena* arena) : arena_(arena), default_enum_value_(0) { Init(); } Map(const Map& other) - : arena_(NULL), default_enum_value_(other.default_enum_value_) { + : arena_(nullptr), default_enum_value_(other.default_enum_value_) { Init(); insert(other.begin(), other.end()); } @@ -169,14 +269,14 @@ class Map { template Map(const InputIt& first, const InputIt& last) - : arena_(NULL), default_enum_value_(0) { + : arena_(nullptr), default_enum_value_(0) { Init(); insert(first, last); } ~Map() { clear(); - if (arena_ == NULL) { + if (arena_ == nullptr) { delete elements_; } } @@ -187,101 +287,6 @@ class Map { Arena::Create(arena_, 0u, hasher(), Allocator(arena_)); } - // re-implement std::allocator to use arena allocator for memory allocation. - // Used for Map implementation. Users should not use this class - // directly. - template - class MapAllocator { - public: - typedef U value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - MapAllocator() : arena_(NULL) {} - explicit MapAllocator(Arena* arena) : arena_(arena) {} - template - MapAllocator(const MapAllocator& allocator) - : arena_(allocator.arena()) {} - - pointer allocate(size_type n, const void* /* hint */ = 0) { - // If arena is not given, malloc needs to be called which doesn't - // construct element object. - if (arena_ == NULL) { - return static_cast(::operator new(n * sizeof(value_type))); - } else { - return reinterpret_cast( - Arena::CreateArray(arena_, n * sizeof(value_type))); - } - } - - void deallocate(pointer p, size_type n) { - if (arena_ == NULL) { -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) - ::operator delete(p, n * sizeof(value_type)); -#else - (void)n; - ::operator delete(p); -#endif - } - } - -#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ - !defined(GOOGLE_PROTOBUF_OS_NACL) && \ - !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) - template - void construct(NodeType* p, Args&&... args) { - // Clang 3.6 doesn't compile static casting to void* directly. (Issue - // #1266) According C++ standard 5.2.9/1: "The static_cast operator shall - // not cast away constness". So first the maybe const pointer is casted to - // const void* and after the const void* is const casted. - new (const_cast(static_cast(p))) - NodeType(std::forward(args)...); - } - - template - void destroy(NodeType* p) { - p->~NodeType(); - } -#else - void construct(pointer p, const_reference t) { new (p) value_type(t); } - - void destroy(pointer p) { p->~value_type(); } -#endif - - template - struct rebind { - typedef MapAllocator other; - }; - - template - bool operator==(const MapAllocator& other) const { - return arena_ == other.arena_; - } - - template - bool operator!=(const MapAllocator& other) const { - return arena_ != other.arena_; - } - - // To support Visual Studio 2008 - size_type max_size() const { - // parentheses around (std::...:max) prevents macro warning of max() - return (std::numeric_limits::max)(); - } - - // To support gcc-4.4, which does not properly - // support templated friend classes - Arena* arena() const { return arena_; } - - private: - typedef void DestructorSkippable_; - Arena* const arena_; - }; - // InnerMap's key type is Key and its value type is value_type*. We use a // custom class here and for Node, below, to ensure that k_ is at offset 0, // allowing safe conversion from pointer to Node to pointer to Key, and vice @@ -300,7 +305,7 @@ class Map { value_type* v_; }; - typedef MapAllocator Allocator; + using Allocator = internal::MapAllocator; // InnerMap is a generic hash-based map. It doesn't contain any // protocol-buffer-specific logic. It is a chaining hash map with the @@ -317,7 +322,7 @@ class Map { // 2. The number of buckets is a power of two. // 3. Buckets are converted to trees in pairs: if we convert bucket b then // buckets b and b^1 will share a tree. Invariant: buckets b and b^1 have - // the same non-NULL value iff they are sharing a tree. (An alternative + // the same non-null value iff they are sharing a tree. (An alternative // implementation strategy would be to have a tag bit per bucket.) // 4. As is typical for hash_map and such, the Keys and Values are always // stored in linked list nodes. Pointers to elements are never invalidated @@ -327,19 +332,19 @@ class Map { // 6. Once we've tree-converted a bucket, it is never converted back. However, // the items a tree contains may wind up assigned to trees or lists upon a // rehash. - // 7. The code requires no C++ features from C++11 or later. + // 7. The code requires no C++ features from C++14 or later. // 8. Mutations to a map do not invalidate the map's iterators, pointers to // elements, or references to elements. // 9. Except for erase(iterator), any non-const method can reorder iterators. class InnerMap : private hasher { public: - typedef value_type* Value; + using Value = value_type*; InnerMap(size_type n, hasher h, Allocator alloc) : hasher(h), num_elements_(0), seed_(Seed()), - table_(NULL), + table_(nullptr), alloc_(alloc) { n = TableSize(n); table_ = CreateEmptyTable(n); @@ -347,7 +352,7 @@ class Map { } ~InnerMap() { - if (table_ != NULL) { + if (table_ != nullptr) { clear(); Dealloc(table_, num_buckets_); } @@ -373,27 +378,25 @@ class Map { // Trees. The payload type is pointer to Key, so that we can query the tree // with Keys that are not in any particular data structure. When we insert, // though, the pointer is always pointing to a Key that is inside a Node. - struct KeyCompare { - bool operator()(const Key* n0, const Key* n1) const { return *n0 < *n1; } - }; - typedef typename Allocator::template rebind::other KeyPtrAllocator; - typedef std::set Tree; - typedef typename Tree::iterator TreeIterator; + using KeyPtrAllocator = typename Allocator::template rebind::other; + using Tree = std::set, KeyPtrAllocator>; + using TreeIterator = typename Tree::iterator; // iterator and const_iterator are instantiations of iterator_base. template - struct iterator_base { - typedef KeyValueType& reference; - typedef KeyValueType* pointer; + class iterator_base { + public: + using reference = KeyValueType&; + using pointer = KeyValueType*; // Invariants: // node_ is always correct. This is handy because the most common // operations are operator* and operator-> and they only use node_. - // When node_ is set to a non-NULL value, all the other non-const fields + // When node_ is set to a non-null value, all the other non-const fields // are updated to be correct also, but those fields can become stale // if the underlying map is modified. When those fields are needed they // are rechecked, and updated if necessary. - iterator_base() : node_(NULL), m_(NULL), bucket_index_(0) {} + iterator_base() : node_(nullptr), m_(nullptr), bucket_index_(0) {} explicit iterator_base(const InnerMap* m) : m_(m) { SearchFrom(m->index_of_first_non_null_); @@ -417,11 +420,11 @@ class Map { } // Advance through buckets, looking for the first that isn't empty. - // If nothing non-empty is found then leave node_ == NULL. + // If nothing non-empty is found then leave node_ == nullptr. void SearchFrom(size_type start_bucket) { GOOGLE_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ || - m_->table_[m_->index_of_first_non_null_] != NULL); - node_ = NULL; + m_->table_[m_->index_of_first_non_null_] != nullptr); + node_ = nullptr; for (bucket_index_ = start_bucket; bucket_index_ < m_->num_buckets_; bucket_index_++) { if (m_->TableEntryIsNonEmptyList(bucket_index_)) { @@ -447,7 +450,7 @@ class Map { } iterator_base& operator++() { - if (node_->next == NULL) { + if (node_->next == nullptr) { TreeIterator tree_it; const bool is_list = revalidate_if_necessary(&tree_it); if (is_list) { @@ -473,12 +476,12 @@ class Map { return tmp; } - // Assumes node_ and m_ are correct and non-NULL, but other fields may be + // Assumes node_ and m_ are correct and non-null, but other fields may be // stale. Fix them as needed. Then return true iff node_ points to a // Node in a list. If false is returned then *it is modified to be // a valid iterator for node_. bool revalidate_if_necessary(TreeIterator* it) { - GOOGLE_DCHECK(node_ != NULL && m_ != NULL); + GOOGLE_DCHECK(node_ != nullptr && m_ != nullptr); // Force bucket_index_ to be in range. bucket_index_ &= (m_->num_buckets_ - 1); // Common case: the bucket we think is relevant points to node_. @@ -487,7 +490,7 @@ class Map { // but not at the head. if (m_->TableEntryIsNonEmptyList(bucket_index_)) { Node* l = static_cast(m_->table_[bucket_index_]); - while ((l = l->next) != NULL) { + while ((l = l->next) != nullptr) { if (l == node_) { return true; } @@ -508,8 +511,8 @@ class Map { }; public: - typedef iterator_base iterator; - typedef iterator_base const_iterator; + using iterator = iterator_base; + using const_iterator = iterator_base; iterator begin() { return iterator(this); } iterator end() { return iterator(); } @@ -520,16 +523,16 @@ class Map { for (size_type b = 0; b < num_buckets_; b++) { if (TableEntryIsNonEmptyList(b)) { Node* node = static_cast(table_[b]); - table_[b] = NULL; + table_[b] = nullptr; do { Node* next = node->next; DestroyNode(node); node = next; - } while (node != NULL); + } while (node != nullptr); } else if (TableEntryIsTree(b)) { Tree* tree = static_cast(table_[b]); GOOGLE_DCHECK(table_[b] == table_[b + 1] && (b & 1) == 0); - table_[b] = table_[b + 1] = NULL; + table_[b] = table_[b + 1] = nullptr; typename Tree::iterator tree_it = tree->begin(); do { Node* node = NodePtrFromKeyPtr(*tree_it); @@ -556,14 +559,14 @@ class Map { bool empty() const { return size() == 0; } iterator find(const Key& k) { return iterator(FindHelper(k).first); } - const_iterator find(const Key& k) const { return find(k, NULL); } + const_iterator find(const Key& k) const { return find(k, nullptr); } bool contains(const Key& k) const { return find(k) != end(); } // In traditional C++ style, this performs "insert if not present." std::pair insert(const KeyValuePair& kv) { std::pair p = FindHelper(kv.key()); // Case 1: key was already present. - if (p.first.node_ != NULL) + if (p.first.node_ != nullptr) return std::make_pair(iterator(p.first), false); // Case 2: insert. if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) { @@ -582,7 +585,7 @@ class Map { std::pair insert(const Key& k) { std::pair p = FindHelper(k); // Case 1: key was already present. - if (p.first.node_ != NULL) + if (p.first.node_ != nullptr) return std::make_pair(iterator(p.first), false); // Case 2: insert. if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) { @@ -590,7 +593,7 @@ class Map { } const size_type b = p.second; // bucket number Node* node = Alloc(1); - typedef typename Allocator::template rebind::other KeyAllocator; + using KeyAllocator = typename Allocator::template rebind::other; KeyAllocator(alloc_).construct(&node->kv.key(), k); iterator result = InsertUnique(b, node); ++num_elements_; @@ -622,14 +625,14 @@ class Map { // only because we want index_of_first_non_null_ to be correct. b &= ~static_cast(1); DestroyTree(tree); - table_[b] = table_[b + 1] = NULL; + table_[b] = table_[b + 1] = nullptr; } } DestroyNode(item); --num_elements_; if (PROTOBUF_PREDICT_FALSE(b == index_of_first_non_null_)) { while (index_of_first_non_null_ < num_buckets_ && - table_[index_of_first_non_null_] == NULL) { + table_[index_of_first_non_null_] == nullptr) { ++index_of_first_non_null_; } } @@ -640,7 +643,7 @@ class Map { return FindHelper(k, it).first; } std::pair FindHelper(const Key& k) const { - return FindHelper(k, NULL); + return FindHelper(k, nullptr); } std::pair FindHelper(const Key& k, TreeIterator* it) const { @@ -653,7 +656,7 @@ class Map { } else { node = node->next; } - } while (node != NULL); + } while (node != nullptr); } else if (TableEntryIsTree(b)) { GOOGLE_DCHECK_EQ(table_[b], table_[b ^ 1]); b &= ~static_cast(1); @@ -661,7 +664,7 @@ class Map { Key* key = const_cast(&k); typename Tree::iterator tree_it = tree->find(key); if (tree_it != tree->end()) { - if (it != NULL) *it = tree_it; + if (it != nullptr) *it = tree_it; return std::make_pair(const_iterator(tree_it, this, b), b); } } @@ -674,7 +677,7 @@ class Map { // bucket. num_elements_ is not modified. iterator InsertUnique(size_type b, Node* node) { GOOGLE_DCHECK(index_of_first_non_null_ == num_buckets_ || - table_[index_of_first_non_null_] != NULL); + table_[index_of_first_non_null_] != nullptr); // In practice, the code that led to this point may have already // determined whether we are inserting into an empty list, a short list, // or whatever. But it's probably cheap enough to recompute that here; @@ -716,8 +719,8 @@ class Map { // Tree. iterator InsertUniqueInTree(size_type b, Node* node) { GOOGLE_DCHECK_EQ(table_[b], table_[b ^ 1]); - // Maintain the invariant that node->next is NULL for all Nodes in Trees. - node->next = NULL; + // Maintain the invariant that node->next is null for all Nodes in Trees. + node->next = nullptr; return iterator( static_cast(table_[b])->insert(KeyPtrFromNodePtr(node)).first, this, b & ~static_cast(1)); @@ -789,7 +792,7 @@ class Map { Node* next = node->next; InsertUnique(BucketNumber(*KeyPtrFromNodePtr(node)), node); node = next; - } while (node != NULL); + } while (node != nullptr); } void TransferTree(void* const* table, size_type index) { @@ -824,10 +827,10 @@ class Map { return TableEntryIsList(table_, b); } static bool TableEntryIsEmpty(void* const* table, size_type b) { - return table[b] == NULL; + return table[b] == nullptr; } static bool TableEntryIsNonEmptyList(void* const* table, size_type b) { - return table[b] != NULL && table[b] != table[b ^ 1]; + return table[b] != nullptr && table[b] != table[b ^ 1]; } static bool TableEntryIsTree(void* const* table, size_type b) { return !TableEntryIsEmpty(table, b) && @@ -845,8 +848,8 @@ class Map { // create a temporary and use the two-arg construct that's known to exist. // It's clunky, but the compiler should be able to generate more-or-less // the same code. - tree_allocator.construct(tree, - Tree(KeyCompare(), KeyPtrAllocator(alloc_))); + tree_allocator.construct( + tree, Tree(typename Tree::key_compare(), KeyPtrAllocator(alloc_))); // Now the tree is ready to use. size_type count = CopyListToTree(b, tree) + CopyListToTree(b ^ 1, tree); GOOGLE_DCHECK_EQ(count, tree->size()); @@ -858,11 +861,11 @@ class Map { size_type CopyListToTree(size_type b, Tree* tree) { size_type count = 0; Node* node = static_cast(table_[b]); - while (node != NULL) { + while (node != nullptr) { tree->insert(KeyPtrFromNodePtr(node)); ++count; Node* next = node->next; - node->next = NULL; + node->next = nullptr; node = next; } return count; @@ -877,7 +880,7 @@ class Map { do { ++count; node = node->next; - } while (node != NULL); + } while (node != nullptr); // Invariant: no linked list ever is more than kMaxLength in length. GOOGLE_DCHECK_LE(count, kMaxLength); return count >= kMaxLength; @@ -904,14 +907,14 @@ class Map { // Use alloc_ to allocate an array of n objects of type U. template U* Alloc(size_type n) { - typedef typename Allocator::template rebind::other alloc_type; + using alloc_type = typename Allocator::template rebind::other; return alloc_type(alloc_).allocate(n); } // Use alloc_ to deallocate an array of n objects of type U. template void Dealloc(U* t, size_type n) { - typedef typename Allocator::template rebind::other alloc_type; + using alloc_type = typename Allocator::template rebind::other; alloc_type(alloc_).deallocate(t, n); } @@ -958,14 +961,14 @@ class Map { public: // Iterators class const_iterator { - typedef typename InnerMap::const_iterator InnerIt; + using InnerIt = typename InnerMap::const_iterator; public: - typedef std::forward_iterator_tag iterator_category; - typedef typename Map::value_type value_type; - typedef ptrdiff_t difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; + using iterator_category = std::forward_iterator_tag; + using value_type = typename Map::value_type; + using difference_type = ptrdiff_t; + using pointer = const value_type*; + using reference = const value_type&; const_iterator() {} explicit const_iterator(const InnerIt& it) : it_(it) {} @@ -991,14 +994,14 @@ class Map { }; class iterator { - typedef typename InnerMap::iterator InnerIt; + using InnerIt = typename InnerMap::iterator; public: - typedef std::forward_iterator_tag iterator_category; - typedef typename Map::value_type value_type; - typedef ptrdiff_t difference_type; - typedef value_type* pointer; - typedef value_type& reference; + using iterator_category = std::forward_iterator_tag; + using value_type = typename Map::value_type; + using difference_type = ptrdiff_t; + using pointer = value_type*; + using reference = value_type&; iterator() {} explicit iterator(const InnerIt& it) : it_(it) {} @@ -1013,7 +1016,7 @@ class Map { iterator operator++(int) { return iterator(it_++); } // Allow implicit conversion to const_iterator. - operator const_iterator() const { + operator const_iterator() const { // NOLINT(runtime/explicit) return const_iterator(typename InnerMap::const_iterator(it_)); } @@ -1048,7 +1051,7 @@ class Map { // Element access T& operator[](const key_type& key) { value_type** value = &(*elements_)[key]; - if (*value == NULL) { + if (*value == nullptr) { *value = CreateValueTypeInternal(key); internal::MapValueInitializer::value, T>::Initialize( (*value)->second, default_enum_value_); @@ -1130,7 +1133,7 @@ class Map { } } iterator erase(iterator pos) { - if (arena_ == NULL) delete pos.operator->(); + if (arena_ == nullptr) delete pos.operator->(); iterator i = pos++; elements_->erase(i.it_); return pos; @@ -1176,27 +1179,26 @@ class Map { } value_type* CreateValueTypeInternal(const Key& key) { - if (arena_ == NULL) { + if (arena_ == nullptr) { return new value_type(key); } else { value_type* value = reinterpret_cast( Arena::CreateArray(arena_, sizeof(value_type))); - Arena::CreateInArenaStorage(const_cast(&value->first), arena_); + Arena::CreateInArenaStorage(const_cast(&value->first), arena_, key); Arena::CreateInArenaStorage(&value->second, arena_); - const_cast(value->first) = key; return value; } } value_type* CreateValueTypeInternal(const value_type& value) { - if (arena_ == NULL) { + if (arena_ == nullptr) { return new value_type(value); } else { value_type* p = reinterpret_cast( Arena::CreateArray(arena_, sizeof(value_type))); - Arena::CreateInArenaStorage(const_cast(&p->first), arena_); + Arena::CreateInArenaStorage(const_cast(&p->first), arena_, + value.first); Arena::CreateInArenaStorage(&p->second, arena_); - const_cast(p->first) = value.first; p->second = value.second; return p; } @@ -1207,8 +1209,8 @@ class Map { InnerMap* elements_; friend class Arena; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; template #include #include -#include #include #include #include @@ -101,6 +100,10 @@ class MapEntry : MapEntryImpl(arena), _internal_metadata_(arena) {} + ~MapEntry() { + Message::_internal_metadata_.Delete(); + _internal_metadata_.Delete(); + } typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -118,7 +121,7 @@ class MapEntry return size; } - InternalMetadataWithArena _internal_metadata_; + InternalMetadata _internal_metadata_; private: friend class ::PROTOBUF_NAMESPACE_ID::Arena; diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index fe8a2d72645f..7125ba181099 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -187,14 +187,14 @@ class MapEntryImpl : public Base { static const WireFormatLite::FieldType kEntryValueFieldType = kValueFieldType; static const int kEntryDefaultEnumValue = default_enum_value; - MapEntryImpl() : arena_(NULL) { + MapEntryImpl() { KeyTypeHandler::Initialize(&key_, NULL); ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value, NULL); _has_bits_[0] = 0; } - explicit MapEntryImpl(Arena* arena) : arena_(arena) { + explicit MapEntryImpl(Arena* arena) : Base(arena) { KeyTypeHandler::Initialize(&key_, arena); ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value, arena); @@ -202,7 +202,7 @@ class MapEntryImpl : public Base { } ~MapEntryImpl() { - if (GetArenaNoVirtual() != NULL) return; + if (Base::GetArena() != NULL) return; KeyTypeHandler::DeleteNoArena(key_); ValueTypeHandler::DeleteNoArena(value_); } @@ -218,11 +218,11 @@ class MapEntryImpl : public Base { } inline KeyMapEntryAccessorType* mutable_key() { set_has_key(); - return KeyTypeHandler::EnsureMutable(&key_, GetArenaNoVirtual()); + return KeyTypeHandler::EnsureMutable(&key_, Base::GetArena()); } inline ValueMapEntryAccessorType* mutable_value() { set_has_value(); - return ValueTypeHandler::EnsureMutable(&value_, GetArenaNoVirtual()); + return ValueTypeHandler::EnsureMutable(&value_, Base::GetArena()); } // implements MessageLite ========================================= @@ -315,13 +315,13 @@ class MapEntryImpl : public Base { void MergeFromInternal(const MapEntryImpl& from) { if (from._has_bits_[0]) { if (from.has_key()) { - KeyTypeHandler::EnsureMutable(&key_, GetArenaNoVirtual()); - KeyTypeHandler::Merge(from.key(), &key_, GetArenaNoVirtual()); + KeyTypeHandler::EnsureMutable(&key_, Base::GetArena()); + KeyTypeHandler::Merge(from.key(), &key_, Base::GetArena()); set_has_key(); } if (from.has_value()) { - ValueTypeHandler::EnsureMutable(&value_, GetArenaNoVirtual()); - ValueTypeHandler::Merge(from.value(), &value_, GetArenaNoVirtual()); + ValueTypeHandler::EnsureMutable(&value_, Base::GetArena()); + ValueTypeHandler::Merge(from.value(), &value_, Base::GetArena()); set_has_value(); } } @@ -329,8 +329,8 @@ class MapEntryImpl : public Base { public: void Clear() override { - KeyTypeHandler::Clear(&key_, GetArenaNoVirtual()); - ValueTypeHandler::ClearMaybeByDefaultEnum(&value_, GetArenaNoVirtual(), + KeyTypeHandler::Clear(&key_, Base::GetArena()); + ValueTypeHandler::ClearMaybeByDefaultEnum(&value_, Base::GetArena(), default_enum_value); clear_has_key(); clear_has_value(); @@ -342,8 +342,6 @@ class MapEntryImpl : public Base { ValueTypeHandler::AssignDefaultValue(&d->value_); } - Arena* GetArena() const override { return GetArenaNoVirtual(); } - // Parsing using MergePartialFromCodedStream, above, is not as // efficient as it could be. This helper class provides a speedier way. template @@ -440,10 +438,10 @@ class MapEntryImpl : public Base { return ptr; } - template + template const char* ParseWithEnumValidation(const char* ptr, ParseContext* ctx, bool (*is_valid)(int), uint32 field_num, - Metadata* metadata) { + InternalMetadata* metadata) { auto entry = NewEntry(); ptr = entry->_InternalParse(ptr, ctx); if (!ptr) return nullptr; @@ -451,7 +449,7 @@ class MapEntryImpl : public Base { UseKeyAndValueFromEntry(); } else { WriteLengthDelimited(field_num, entry->SerializeAsString(), - metadata->mutable_unknown_fields()); + metadata->mutable_unknown_fields()); } return ptr; } @@ -515,12 +513,11 @@ class MapEntryImpl : public Base { void clear_has_value() { _has_bits_[0] &= ~0x00000002u; } public: - inline Arena* GetArenaNoVirtual() const { return arena_; } + inline Arena* GetArena() const { return Base::GetArena(); } public: // Needed for constructing tables KeyOnMemory key_; ValueOnMemory value_; - Arena* arena_; uint32 _has_bits_[1]; private: @@ -549,6 +546,7 @@ class MapEntryLite SuperType; MapEntryLite() {} explicit MapEntryLite(Arena* arena) : SuperType(arena) {} + ~MapEntryLite() { MessageLite::_internal_metadata_.Delete(); } void MergeFrom(const MapEntryLite& other) { MergeFromInternal(other); } private: diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 38bf26aebb97..1d1a0dfb66a3 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -75,7 +75,9 @@ class PROTOBUF_EXPORT MapFieldBase { : arena_(arena), repeated_field_(NULL), state_(STATE_MODIFIED_MAP) { // Mutex's destructor needs to be called explicitly to release resources // acquired in its constructor. - arena->OwnDestructor(&mutex_); + if (arena) { + arena->OwnDestructor(&mutex_); + } } virtual ~MapFieldBase(); @@ -286,12 +288,12 @@ class MapField : public TypeDefinedMapFieldBase { const char* _InternalParse(const char* ptr, ParseContext* ctx) { return impl_._InternalParse(ptr, ctx); } - template + template const char* ParseWithEnumValidation(const char* ptr, ParseContext* ctx, bool (*is_valid)(int), uint32 field_num, - Metadata* metadata) { - return impl_.ParseWithEnumValidation(ptr, ctx, is_valid, field_num, - metadata); + InternalMetadata* metadata) { + return impl_.template ParseWithEnumValidation( + ptr, ctx, is_valid, field_num, metadata); } private: diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h index 3f2f6324ab66..d641d1733352 100644 --- a/src/google/protobuf/map_field_lite.h +++ b/src/google/protobuf/map_field_lite.h @@ -108,13 +108,13 @@ class MapFieldLite { return parser._InternalParse(ptr, ctx); } - template + template const char* ParseWithEnumValidation(const char* ptr, ParseContext* ctx, bool (*is_valid)(int), uint32 field_num, - Metadata* metadata) { + InternalMetadata* metadata) { typename Derived::template Parser> parser(this); - return parser.ParseWithEnumValidation(ptr, ctx, is_valid, field_num, - metadata); + return parser.template ParseWithEnumValidation( + ptr, ctx, is_valid, field_num, metadata); } private: @@ -125,28 +125,27 @@ class MapFieldLite { friend class ::PROTOBUF_NAMESPACE_ID::Arena; }; -template +template struct EnumParseWrapper { const char* _InternalParse(const char* ptr, ParseContext* ctx) { - return map_field->ParseWithEnumValidation(ptr, ctx, is_valid, field_num, - metadata); + return map_field->template ParseWithEnumValidation( + ptr, ctx, is_valid, field_num, metadata); } T* map_field; bool (*is_valid)(int); uint32 field_num; - Metadata* metadata; + InternalMetadata* metadata; }; // Helper function because the typenames of maps are horrendous to print. This // leverages compiler type deduction, to keep all type data out of the // generated code -template -EnumParseWrapper InitEnumParseWrapper(T* map_field, - bool (*is_valid)(int), - uint32 field_num, - Metadata* metadata) { - return EnumParseWrapper{map_field, is_valid, field_num, - metadata}; +template +EnumParseWrapper InitEnumParseWrapper( + T* map_field, bool (*is_valid)(int), uint32 field_num, + InternalMetadata* metadata) { + return EnumParseWrapper{map_field, is_valid, field_num, + metadata}; } // True if IsInitialized() is true for value field in all elements of t. T is diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index 742cc0031a8c..01512a061080 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -39,9 +39,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -94,6 +96,8 @@ void MapTestForceDeterministic() { io::CodedOutputStream::SetDefaultSerializationDeterministic(); } +namespace { + // Map API Test ===================================================== class MapImplTest : public ::testing::Test { @@ -980,11 +984,7 @@ TEST_F(MapImplTest, CopyAssignMapIterator) { static int Func(int i, int j) { return i * j; } -static std::string StrFunc(int i, int j) { - std::string str; - SStringPrintf(&str, "%d", Func(i, j)); - return str; -} +static std::string StrFunc(int i, int j) { return StrCat(Func(i, j)); } static int Int(const std::string& value) { int result = 0; @@ -992,6 +992,9 @@ static int Int(const std::string& value) { return result; } +} // namespace + +// This class is a friend, so no anonymous namespace. class MapFieldReflectionTest : public testing::Test { protected: typedef FieldDescriptor FD; @@ -1002,6 +1005,8 @@ class MapFieldReflectionTest : public testing::Test { } }; +namespace { + TEST_F(MapFieldReflectionTest, RegularFields) { TestMap message; const Reflection* refl = message.GetReflection(); @@ -3051,9 +3056,9 @@ TEST(WireFormatForMapFieldTest, MapByteSizeDynamicMessage) { EXPECT_EQ(expected_size, size); // Protobuf used to have a bug for serialize when map it marked CLEAN. It used - // repeated field to calculate ByteSize but use map to serialize the real data, - // thus the ByteSize may bigger than real serialized size. A crash might be - // happen at SerializeToString(). Or an "unexpect end group" warning was + // repeated field to calculate ByteSize but use map to serialize the real + // data, thus the ByteSize may bigger than real serialized size. A crash might + // be happen at SerializeToString(). Or an "unexpect end group" warning was // raised at parse back if user use SerializeWithCachedSizes() which avoids // size check at serialize. std::string serialized_data; @@ -3505,6 +3510,8 @@ TEST(MoveTest, MoveAssignmentWorks) { EXPECT_EQ(nested_msg43_ptr, &moved_to_map[43].optional_nested_message()); } + +} // namespace } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 650ca46c199b..d35dfffa3cdd 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -32,13 +32,12 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include + #include #include #include -#include -#include - #include #include #include @@ -48,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -136,388 +136,9 @@ void Message::DiscardUnknownFields() { return ReflectionOps::DiscardUnknownFields(this); } -namespace internal { - -class ReflectionAccessor { - public: - static void* GetOffset(void* msg, const google::protobuf::FieldDescriptor* f, - const google::protobuf::Reflection* r) { - return static_cast(msg) + r->schema_.GetFieldOffset(f); - } - - static void* GetRepeatedEnum(const Reflection* reflection, - const FieldDescriptor* field, Message* msg) { - return reflection->MutableRawRepeatedField( - msg, field, FieldDescriptor::CPPTYPE_ENUM, 0, nullptr); - } - - static InternalMetadataWithArena* MutableInternalMetadataWithArena( - const Reflection* reflection, Message* msg) { - return reflection->MutableInternalMetadataWithArena(msg); - } -}; - -} // namespace internal - -void SetField(uint64 val, const FieldDescriptor* field, Message* msg, - const Reflection* reflection) { -#define STORE_TYPE(CPPTYPE_METHOD) \ - do \ - if (field->is_repeated()) { \ - reflection->Add##CPPTYPE_METHOD(msg, field, value); \ - } else { \ - reflection->Set##CPPTYPE_METHOD(msg, field, value); \ - } \ - while (0) - - switch (field->type()) { -#define HANDLE_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: { \ - CPPTYPE value = val; \ - STORE_TYPE(CPPTYPE_METHOD); \ - break; \ - } - - // Varints - HANDLE_TYPE(INT32, int32, Int32) - HANDLE_TYPE(INT64, int64, Int64) - HANDLE_TYPE(UINT32, uint32, UInt32) - HANDLE_TYPE(UINT64, uint64, UInt64) - case FieldDescriptor::TYPE_SINT32: { - int32 value = WireFormatLite::ZigZagDecode32(val); - STORE_TYPE(Int32); - break; - } - case FieldDescriptor::TYPE_SINT64: { - int64 value = WireFormatLite::ZigZagDecode64(val); - STORE_TYPE(Int64); - break; - } - HANDLE_TYPE(BOOL, bool, Bool) - - // Fixed - HANDLE_TYPE(FIXED32, uint32, UInt32) - HANDLE_TYPE(FIXED64, uint64, UInt64) - HANDLE_TYPE(SFIXED32, int32, Int32) - HANDLE_TYPE(SFIXED64, int64, Int64) - - case FieldDescriptor::TYPE_FLOAT: { - float value; - uint32 bit_rep = val; - std::memcpy(&value, &bit_rep, sizeof(value)); - STORE_TYPE(Float); - break; - } - case FieldDescriptor::TYPE_DOUBLE: { - double value; - uint64 bit_rep = val; - std::memcpy(&value, &bit_rep, sizeof(value)); - STORE_TYPE(Double); - break; - } - case FieldDescriptor::TYPE_ENUM: { - int value = val; - if (field->is_repeated()) { - reflection->AddEnumValue(msg, field, value); - } else { - reflection->SetEnumValue(msg, field, value); - } - break; - } - default: - GOOGLE_LOG(FATAL) << "Error in descriptors, primitive field with field type " - << field->type(); - } -#undef STORE_TYPE -#undef HANDLE_TYPE -} - -bool ReflectiveValidator(const void* arg, int val) { - auto d = static_cast(arg); - return d->FindValueByNumber(val) != nullptr; -} - -const char* ParsePackedField(const FieldDescriptor* field, Message* msg, - const Reflection* reflection, const char* ptr, - internal::ParseContext* ctx) { - switch (field->type()) { -#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, METHOD_NAME) \ - case FieldDescriptor::TYPE_##TYPE: \ - return internal::Packed##METHOD_NAME##Parser( \ - reflection->MutableRepeatedFieldInternal(msg, field), ptr, \ - ctx) - HANDLE_PACKED_TYPE(INT32, int32, Int32); - HANDLE_PACKED_TYPE(INT64, int64, Int64); - HANDLE_PACKED_TYPE(SINT32, int32, SInt32); - HANDLE_PACKED_TYPE(SINT64, int64, SInt64); - HANDLE_PACKED_TYPE(UINT32, uint32, UInt32); - HANDLE_PACKED_TYPE(UINT64, uint64, UInt64); - HANDLE_PACKED_TYPE(BOOL, bool, Bool); - case FieldDescriptor::TYPE_ENUM: { - auto object = - internal::ReflectionAccessor::GetRepeatedEnum(reflection, field, msg); - if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { - return internal::PackedEnumParser(object, ptr, ctx); - } else { - return internal::PackedEnumParserArg( - object, ptr, ctx, ReflectiveValidator, field->enum_type(), - internal::ReflectionAccessor::MutableInternalMetadataWithArena( - reflection, msg), - field->number()); - } - } - HANDLE_PACKED_TYPE(FIXED32, uint32, Fixed32); - HANDLE_PACKED_TYPE(FIXED64, uint64, Fixed64); - HANDLE_PACKED_TYPE(SFIXED32, int32, SFixed32); - HANDLE_PACKED_TYPE(SFIXED64, int64, SFixed64); - HANDLE_PACKED_TYPE(FLOAT, float, Float); - HANDLE_PACKED_TYPE(DOUBLE, double, Double); -#undef HANDLE_PACKED_TYPE - - default: - GOOGLE_LOG(FATAL) << "Type is not packable " << field->type(); - return nullptr; // Make compiler happy - } -} - -const char* ParseLenDelim(int field_number, const FieldDescriptor* field, - Message* msg, const Reflection* reflection, - const char* ptr, internal::ParseContext* ctx) { - if (WireFormat::WireTypeForFieldType(field->type()) != - WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - GOOGLE_DCHECK(field->is_packable()); - return ParsePackedField(field, msg, reflection, ptr, ctx); - } - enum { kNone = 0, kVerify, kStrict } utf8_level = kNone; - const char* field_name = nullptr; - auto parse_string = [ptr, ctx, &utf8_level, - &field_name](std::string* s) -> const char* { - auto res = internal::InlineGreedyStringParser(s, ptr, ctx); - if (utf8_level != kNone) { - if (!internal::VerifyUTF8(s, field_name) && utf8_level == kStrict) { - return nullptr; - } - } - return res; - }; - switch (field->type()) { - case FieldDescriptor::TYPE_STRING: { - bool enforce_utf8 = true; - bool utf8_verification = true; - if (enforce_utf8 && - field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { - utf8_level = kStrict; - } else if (utf8_verification) { - utf8_level = kVerify; - } - field_name = field->full_name().c_str(); - PROTOBUF_FALLTHROUGH_INTENDED; - } - case FieldDescriptor::TYPE_BYTES: { - if (field->is_repeated()) { - int index = reflection->FieldSize(*msg, field); - // Add new empty value. - reflection->AddString(msg, field, ""); - if (field->options().ctype() == FieldOptions::STRING || - field->is_extension()) { - auto object = - reflection - ->MutableRepeatedPtrFieldInternal(msg, field) - ->Mutable(index); - return parse_string(object); - } else { - auto object = - reflection - ->MutableRepeatedPtrFieldInternal(msg, field) - ->Mutable(index); - return parse_string(object); - } - } else { - // Clear value and make sure it's set. - reflection->SetString(msg, field, ""); - if (field->options().ctype() == FieldOptions::STRING || - field->is_extension()) { - // HACK around inability to get mutable_string in reflection - std::string* object = &const_cast( - reflection->GetStringReference(*msg, field, nullptr)); - return parse_string(object); - } else { - // HACK around inability to get mutable_string in reflection - std::string* object = &const_cast( - reflection->GetStringReference(*msg, field, nullptr)); - return parse_string(object); - } - } - GOOGLE_LOG(FATAL) << "No other type than string supported"; - } - case FieldDescriptor::TYPE_MESSAGE: { - Message* object; - if (field->is_repeated()) { - object = reflection->AddMessage(msg, field, ctx->data().factory); - } else { - object = reflection->MutableMessage(msg, field, ctx->data().factory); - } - return ctx->ParseMessage(object, ptr); - } - default: - GOOGLE_LOG(FATAL) << "Wrong type for length delim " << field->type(); - } - return nullptr; // Make compiler happy. -} - -Message* GetGroup(int field_number, const FieldDescriptor* field, Message* msg, - const Reflection* reflection) { - if (field->is_repeated()) { - return reflection->AddMessage(msg, field, nullptr); - } else { - return reflection->MutableMessage(msg, field, nullptr); - } -} - const char* Message::_InternalParse(const char* ptr, internal::ParseContext* ctx) { - class ReflectiveFieldParser { - public: - ReflectiveFieldParser(Message* msg, internal::ParseContext* ctx) - : ReflectiveFieldParser(msg, ctx, false) {} - - void AddVarint(uint32 num, uint64 value) { - if (is_item_ && num == 2) { - if (!payload_.empty()) { - auto field = Field(value, 2); - if (field && field->message_type()) { - auto child = reflection_->MutableMessage(msg_, field); - // TODO(gerbens) signal error - child->ParsePartialFromString(payload_); - } else { - MutableUnknown()->AddLengthDelimited(value)->swap(payload_); - } - return; - } - type_id_ = value; - return; - } - auto field = Field(num, 0); - if (field) { - SetField(value, field, msg_, reflection_); - } else { - MutableUnknown()->AddVarint(num, value); - } - } - void AddFixed64(uint32 num, uint64 value) { - auto field = Field(num, 1); - if (field) { - SetField(value, field, msg_, reflection_); - } else { - MutableUnknown()->AddFixed64(num, value); - } - } - const char* ParseLengthDelimited(uint32 num, const char* ptr, - internal::ParseContext* ctx) { - if (is_item_ && num == 3) { - if (type_id_ == 0) { - return InlineGreedyStringParser(&payload_, ptr, ctx); - } - num = type_id_; - type_id_ = 0; - } - auto field = Field(num, 2); - if (field) { - return ParseLenDelim(num, field, msg_, reflection_, ptr, ctx); - } else { - return InlineGreedyStringParser( - MutableUnknown()->AddLengthDelimited(num), ptr, ctx); - } - } - const char* ParseGroup(uint32 num, const char* ptr, - internal::ParseContext* ctx) { - if (!is_item_ && descriptor_->options().message_set_wire_format() && - num == 1) { - is_item_ = true; - ptr = ctx->ParseGroup(this, ptr, num * 8 + 3); - is_item_ = false; - type_id_ = 0; - return ptr; - } - auto field = Field(num, 3); - if (field) { - auto msg = GetGroup(num, field, msg_, reflection_); - return ctx->ParseGroup(msg, ptr, num * 8 + 3); - } else { - return UnknownFieldParse(num * 8 + 3, MutableUnknown(), ptr, ctx); - } - } - void AddFixed32(uint32 num, uint32 value) { - auto field = Field(num, 5); - if (field) { - SetField(value, field, msg_, reflection_); - } else { - MutableUnknown()->AddFixed32(num, value); - } - } - - const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) { - // We're parsing the a MessageSetItem - GOOGLE_DCHECK(is_item_); - return internal::WireFormatParser(*this, ptr, ctx); - } - - private: - Message* msg_; - const Descriptor* descriptor_; - const Reflection* reflection_; - internal::ParseContext* ctx_; - UnknownFieldSet* unknown_ = nullptr; - bool is_item_ = false; - uint32 type_id_ = 0; - std::string payload_; - - ReflectiveFieldParser(Message* msg, internal::ParseContext* ctx, - bool is_item) - : msg_(msg), - descriptor_(msg->GetDescriptor()), - reflection_(msg->GetReflection()), - ctx_(ctx), - is_item_(is_item) { - GOOGLE_CHECK(descriptor_) << msg->GetTypeName(); - GOOGLE_CHECK(reflection_) << msg->GetTypeName(); - } - - const FieldDescriptor* Field(int num, int wire_type) { - auto field = descriptor_->FindFieldByNumber(num); - - // If that failed, check if the field is an extension. - if (field == nullptr && descriptor_->IsExtensionNumber(num)) { - const DescriptorPool* pool = ctx_->data().pool; - if (pool == nullptr) { - field = reflection_->FindKnownExtensionByNumber(num); - } else { - field = pool->FindExtensionByNumber(descriptor_, num); - } - } - if (field == nullptr) return nullptr; - - if (internal::WireFormat::WireTypeForFieldType(field->type()) != - wire_type) { - if (field->is_packable()) { - if (wire_type == - internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - return field; - } - } - return nullptr; - } - return field; - } - - UnknownFieldSet* MutableUnknown() { - if (unknown_) return unknown_; - return unknown_ = reflection_->MutableUnknownFields(msg_); - } - }; - - ReflectiveFieldParser field_parser(this, ctx); - return internal::WireFormatParser(field_parser, ptr, ctx); + return WireFormat::_InternalParse(this, ptr, ctx); } uint8* Message::_InternalSerialize(uint8* target, @@ -548,6 +169,11 @@ MessageFactory::~MessageFactory() {} namespace { + +#define HASH_MAP std::unordered_map +#define HASH_FXN hash + + class GeneratedMessageFactory : public MessageFactory { public: static GeneratedMessageFactory* singleton(); @@ -560,8 +186,8 @@ class GeneratedMessageFactory : public MessageFactory { private: // Only written at static init time, so does not require locking. - std::unordered_map, streq> + HASH_MAP, streq> file_map_; internal::WrappedMutex mutex_; diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 0b393fbabe57..b6156b8c9324 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -192,6 +192,26 @@ struct Metadata { const Reflection* reflection; }; +namespace internal { +template +inline To* GetPointerAtOffset(Message* message, uint32 offset) { + return reinterpret_cast(reinterpret_cast(message) + offset); +} + +template +const To* GetConstPointerAtOffset(const Message* message, uint32 offset) { + return reinterpret_cast(reinterpret_cast(message) + + offset); +} + +template +const To& GetConstRefAtOffset(const Message& message, uint32 offset) { + return *GetConstPointerAtOffset(&message, offset); +} + +bool CreateUnknownEnumValues(const FieldDescriptor* field); +} // namespace internal + // Abstract interface for protocol messages. // // See also MessageLite, which contains most every-day operations. Message @@ -205,7 +225,6 @@ struct Metadata { class PROTOBUF_EXPORT Message : public MessageLite { public: inline Message() {} - ~Message() override {} // Basic Operations ------------------------------------------------ @@ -337,6 +356,8 @@ class PROTOBUF_EXPORT Message : public MessageLite { // to implement GetDescriptor() and GetReflection() above. virtual Metadata GetMetadata() const = 0; + inline explicit Message(Arena* arena) : MessageLite(arena) {} + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message); @@ -914,7 +935,6 @@ class PROTOBUF_EXPORT Reflection final { friend class internal::ReflectionOps; // Needed for implementing text format for map. friend class internal::MapFieldPrinterHelper; - friend class internal::ReflectionAccessor; Reflection(const Descriptor* descriptor, const internal::ReflectionSchema& schema, @@ -980,7 +1000,7 @@ class PROTOBUF_EXPORT Reflection final { template inline Type* MutableRaw(Message* message, const FieldDescriptor* field) const; template - inline const Type& DefaultRaw(const FieldDescriptor* field) const; + const Type& DefaultRaw(const FieldDescriptor* field) const; inline const uint32* GetHasBits(const Message& message) const; inline uint32* MutableHasBits(Message* message) const; @@ -990,14 +1010,13 @@ class PROTOBUF_EXPORT Reflection final { Message* message, const OneofDescriptor* oneof_descriptor) const; inline const internal::ExtensionSet& GetExtensionSet( const Message& message) const; - inline internal::ExtensionSet* MutableExtensionSet(Message* message) const; + internal::ExtensionSet* MutableExtensionSet(Message* message) const; inline Arena* GetArena(Message* message) const; - inline const internal::InternalMetadataWithArena& - GetInternalMetadataWithArena(const Message& message) const; + inline const internal::InternalMetadata& GetInternalMetadata( + const Message& message) const; - internal::InternalMetadataWithArena* MutableInternalMetadataWithArena( - Message* message) const; + internal::InternalMetadata* MutableInternalMetadata(Message* message) const; inline bool IsInlined(const FieldDescriptor* field) const; @@ -1287,6 +1306,11 @@ inline RepeatedPtrField* Reflection::MutableRepeatedPtrFieldInternal( MutableRawRepeatedField(message, field, FieldDescriptor::CPPTYPE_MESSAGE, -1, PB::default_instance().GetDescriptor())); } + +template +const Type& Reflection::DefaultRaw(const FieldDescriptor* field) const { + return *reinterpret_cast(schema_.GetFieldDefault(field)); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 4f5cc5fe917b..5b1db7b9beb1 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -117,6 +117,16 @@ inline StringPiece as_string_view(const void* data, int size) { return StringPiece(static_cast(data), size); } +// Returns true of all required fields are present / have values. +inline bool CheckFieldPresence(const internal::ParseContext& ctx, + const MessageLite& msg, + MessageLite::ParseFlags parse_flags) { + if (PROTOBUF_PREDICT_FALSE((parse_flags & MessageLite::kMergePartial) != 0)) { + return true; + } + return msg.IsInitializedWithErrors(); +} + } // namespace void MessageLite::LogInitializationErrorMessage() const { @@ -126,46 +136,62 @@ void MessageLite::LogInitializationErrorMessage() const { namespace internal { template -bool MergePartialFromImpl(StringPiece input, MessageLite* msg) { +bool MergeFromImpl(StringPiece input, MessageLite* msg, + MessageLite::ParseFlags parse_flags) { const char* ptr; internal::ParseContext ctx(io::CodedInputStream::GetDefaultRecursionLimit(), aliasing, &ptr, input); ptr = msg->_InternalParse(ptr, &ctx); // ctx has an explicit limit set (length of string_view). - return ptr && ctx.EndedAtLimit(); + if (PROTOBUF_PREDICT_TRUE(ptr && ctx.EndedAtLimit())) { + return CheckFieldPresence(ctx, *msg, parse_flags); + } + return false; } template -bool MergePartialFromImpl(io::ZeroCopyInputStream* input, MessageLite* msg) { +bool MergeFromImpl(io::ZeroCopyInputStream* input, MessageLite* msg, + MessageLite::ParseFlags parse_flags) { const char* ptr; internal::ParseContext ctx(io::CodedInputStream::GetDefaultRecursionLimit(), aliasing, &ptr, input); ptr = msg->_InternalParse(ptr, &ctx); // ctx has no explicit limit (hence we end on end of stream) - return ptr && ctx.EndedAtEndOfStream(); + if (PROTOBUF_PREDICT_TRUE(ptr && ctx.EndedAtEndOfStream())) { + return CheckFieldPresence(ctx, *msg, parse_flags); + } + return false; } template -bool MergePartialFromImpl(BoundedZCIS input, MessageLite* msg) { +bool MergeFromImpl(BoundedZCIS input, MessageLite* msg, + MessageLite::ParseFlags parse_flags) { const char* ptr; internal::ParseContext ctx(io::CodedInputStream::GetDefaultRecursionLimit(), aliasing, &ptr, input.zcis, input.limit); ptr = msg->_InternalParse(ptr, &ctx); if (PROTOBUF_PREDICT_FALSE(!ptr)) return false; ctx.BackUp(ptr); - return ctx.EndedAtLimit(); -} - -template bool MergePartialFromImpl(StringPiece input, - MessageLite* msg); -template bool MergePartialFromImpl(StringPiece input, - MessageLite* msg); -template bool MergePartialFromImpl(io::ZeroCopyInputStream* input, - MessageLite* msg); -template bool MergePartialFromImpl(io::ZeroCopyInputStream* input, - MessageLite* msg); -template bool MergePartialFromImpl(BoundedZCIS input, MessageLite* msg); -template bool MergePartialFromImpl(BoundedZCIS input, MessageLite* msg); + if (PROTOBUF_PREDICT_TRUE(ctx.EndedAtLimit())) { + return CheckFieldPresence(ctx, *msg, parse_flags); + } + return false; +} + +template bool MergeFromImpl(StringPiece input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +template bool MergeFromImpl(StringPiece input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +template bool MergeFromImpl(io::ZeroCopyInputStream* input, + MessageLite* msg, + MessageLite::ParseFlags parse_flags); +template bool MergeFromImpl(io::ZeroCopyInputStream* input, + MessageLite* msg, + MessageLite::ParseFlags parse_flags); +template bool MergeFromImpl(BoundedZCIS input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +template bool MergeFromImpl(BoundedZCIS input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); } // namespace internal @@ -195,7 +221,8 @@ class ZeroCopyCodedInputStream : public io::ZeroCopyInputStream { io::CodedInputStream* cis_; }; -bool MessageLite::MergePartialFromCodedStream(io::CodedInputStream* input) { +bool MessageLite::MergeFromImpl(io::CodedInputStream* input, + MessageLite::ParseFlags parse_flags) { ZeroCopyCodedInputStream zcis(input); const char* ptr; internal::ParseContext ctx(input->RecursionBudget(), zcis.aliasing_enabled(), @@ -213,24 +240,28 @@ bool MessageLite::MergePartialFromCodedStream(io::CodedInputStream* input) { GOOGLE_DCHECK(ctx.LastTag() != 1); // We can't end on a pushed limit. if (ctx.IsExceedingLimit(ptr)) return false; input->SetLastTag(ctx.LastTag()); - return true; + } else { + input->SetConsumed(); } - input->SetConsumed(); - return true; + return CheckFieldPresence(ctx, *this, parse_flags); +} + +bool MessageLite::MergePartialFromCodedStream(io::CodedInputStream* input) { + return MergeFromImpl(input, kMergePartial); } bool MessageLite::MergeFromCodedStream(io::CodedInputStream* input) { - return MergePartialFromCodedStream(input) && IsInitializedWithErrors(); + return MergeFromImpl(input, kMerge); } bool MessageLite::ParseFromCodedStream(io::CodedInputStream* input) { Clear(); - return MergeFromCodedStream(input); + return MergeFromImpl(input, kParse); } bool MessageLite::ParsePartialFromCodedStream(io::CodedInputStream* input) { Clear(); - return MergePartialFromCodedStream(input); + return MergeFromImpl(input, kParsePartial); } bool MessageLite::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) { diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 31746f3e3862..d2cea5dc45fb 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -184,7 +185,7 @@ PROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const std::string& str); class PROTOBUF_EXPORT MessageLite { public: inline MessageLite() {} - virtual ~MessageLite() {} + virtual ~MessageLite() = default; // Basic Operations ------------------------------------------------ @@ -201,10 +202,10 @@ class PROTOBUF_EXPORT MessageLite { // Get the arena, if any, associated with this message. Virtual method // required for generic operations but most arena-related operations should - // use the GetArenaNoVirtual() generated-code method. Default implementation + // use the GetArena() generated-code method. Default implementation // to reduce code size by avoiding the need for per-type implementations // when types do not implement arena support. - virtual Arena* GetArena() const { return NULL; } + Arena* GetArena() const { return _internal_metadata_.arena(); } // Get a pointer that may be equal to this message's arena, or may not be. // If the value returned by this method is equal to some arena pointer, then @@ -215,7 +216,9 @@ class PROTOBUF_EXPORT MessageLite { // store the arena pointer directly, and sometimes in a more indirect way, // and allow a fastpath comparison against the arena pointer when it's easy // to obtain. - virtual void* GetMaybeArenaPointer() const { return GetArena(); } + void* GetMaybeArenaPointer() const { + return _internal_metadata_.raw_arena_ptr(); + } // Clear all fields of the message and set them to their default values. // Clear() avoids freeing memory, assuming that any memory allocated @@ -444,6 +447,10 @@ class PROTOBUF_EXPORT MessageLite { return Arena::CreateMaybeMessage(arena); } + inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {} + + internal::InternalMetadata _internal_metadata_; + public: enum ParseFlags { kMerge = 0, @@ -464,6 +471,13 @@ class PROTOBUF_EXPORT MessageLite { virtual uint8* _InternalSerialize(uint8* ptr, io::EpsCopyOutputStream* stream) const = 0; + // Identical to IsInitialized() except that it logs an error message. + bool IsInitializedWithErrors() const { + if (IsInitialized()) return true; + LogInitializationErrorMessage(); + return false; + } + private: // TODO(gerbens) make this a pure abstract function virtual const void* InternalGetTable() const { return NULL; } @@ -472,32 +486,34 @@ class PROTOBUF_EXPORT MessageLite { friend class Message; friend class internal::WeakFieldMap; - bool IsInitializedWithErrors() const { - if (IsInitialized()) return true; - LogInitializationErrorMessage(); - return false; - } - void LogInitializationErrorMessage() const; + bool MergeFromImpl(io::CodedInputStream* input, ParseFlags parse_flags); + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite); }; namespace internal { template -bool MergePartialFromImpl(StringPiece input, MessageLite* msg); -extern template bool MergePartialFromImpl(StringPiece input, - MessageLite* msg); -extern template bool MergePartialFromImpl(StringPiece input, - MessageLite* msg); +bool MergeFromImpl(StringPiece input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +extern template bool MergeFromImpl(StringPiece input, + MessageLite* msg, + MessageLite::ParseFlags parse_flags); +extern template bool MergeFromImpl(StringPiece input, + MessageLite* msg, + MessageLite::ParseFlags parse_flags); template -bool MergePartialFromImpl(io::ZeroCopyInputStream* input, MessageLite* msg); -extern template bool MergePartialFromImpl(io::ZeroCopyInputStream* input, - MessageLite* msg); -extern template bool MergePartialFromImpl(io::ZeroCopyInputStream* input, - MessageLite* msg); +bool MergeFromImpl(io::ZeroCopyInputStream* input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +extern template bool MergeFromImpl(io::ZeroCopyInputStream* input, + MessageLite* msg, + MessageLite::ParseFlags parse_flags); +extern template bool MergeFromImpl(io::ZeroCopyInputStream* input, + MessageLite* msg, + MessageLite::ParseFlags parse_flags); struct BoundedZCIS { io::ZeroCopyInputStream* zcis; @@ -505,18 +521,20 @@ struct BoundedZCIS { }; template -bool MergePartialFromImpl(BoundedZCIS input, MessageLite* msg); -extern template bool MergePartialFromImpl(BoundedZCIS input, - MessageLite* msg); -extern template bool MergePartialFromImpl(BoundedZCIS input, - MessageLite* msg); +bool MergeFromImpl(BoundedZCIS input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +extern template bool MergeFromImpl(BoundedZCIS input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); +extern template bool MergeFromImpl(BoundedZCIS input, MessageLite* msg, + MessageLite::ParseFlags parse_flags); template struct SourceWrapper; template -bool MergePartialFromImpl(const SourceWrapper& input, MessageLite* msg) { - return input.template MergePartialInto(msg); +bool MergeFromImpl(const SourceWrapper& input, MessageLite* msg, + MessageLite::ParseFlags parse_flags) { + return input.template MergeInto(msg, parse_flags); } } // namespace internal @@ -524,9 +542,8 @@ bool MergePartialFromImpl(const SourceWrapper& input, MessageLite* msg) { template bool MessageLite::ParseFrom(const T& input) { if (flags & kParse) Clear(); - constexpr bool alias = flags & kMergeWithAliasing; - bool res = internal::MergePartialFromImpl(input, this); - return res && ((flags & kMergePartial) || IsInitializedWithErrors()); + constexpr bool alias = (flags & kMergeWithAliasing) != 0; + return internal::MergeFromImpl(input, this, flags); } // =================================================================== diff --git a/src/google/protobuf/metadata.h b/src/google/protobuf/metadata.h index 009a7e93a6d7..4e89648ee672 100644 --- a/src/google/protobuf/metadata.h +++ b/src/google/protobuf/metadata.h @@ -28,51 +28,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// This header file defines an internal class that encapsulates internal message -// metadata (Unknown-field set, Arena pointer, ...) and allows its -// representation to be made more space-efficient via various optimizations. -// -// Note that this is distinct from google::protobuf::Metadata, which encapsulates -// Descriptor and Reflection pointers. - #ifndef GOOGLE_PROTOBUF_METADATA_H__ #define GOOGLE_PROTOBUF_METADATA_H__ -#include -#include - -#ifdef SWIG -#error "You cannot SWIG proto headers" -#endif - -namespace google { -namespace protobuf { -namespace internal { - -class InternalMetadataWithArena - : public InternalMetadataWithArenaBase { - public: - InternalMetadataWithArena() {} - explicit InternalMetadataWithArena(Arena* arena) - : InternalMetadataWithArenaBase(arena) {} - - void DoSwap(UnknownFieldSet* other) { mutable_unknown_fields()->Swap(other); } - - void DoMergeFrom(const UnknownFieldSet& other) { - mutable_unknown_fields()->MergeFrom(other); - } - - void DoClear() { mutable_unknown_fields()->Clear(); } - - static const UnknownFieldSet& default_instance() { - return *UnknownFieldSet::default_instance(); - } -}; - -} // namespace internal -} // namespace protobuf -} // namespace google +// TODO(b/151117630): Remove this file and all instances where it gets imported. #endif // GOOGLE_PROTOBUF_METADATA_H__ diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index 2b762fa6b48d..dc4ec956b7b3 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include #include @@ -58,48 +56,54 @@ namespace internal { // The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to // indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container // pointer. -template -class InternalMetadataWithArenaBase { +class InternalMetadata { public: - InternalMetadataWithArenaBase() : ptr_(NULL) {} - explicit InternalMetadataWithArenaBase(Arena* arena) : ptr_(arena) {} + InternalMetadata() : ptr_(nullptr) {} + explicit InternalMetadata(Arena* arena) : ptr_(arena) {} - ~InternalMetadataWithArenaBase() { + template + void Delete() { + // Note that Delete<> should be called not more than once. if (have_unknown_fields() && arena() == NULL) { - delete PtrValue(); + delete PtrValue>(); } - ptr_ = NULL; } - PROTOBUF_ALWAYS_INLINE const T& unknown_fields() const { + PROTOBUF_ALWAYS_INLINE Arena* arena() const { if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue()->unknown_fields; + return PtrValue()->arena; } else { - return Derived::default_instance(); + return PtrValue(); } } - PROTOBUF_ALWAYS_INLINE T* mutable_unknown_fields() { - if (PROTOBUF_PREDICT_TRUE(have_unknown_fields())) { - return &PtrValue()->unknown_fields; - } else { - return mutable_unknown_fields_slow(); - } + PROTOBUF_ALWAYS_INLINE bool have_unknown_fields() const { + return PtrTag() == kTagContainer; } - PROTOBUF_ALWAYS_INLINE Arena* arena() const { + PROTOBUF_ALWAYS_INLINE void* raw_arena_ptr() const { return ptr_; } + + template + PROTOBUF_ALWAYS_INLINE const T& unknown_fields( + const T& (*default_instance)()) const { if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue()->arena; + return PtrValue>()->unknown_fields; } else { - return PtrValue(); + return default_instance(); } } - PROTOBUF_ALWAYS_INLINE bool have_unknown_fields() const { - return PtrTag() == kTagContainer; + template + PROTOBUF_ALWAYS_INLINE T* mutable_unknown_fields() { + if (PROTOBUF_PREDICT_TRUE(have_unknown_fields())) { + return &PtrValue>()->unknown_fields; + } else { + return mutable_unknown_fields_slow(); + } } - PROTOBUF_ALWAYS_INLINE void Swap(Derived* other) { + template + PROTOBUF_ALWAYS_INLINE void Swap(InternalMetadata* other) { // Semantics here are that we swap only the unknown fields, not the arena // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in @@ -107,24 +111,24 @@ class InternalMetadataWithArenaBase { // cannot simply swap ptr_ and then restore the arena pointers. We reuse // UFS's swap implementation instead. if (have_unknown_fields() || other->have_unknown_fields()) { - static_cast(this)->DoSwap(other->mutable_unknown_fields()); + DoSwap(other->mutable_unknown_fields()); } } - PROTOBUF_ALWAYS_INLINE void MergeFrom(const Derived& other) { + template + PROTOBUF_ALWAYS_INLINE void MergeFrom(const InternalMetadata& other) { if (other.have_unknown_fields()) { - static_cast(this)->DoMergeFrom(other.unknown_fields()); + DoMergeFrom(other.unknown_fields(nullptr)); } } + template PROTOBUF_ALWAYS_INLINE void Clear() { if (have_unknown_fields()) { - static_cast(this)->DoClear(); + DoClear(); } } - PROTOBUF_ALWAYS_INLINE void* raw_arena_ptr() const { return ptr_; } - private: void* ptr_; @@ -150,14 +154,19 @@ class InternalMetadataWithArenaBase { } // If ptr_'s tag is kTagContainer, it points to an instance of this struct. - struct Container { - T unknown_fields; + struct ContainerBase { Arena* arena; }; + template + struct Container : public ContainerBase { + T unknown_fields; + }; + + template PROTOBUF_NOINLINE T* mutable_unknown_fields_slow() { Arena* my_arena = arena(); - Container* container = Arena::Create(my_arena); + Container* container = Arena::Create>(my_arena); // Two-step assignment works around a bug in clang's static analyzer: // https://bugs.llvm.org/show_bug.cgi?id=34198. ptr_ = container; @@ -166,40 +175,43 @@ class InternalMetadataWithArenaBase { container->arena = my_arena; return &(container->unknown_fields); } -}; -// We store unknown fields as a std::string right now, because there is -// currently no good interface for reading unknown fields into an ArenaString. -// We may want to revisit this to allow unknown fields to be parsed onto the -// Arena. -class InternalMetadataWithArenaLite - : public InternalMetadataWithArenaBase { - public: - InternalMetadataWithArenaLite() {} - - explicit InternalMetadataWithArenaLite(Arena* arena) - : InternalMetadataWithArenaBase(arena) {} + // Templated functions. - void DoSwap(std::string* other) { mutable_unknown_fields()->swap(*other); } - - void DoMergeFrom(const std::string& other) { - mutable_unknown_fields()->append(other); + template + void DoClear() { + mutable_unknown_fields()->Clear(); } - void DoClear() { mutable_unknown_fields()->clear(); } + template + void DoMergeFrom(const T& other) { + mutable_unknown_fields()->MergeFrom(other); + } - static const std::string& default_instance() { - // Can't use GetEmptyStringAlreadyInited() here because empty string - // may not have been initialized yet. This happens when protocol compiler - // statically determines the user can't access defaults and omits init code - // from proto constructors. However unknown fields are always part of a - // proto so it needs to be lazily initialized. See b/112613846. - return GetEmptyString(); + template + void DoSwap(T* other) { + mutable_unknown_fields()->Swap(other); } }; +// String Template specializations. + +template <> +inline void InternalMetadata::DoClear() { + mutable_unknown_fields()->clear(); +} + +template <> +inline void InternalMetadata::DoMergeFrom( + const std::string& other) { + mutable_unknown_fields()->append(other); +} + +template <> +inline void InternalMetadata::DoSwap(std::string* other) { + mutable_unknown_fields()->swap(*other); +} + // This helper RAII class is needed to efficiently parse unknown fields. We // should only call mutable_unknown_fields if there are actual unknown fields. // The obvious thing to just use a stack string and swap it at the end of @@ -210,19 +222,20 @@ class InternalMetadataWithArenaLite // guarantees that the string is only swapped after stream is destroyed. class PROTOBUF_EXPORT LiteUnknownFieldSetter { public: - explicit LiteUnknownFieldSetter(InternalMetadataWithArenaLite* metadata) + explicit LiteUnknownFieldSetter(InternalMetadata* metadata) : metadata_(metadata) { if (metadata->have_unknown_fields()) { - buffer_.swap(*metadata->mutable_unknown_fields()); + buffer_.swap(*metadata->mutable_unknown_fields()); } } ~LiteUnknownFieldSetter() { - if (!buffer_.empty()) metadata_->mutable_unknown_fields()->swap(buffer_); + if (!buffer_.empty()) + metadata_->mutable_unknown_fields()->swap(buffer_); } std::string* buffer() { return &buffer_; } private: - InternalMetadataWithArenaLite* metadata_; + InternalMetadata* metadata_; std::string buffer_; }; diff --git a/src/google/protobuf/parse_context.cc b/src/google/protobuf/parse_context.cc index 6cf63b78586a..ea4ed19650b7 100644 --- a/src/google/protobuf/parse_context.cc +++ b/src/google/protobuf/parse_context.cc @@ -474,36 +474,6 @@ const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx) { return VarintParser(object, ptr, ctx); } -const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), - InternalMetadataWithArenaLite* metadata, - int field_num) { - return ctx->ReadPackedVarint( - ptr, [object, is_valid, metadata, field_num](uint64 val) { - if (is_valid(val)) { - static_cast*>(object)->Add(val); - } else { - WriteVarint(field_num, val, metadata->mutable_unknown_fields()); - } - }); -} - -const char* PackedEnumParserArg(void* object, const char* ptr, - ParseContext* ctx, - bool (*is_valid)(const void*, int), - const void* data, - InternalMetadataWithArenaLite* metadata, - int field_num) { - return ctx->ReadPackedVarint( - ptr, [object, is_valid, data, metadata, field_num](uint64 val) { - if (is_valid(data, val)) { - static_cast*>(object)->Add(val); - } else { - WriteVarint(field_num, val, metadata->mutable_unknown_fields()); - } - }); -} - const char* PackedBoolParser(void* object, const char* ptr, ParseContext* ctx) { return VarintParser(object, ptr, ctx); } @@ -604,12 +574,6 @@ const char* UnknownFieldParse(uint32 tag, std::string* unknown, const char* ptr, return FieldParser(tag, field_parser, ptr, ctx); } -const char* UnknownFieldParse(uint32 tag, - InternalMetadataWithArenaLite* metadata, - const char* ptr, ParseContext* ctx) { - return UnknownFieldParse(tag, metadata->mutable_unknown_fields(), ptr, ctx); -} - } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 9b2a473ddd84..c83eed94cf5a 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -239,6 +239,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { const char* InitFrom(io::ZeroCopyInputStream* zcis); const char* InitFrom(io::ZeroCopyInputStream* zcis, int limit) { + if (limit == -1) return InitFrom(zcis); overall_limit_ = limit; auto res = InitFrom(zcis); limit_ = limit - static_cast(buffer_end_ - res); @@ -741,13 +742,39 @@ PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedSInt64Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( - void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(int), - InternalMetadataWithArenaLite* metadata, int field_num); -PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParserArg( - void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(const void*, int), const void* data, - InternalMetadataWithArenaLite* metadata, int field_num); + +template +PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) +PROTOBUF_MUST_USE_RESULT const + char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, + bool (*is_valid)(int), InternalMetadata* metadata, + int field_num) { + return ctx->ReadPackedVarint( + ptr, [object, is_valid, metadata, field_num](uint64 val) { + if (is_valid(val)) { + static_cast*>(object)->Add(val); + } else { + WriteVarint(field_num, val, metadata->mutable_unknown_fields()); + } + }); +} + +template +PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) +PROTOBUF_MUST_USE_RESULT const + char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx, + bool (*is_valid)(const void*, int), + const void* data, InternalMetadata* metadata, + int field_num) { + return ctx->ReadPackedVarint( + ptr, [object, is_valid, data, metadata, field_num](uint64 val) { + if (is_valid(data, val)) { + static_cast*>(object)->Add(val); + } else { + WriteVarint(field_num, val, metadata->mutable_unknown_fields()); + } + }); +} PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedBoolParser( void* object, const char* ptr, ParseContext* ctx); @@ -772,9 +799,6 @@ PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* UnknownGroupLiteParse( // UnknownFieldSet* to make the generated code isomorphic between full and lite. PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* UnknownFieldParse( uint32 tag, std::string* unknown, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* UnknownFieldParse( - uint32 tag, InternalMetadataWithArenaLite* metadata, const char* ptr, - ParseContext* ctx); } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index f127e60797a0..81080c8e7de3 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -136,6 +136,9 @@ #ifdef PROTOBUF_UNUSED #error PROTOBUF_UNUSED was previously defined #endif +#ifdef PROTOBUF_FINAL +#error PROTOBUF_FINAL was previously defined +#endif #define PROTOBUF_NAMESPACE "google::protobuf" @@ -315,7 +318,7 @@ // https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98 #define PROTOBUF_RTTI 0 #elif defined(__GNUC__) && !defined(__GXX_RTTI) -# https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +#https: // gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html #define PROTOBUF_RTTI 0 #else #define PROTOBUF_RTTI 1 @@ -338,7 +341,10 @@ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ __builtin_offsetof(TYPE, FIELD) \ _Pragma("clang diagnostic pop") -#else +#elif defined(__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) +#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD) +#else // defined(__clang__) // Note that we calculate relative to the pointer value 16 here since if we // just use zero, GCC complains about dereferencing a NULL pointer. We // choose 16 rather than some other number just in case the compiler would @@ -352,28 +358,20 @@ #if defined(PROTOBUF_USE_DLLS) #if defined(_MSC_VER) #ifdef LIBPROTOBUF_EXPORTS - #define PROTOBUF_EXPORT __declspec(dllexport) - #define PROTOBUF_EXPORT_TEMPLATE_DECLARE - #define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) + #define PROTOBUF_EXPORT __declspec(dllexport) #else - #define PROTOBUF_EXPORT __declspec(dllimport) - #define PROTOBUF_EXPORT_TEMPLATE_DECLARE - #define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) + #define PROTOBUF_EXPORT __declspec(dllimport) #endif #ifdef LIBPROTOC_EXPORTS - #define PROTOC_EXPORT __declspec(dllexport) + #define PROTOC_EXPORT __declspec(dllexport) #else - #define PROTOC_EXPORT __declspec(dllimport) + #define PROTOC_EXPORT __declspec(dllimport) #endif #else // defined(_MSC_VER) #ifdef LIBPROTOBUF_EXPORTS #define PROTOBUF_EXPORT __attribute__((visibility("default"))) - #define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) - #define PROTOBUF_EXPORT_TEMPLATE_DEFINE #else #define PROTOBUF_EXPORT - #define PROTOBUF_EXPORT_TEMPLATE_DECLARE - #define PROTOBUF_EXPORT_TEMPLATE_DEFINE #endif #ifdef LIBPROTOC_EXPORTS #define PROTOC_EXPORT __attribute__((visibility("default"))) @@ -384,10 +382,168 @@ #else // defined(PROTOBUF_USE_DLLS) #define PROTOBUF_EXPORT #define PROTOC_EXPORT - #define PROTOBUF_EXPORT_TEMPLATE_DECLARE - #define PROTOBUF_EXPORT_TEMPLATE_DEFINE #endif + +// This portion provides macros for using FOO_EXPORT macros with explicit +// template instantiation declarations and definitions. +// Generally, the FOO_EXPORT macros are used at declarations, +// and GCC requires them to be used at explicit instantiation declarations, +// but MSVC requires __declspec(dllexport) to be used at the explicit +// instantiation definitions instead. + +// Usage +// +// In a header file, write: +// +// extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(FOO_EXPORT) foo; +// +// In a source file, write: +// +// template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(FOO_EXPORT) foo; +// +// Where FOO_EXPORT is either PROTOBUF_EXPORT or PROTOC_EXPORT + +// Implementation notes +// +// The implementation of these macros uses some subtle macro semantics to +// detect what the provided FOO_EXPORT value was defined as and then +// to dispatch to appropriate macro definitions. Unfortunately, +// MSVC's C preprocessor is rather non-compliant and requires special +// care to make it work. +// +// Issue 1. +// +// #define F(x) +// F() +// +// MSVC emits warning C4003 ("not enough actual parameters for macro +// 'F'), even though it's a valid macro invocation. This affects the +// macros below that take just an "export" parameter, because export +// may be empty. +// +// As a workaround, we can add a dummy parameter and arguments: +// +// #define F(x,_) +// F(,) +// +// Issue 2. +// +// #define F(x) G##x +// #define Gj() ok +// F(j()) +// +// The correct replacement for "F(j())" is "ok", but MSVC replaces it +// with "Gj()". As a workaround, we can pass the result to an +// identity macro to force MSVC to look for replacements again. (This +// is why PROTOBUF_EXPORT_TEMPLATE_STYLE_3 exists.) + +#define PROTOBUF_EXPORT_TEMPLATE_DECLARE(export) \ + PROTOBUF_EXPORT_TEMPLATE_INVOKE( \ + DECLARE, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), export) +#define PROTOBUF_EXPORT_TEMPLATE_DEFINE(export) \ + PROTOBUF_EXPORT_TEMPLATE_INVOKE( \ + DEFINE, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), export) + +// INVOKE is an internal helper macro to perform parameter replacements +// and token pasting to chain invoke another macro. E.g., +// PROTOBUF_EXPORT_TEMPLATE_INVOKE(DECLARE, DEFAULT, FOO_EXPORT) +// will export to call +// PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT(FOO_EXPORT, ) +// (but with FOO_EXPORT expanded too). +#define PROTOBUF_EXPORT_TEMPLATE_INVOKE(which, style, export) \ + PROTOBUF_EXPORT_TEMPLATE_INVOKE_2(which, style, export) +#define PROTOBUF_EXPORT_TEMPLATE_INVOKE_2(which, style, export) \ + PROTOBUF_EXPORT_TEMPLATE_##which##_##style(export, ) + +// Default style is to apply the FOO_EXPORT macro at declaration sites. +#define PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT(export, _) export +#define PROTOBUF_EXPORT_TEMPLATE_DEFINE_DEFAULT(export, _) + +// The "MSVC hack" style is used when FOO_EXPORT is defined +// as __declspec(dllexport), which MSVC requires to be used at +// definition sites instead. +#define PROTOBUF_EXPORT_TEMPLATE_DECLARE_MSVC_HACK(export, _) +#define PROTOBUF_EXPORT_TEMPLATE_DEFINE_MSVC_HACK(export, _) export + +// PROTOBUF_EXPORT_TEMPLATE_STYLE is an internal helper macro that identifies +// which export style needs to be used for the provided FOO_EXPORT macro +// definition. "", "__attribute__(...)", and "__declspec(dllimport)" are +// mapped to "DEFAULT"; while "__declspec(dllexport)" is mapped to "MSVC_HACK". +// +// It's implemented with token pasting to transform the __attribute__ and +// __declspec annotations into macro invocations. E.g., if FOO_EXPORT is +// defined as "__declspec(dllimport)", it undergoes the following sequence of +// macro substitutions: +// PROTOBUF_EXPORT_TEMPLATE_STYLE(FOO_EXPORT, ) +// PROTOBUF_EXPORT_TEMPLATE_STYLE_2(__declspec(dllimport), ) +// PROTOBUF_EXPORT_TEMPLATE_STYLE_3( +// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport)) +// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport) +// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport +// DEFAULT +#define PROTOBUF_EXPORT_TEMPLATE_STYLE(export, _) \ + PROTOBUF_EXPORT_TEMPLATE_STYLE_2(export, ) +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_2(export, _) \ + PROTOBUF_EXPORT_TEMPLATE_STYLE_3( \ + PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA##export) +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_3(style) style + +// Internal helper macros for PROTOBUF_EXPORT_TEMPLATE_STYLE. +// +// XXX: C++ reserves all identifiers containing "__" for the implementation, +// but "__attribute__" and "__declspec" already contain "__" and the token-paste +// operator can only add characters; not remove them. To minimize the risk of +// conflict with implementations, we include "foj3FJo5StF0OvIzl7oMxA" (a random +// 128-bit string, encoded in Base64) in the macro name. +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA DEFAULT +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__(...) \ + DEFAULT +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec(arg) \ + PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_##arg + +// Internal helper macros for PROTOBUF_EXPORT_TEMPLATE_STYLE. +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport MSVC_HACK +#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport DEFAULT + +// Sanity checks. +// +// PROTOBUF_EXPORT_TEMPLATE_TEST uses the same macro invocation pattern as +// PROTOBUF_EXPORT_TEMPLATE_DECLARE and PROTOBUF_EXPORT_TEMPLATE_DEFINE do to +// check that they're working correctly. When they're working correctly, the +// sequence of macro replacements should go something like: +// +// PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); +// +// static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT, +// PROTOBUF_EXPORT_TEMPLATE_STYLE(__declspec(dllimport), ), +// __declspec(dllimport)), "__declspec(dllimport)"); +// +// static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT, +// DEFAULT, __declspec(dllimport)), "__declspec(dllimport)"); +// +// static_assert(PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT( +// __declspec(dllimport)), "__declspec(dllimport)"); +// +// static_assert(true, "__declspec(dllimport)"); +// +// When they're not working correctly, a syntax error should occur instead. +#define PROTOBUF_EXPORT_TEMPLATE_TEST(want, export) \ + static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE( \ + TEST_##want, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), \ + export), #export) +#define PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT(...) true +#define PROTOBUF_EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK(...) true + +PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, ); +PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __attribute__((visibility("default")))); +PROTOBUF_EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport)); +PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); + +#undef PROTOBUF_EXPORT_TEMPLATE_TEST +#undef PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT +#undef PROTOBUF_EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK + // Windows declares several inconvenient macro names. We #undef them and then // restore them in port_undef.inc. #ifdef _MSC_VER @@ -409,11 +565,26 @@ #undef max #endif // _MSC_VER +#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) +// Don't let the YES/NO Objective-C Macros interfere with proto identifiers with +// the same name. +#pragma push_macro("YES") +#undef YES +#pragma push_macro("NO") +#undef NO +#endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) + #if defined(__clang__) #pragma clang diagnostic push // TODO(gerbens) ideally we cleanup the code. But a cursory try shows many // violations. So let's ignore for now. #pragma clang diagnostic ignored "-Wshorten-64-to-32" +#elif defined(__GNUC__) +// GCC does not allow disabling diagnostics within an expression: +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one +// globally even though it's only used for PROTOBUF_FIELD_OFFSET. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" #endif // PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To @@ -456,7 +627,10 @@ #if defined(_MSC_VER) #define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) #elif defined(__GNUC__) -#define PROTOBUF_ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) +#define PROTOBUF_ALIGNAS(byte_alignment) \ + __attribute__((aligned(byte_alignment))) #else #define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment) #endif + +#define PROTOBUF_FINAL final diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 2cc56f37347c..68339f62b0c5 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -69,6 +69,20 @@ #undef PROTOBUF_EXPORT_TEMPLATE_DECLARE #undef PROTOBUF_EXPORT_TEMPLATE_DEFINE #undef PROTOBUF_ALIGNAS +#undef PROTOBUF_EXPORT_TEMPLATE_INVOKE_2 +#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT +#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE_DEFAULT +#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE_MSVC_HACK +#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE_MSVC_HACK +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_2 +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_3 +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__ +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport +#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport +#undef PROTOBUF_FINAL // Restore macro that may have been #undef'd in port_def.inc. #ifdef _MSC_VER @@ -82,6 +96,13 @@ #pragma pop_macro("max") #endif +#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) +#pragma pop_macro("YES") +#pragma pop_macro("NO") +#endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) + #if defined(__clang__) #pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop #endif diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 75da9eb7a27e..60440d520d31 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -194,6 +195,32 @@ TEST(Proto3ArenaTest, MessageFieldClearViaReflection) { EXPECT_EQ(0, message->optional_nested_message().bb()); } +TEST(Proto3OptionalTest, OptionalFields) { + const Descriptor* d = protobuf_unittest::TestProto3Optional::descriptor(); + + for (int i = 0; i < d->field_count(); i++) { + const FieldDescriptor* f = d->field(i); + EXPECT_TRUE(f->has_optional_keyword()) << f->full_name(); + EXPECT_TRUE(f->is_singular_with_presence()) << f->full_name(); + EXPECT_TRUE(f->containing_oneof()) << f->full_name(); + } +} + +TEST(Proto3OptionalTest, PlainFields) { + const Descriptor* d = TestAllTypes::descriptor(); + + for (int i = 0; i < d->field_count(); i++) { + const FieldDescriptor* f = d->field(i); + EXPECT_FALSE(f->has_optional_keyword()) << f->full_name(); + if (f->is_optional() && f->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { + EXPECT_FALSE(f->is_singular_with_presence()) << f->full_name(); + } + } + + EXPECT_FALSE( + d->FindFieldByName("oneof_nested_message")->is_singular_with_presence()); +} + } // namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 077956a7bdca..5eee1ddc6245 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -125,8 +125,16 @@ void ReflectionOps::Merge(const Message& from, Message* to) { #undef HANDLE_TYPE case FieldDescriptor::CPPTYPE_MESSAGE: - to_reflection->AddMessage(to, field)->MergeFrom( - from_reflection->GetRepeatedMessage(from, field, j)); + const Message& from_child = + from_reflection->GetRepeatedMessage(from, field, j); + if (from_reflection == to_reflection) { + to_reflection + ->AddMessage(to, field, + from_child.GetReflection()->GetMessageFactory()) + ->MergeFrom(from_child); + } else { + to_reflection->AddMessage(to, field)->MergeFrom(from_child); + } break; } } @@ -150,8 +158,15 @@ void ReflectionOps::Merge(const Message& from, Message* to) { #undef HANDLE_TYPE case FieldDescriptor::CPPTYPE_MESSAGE: - to_reflection->MutableMessage(to, field)->MergeFrom( - from_reflection->GetMessage(from, field)); + const Message& from_child = from_reflection->GetMessage(from, field); + if (from_reflection == to_reflection) { + to_reflection + ->MutableMessage( + to, field, from_child.GetReflection()->GetMessageFactory()) + ->MergeFrom(from_child); + } else { + to_reflection->MutableMessage(to, field)->MergeFrom(from_child); + } break; } } @@ -178,10 +193,13 @@ bool ReflectionOps::IsInitialized(const Message& message) { const Reflection* reflection = GetReflectionOrDie(message); // Check required fields of this message. - for (int i = 0; i < descriptor->field_count(); i++) { - if (descriptor->field(i)->is_required()) { - if (!reflection->HasField(message, descriptor->field(i))) { - return false; + { + const int field_count = descriptor->field_count(); + for (int i = 0; i < field_count; i++) { + if (descriptor->field(i)->is_required()) { + if (!reflection->HasField(message, descriptor->field(i))) { + return false; + } } } } @@ -306,10 +324,13 @@ void ReflectionOps::FindInitializationErrors(const Message& message, const Reflection* reflection = GetReflectionOrDie(message); // Check required fields of this message. - for (int i = 0; i < descriptor->field_count(); i++) { - if (descriptor->field(i)->is_required()) { - if (!reflection->HasField(message, descriptor->field(i))) { - errors->push_back(prefix + descriptor->field(i)->name()); + { + const int field_count = descriptor->field_count(); + for (int i = 0; i < field_count; i++) { + if (descriptor->field(i)->is_required()) { + if (!reflection->HasField(message, descriptor->field(i))) { + errors->push_back(prefix + descriptor->field(i)->name()); + } } } } @@ -339,6 +360,21 @@ void ReflectionOps::FindInitializationErrors(const Message& message, } } +void GenericSwap(Message* m1, Message* m2) { + Arena* m2_arena = m2->GetArena(); + GOOGLE_DCHECK(m1->GetArena() != m2_arena); + + // Copy semantics in this case. We try to improve efficiency by placing the + // temporary on |m2|'s arena so that messages are copied twice rather than + // three times. + Message* tmp = m2->New(m2_arena); + std::unique_ptr tmp_deleter(m2_arena == nullptr ? tmp : nullptr); + tmp->CheckTypeAndMergeFrom(*m1); + m1->Clear(); + m1->CheckTypeAndMergeFrom(*m2); + m2->GetReflection()->Swap(tmp, m2); +} + } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index bd141933c67d..be2073db2cd1 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_unittest.cc @@ -473,6 +473,36 @@ TEST(ReflectionOpsTest, FindOneofInitializationErrors) { EXPECT_EQ("foo_message.required_double", FindInitializationErrors(message)); } +TEST(ReflectionOpsTest, GenericSwap) { + Arena arena; + { + unittest::TestAllTypes message; + auto* arena_message = Arena::CreateMessage(&arena); + TestUtil::SetAllFields(arena_message); + const uint64 initial_arena_size = arena.SpaceUsed(); + + GenericSwap(&message, arena_message); + + TestUtil::ExpectAllFieldsSet(message); + TestUtil::ExpectClear(*arena_message); + // The temp should be allocated on the arena in this case. + EXPECT_GT(arena.SpaceUsed(), initial_arena_size); + } + { + unittest::TestAllTypes message; + auto* arena_message = Arena::CreateMessage(&arena); + TestUtil::SetAllFields(arena_message); + const uint64 initial_arena_size = arena.SpaceUsed(); + + GenericSwap(arena_message, &message); + + TestUtil::ExpectAllFieldsSet(message); + TestUtil::ExpectClear(*arena_message); + // The temp shouldn't be allocated on the arena in this case. + EXPECT_EQ(arena.SpaceUsed(), initial_arena_size); + } +} + } // namespace } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index fc73917c509b..bc70be53abce 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc @@ -55,7 +55,7 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { return &rep_->elements[current_size_]; } Rep* old_rep = rep_; - Arena* arena = GetArenaNoVirtual(); + Arena* arena = GetArena(); new_size = std::max(kMinRepeatedFieldAllocationSize, std::max(total_size_ * 2, new_size)); GOOGLE_CHECK_LE(new_size, (std::numeric_limits::max() - kRepHeaderSize) / @@ -123,14 +123,22 @@ MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) { } // namespace internal -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField; -template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedPtrField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedField; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT) + RepeatedPtrField; } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index f0ee5e6a05d9..e74ffc70b5fe 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -106,6 +106,46 @@ inline int CalculateReserve(Iter begin, Iter end) { typedef typename std::iterator_traits::iterator_category Category; return CalculateReserve(begin, end, Category()); } + +// Swaps two blocks of memory of size sizeof(T). +template +inline void SwapBlock(char* p, char* q) { + T tmp; + memcpy(&tmp, p, sizeof(T)); + memcpy(p, q, sizeof(T)); + memcpy(q, &tmp, sizeof(T)); +} + +// Swaps two blocks of memory of size kSize: +// template void memswap(char* p, char* q); + +template +inline typename std::enable_if<(kSize == 0), void>::type memswap(char*, char*) { +} + +#define PROTO_MEMSWAP_DEF_SIZE(reg_type, max_size) \ + template \ + typename std::enable_if<(kSize >= sizeof(reg_type) && kSize < (max_size)), \ + void>::type \ + memswap(char* p, char* q) { \ + SwapBlock(p, q); \ + memswap(p + sizeof(reg_type), \ + q + sizeof(reg_type)); \ + } + +PROTO_MEMSWAP_DEF_SIZE(uint8, 2) +PROTO_MEMSWAP_DEF_SIZE(uint16, 4) +PROTO_MEMSWAP_DEF_SIZE(uint32, 8) + +#ifdef __SIZEOF_INT128__ +PROTO_MEMSWAP_DEF_SIZE(uint64, 16) +PROTO_MEMSWAP_DEF_SIZE(__uint128_t, (1u << 31)) +#else +PROTO_MEMSWAP_DEF_SIZE(uint64, (1u << 31)) +#endif + +#undef PROTO_MEMSWAP_DEF_SIZE + } // namespace internal // RepeatedField is used to represent repeated fields of a primitive type (in @@ -258,7 +298,10 @@ class RepeatedField final { iterator erase(const_iterator first, const_iterator last); // Get the Arena on which this RepeatedField stores its elements. - Arena* GetArena() const { return GetArenaNoVirtual(); } + inline Arena* GetArena() const { + return (total_size_ == 0) ? static_cast(arena_or_elements_) + : rep()->arena; + } // For internal use only. // @@ -327,12 +370,6 @@ class RepeatedField final { // Copy the elements of |from| into |to|. void CopyArray(Element* to, const Element* from, int size); - // Internal helper expected by Arena methods. - inline Arena* GetArenaNoVirtual() const { - return (total_size_ == 0) ? static_cast(arena_or_elements_) - : rep()->arena; - } - // Internal helper to delete all elements and deallocate the storage. // If Element has a trivial destructor (for example, if it's a fundamental // type, like int32), the loop will be removed by the optimizer. @@ -589,7 +626,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other); - inline Arena* GetArenaNoVirtual() const { return arena_; } + inline Arena* GetArena() const { return arena_; } private: static const int kInitialSize = 0; @@ -1016,7 +1053,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { iterator erase(const_iterator first, const_iterator last); // Gets the arena on which this RepeatedPtrField stores its elements. - Arena* GetArena() const { return GetArenaNoVirtual(); } + inline Arena* GetArena() const; // For internal use only. // @@ -1029,9 +1066,6 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // Note: RepeatedPtrField SHOULD NOT be subclassed by users. class TypeHandler; - // Internal arena accessor expected by helpers in Arena. - inline Arena* GetArenaNoVirtual() const; - // Implementations for ExtractSubrange(). The copying behavior must be // included only if the type supports the necessary operations (e.g., // MergeFrom()), so we must resolve this at compile time. ExtractSubrange() @@ -1097,7 +1131,7 @@ inline RepeatedField::RepeatedField(RepeatedField&& other) noexcept // We don't just call Swap(&other) here because it would perform 3 copies if // other is on an arena. This field can't be on an arena because arena // construction always uses the Arena* accepting constructor. - if (other.GetArenaNoVirtual()) { + if (other.GetArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -1110,7 +1144,7 @@ inline RepeatedField& RepeatedField::operator=( // We don't just call Swap(&other) here because it would perform 3 copies if // the two fields are on different arenas. if (this != &other) { - if (this->GetArenaNoVirtual() != other.GetArenaNoVirtual()) { + if (this->GetArena() != other.GetArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -1319,20 +1353,25 @@ inline const Element* RepeatedField::data() const { template inline void RepeatedField::InternalSwap(RepeatedField* other) { GOOGLE_DCHECK(this != other); - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); - std::swap(arena_or_elements_, other->arena_or_elements_); - std::swap(current_size_, other->current_size_); - std::swap(total_size_, other->total_size_); + // Swap all fields at once. + static_assert(std::is_standard_layout>::value, + "offsetof() requires standard layout before c++17"); + internal::memswaparena_or_elements_) - + offsetof(RepeatedField, current_size_)>( + reinterpret_cast(this) + offsetof(RepeatedField, current_size_), + reinterpret_cast(other) + offsetof(RepeatedField, current_size_)); } template void RepeatedField::Swap(RepeatedField* other) { if (this == other) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { - RepeatedField temp(other->GetArenaNoVirtual()); + RepeatedField temp(other->GetArena()); temp.MergeFrom(*this); CopyFrom(*other); other->UnsafeArenaSwap(&temp); @@ -1393,7 +1432,7 @@ void RepeatedField::Reserve(int new_size) { if (total_size_ >= new_size) return; Rep* old_rep = total_size_ > 0 ? rep() : NULL; Rep* new_rep; - Arena* arena = GetArenaNoVirtual(); + Arena* arena = GetArena(); new_size = std::max(internal::kMinRepeatedFieldAllocationSize, std::max(total_size_ * 2, new_size)); GOOGLE_DCHECK_LE( @@ -1503,7 +1542,7 @@ void RepeatedPtrFieldBase::Destroy() { template inline void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) { - if (other->GetArenaNoVirtual() == GetArenaNoVirtual()) { + if (other->GetArena() == GetArena()) { InternalSwap(other); } else { SwapFallback(other); @@ -1512,16 +1551,15 @@ inline void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) { template void RepeatedPtrFieldBase::SwapFallback(RepeatedPtrFieldBase* other) { - GOOGLE_DCHECK(other->GetArenaNoVirtual() != GetArenaNoVirtual()); + GOOGLE_DCHECK(other->GetArena() != GetArena()); // Copy semantics in this case. We try to improve efficiency by placing the - // temporary on |other|'s arena so that messages are copied cross-arena only - // once, not twice. - RepeatedPtrFieldBase temp(other->GetArenaNoVirtual()); + // temporary on |other|'s arena so that messages are copied twice rather than + // three times. + RepeatedPtrFieldBase temp(other->GetArena()); temp.MergeFrom(*this); this->Clear(); this->MergeFrom(*other); - other->Clear(); other->InternalSwap(&temp); temp.Destroy(); // Frees rep_ if `other` had no arena. } @@ -1664,7 +1702,7 @@ void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems, reinterpret_cast(our_elems[i]); TypeHandler::Merge(*other_elem, new_elem); } - Arena* arena = GetArenaNoVirtual(); + Arena* arena = GetArena(); for (int i = already_allocated; i < length; i++) { // Not allocated: alloc a new element first, then merge it. typename TypeHandler::Type* other_elem = @@ -1741,7 +1779,7 @@ void RepeatedPtrFieldBase::AddAllocatedInternal( typename TypeHandler::Type* value, std::true_type) { Arena* element_arena = reinterpret_cast(TypeHandler::GetMaybeArenaPointer(value)); - Arena* arena = GetArenaNoVirtual(); + Arena* arena = GetArena(); if (arena == element_arena && rep_ && rep_->allocated_size < total_size_) { // Fast path: underlying arena representation (tagged pointer) is equal to // our arena pointer, and we can add to array without resizing it (at least @@ -1840,7 +1878,7 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal( // First, release an element. typename TypeHandler::Type* result = UnsafeArenaReleaseLast(); // Now perform a copy if we're on an arena. - Arena* arena = GetArenaNoVirtual(); + Arena* arena = GetArena(); if (arena == NULL) { return result; } else { @@ -1858,7 +1896,7 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal( template inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal( std::false_type) { - GOOGLE_DCHECK(GetArenaNoVirtual() == NULL) + GOOGLE_DCHECK(GetArena() == NULL) << "ReleaseLast() called on a RepeatedPtrField that is on an arena, " << "with a type that does not implement MergeFrom. This is unsafe; " << "please implement MergeFrom for your type."; @@ -1887,7 +1925,7 @@ inline int RepeatedPtrFieldBase::ClearedCount() const { template inline void RepeatedPtrFieldBase::AddCleared( typename TypeHandler::Type* value) { - GOOGLE_DCHECK(GetArenaNoVirtual() == NULL) + GOOGLE_DCHECK(GetArena() == NULL) << "AddCleared() can only be used on a RepeatedPtrField not on an arena."; GOOGLE_DCHECK(TypeHandler::GetArena(value) == NULL) << "AddCleared() can only accept values not on an arena."; @@ -1899,10 +1937,10 @@ inline void RepeatedPtrFieldBase::AddCleared( template inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseCleared() { - GOOGLE_DCHECK(GetArenaNoVirtual() == NULL) + GOOGLE_DCHECK(GetArena() == NULL) << "ReleaseCleared() can only be used on a RepeatedPtrField not on " << "an arena."; - GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + GOOGLE_DCHECK(GetArena() == NULL); GOOGLE_DCHECK(rep_ != NULL); GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_); return cast(rep_->elements[--rep_->allocated_size]); @@ -1966,7 +2004,7 @@ inline RepeatedPtrField::RepeatedPtrField( // We don't just call Swap(&other) here because it would perform 3 copies if // other is on an arena. This field can't be on an arena because arena // construction always uses the Arena* accepting constructor. - if (other.GetArenaNoVirtual()) { + if (other.GetArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -1979,7 +2017,7 @@ inline RepeatedPtrField& RepeatedPtrField::operator=( // We don't just call Swap(&other) here because it would perform 3 copies if // the two fields are on different arenas. if (this != &other) { - if (this->GetArenaNoVirtual() != other.GetArenaNoVirtual()) { + if (this->GetArena() != other.GetArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -2065,7 +2103,7 @@ inline void RepeatedPtrField::ExtractSubrangeInternal( if (num > 0) { // Save the values of the removed elements if requested. if (elements != NULL) { - if (GetArenaNoVirtual() != NULL) { + if (GetArena() != NULL) { // If we're on an arena, we perform a copy for each element so that the // returned elements are heap-allocated. for (int i = 0; i < num; ++i) { @@ -2095,7 +2133,7 @@ inline void RepeatedPtrField::ExtractSubrangeInternal( // ExtractSubrange() must return heap-allocated objects by contract, and we // cannot fulfill this contract if we are an on arena, we must GOOGLE_DCHECK() that // we are not on an arena. - GOOGLE_DCHECK(GetArenaNoVirtual() == NULL) + GOOGLE_DCHECK(GetArena() == NULL) << "ExtractSubrange() when arena is non-NULL is only supported when " << "the Element type supplies a MergeFrom() operation to make copies."; UnsafeArenaExtractSubrange(start, num, elements); @@ -2179,8 +2217,8 @@ inline void RepeatedPtrField::SwapElements(int index1, int index2) { } template -inline Arena* RepeatedPtrField::GetArenaNoVirtual() const { - return RepeatedPtrFieldBase::GetArenaNoVirtual(); +inline Arena* RepeatedPtrField::GetArena() const { + return RepeatedPtrFieldBase::GetArena(); } template @@ -2418,11 +2456,17 @@ class RepeatedPtrOverPtrsIterator { void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) { GOOGLE_DCHECK(this != other); - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); - std::swap(rep_, other->rep_); - std::swap(current_size_, other->current_size_); - std::swap(total_size_, other->total_size_); + // Swap all fields at once. + static_assert(std::is_standard_layout::value, + "offsetof() requires standard layout before c++17"); + internal::memswaprep_) - + offsetof(RepeatedPtrFieldBase, current_size_)>( + reinterpret_cast(this) + + offsetof(RepeatedPtrFieldBase, current_size_), + reinterpret_cast(other) + + offsetof(RepeatedPtrFieldBase, current_size_)); } } // namespace internal @@ -2653,14 +2697,21 @@ UnsafeArenaAllocatedRepeatedPtrFieldBackInserter( } // Extern declarations of common instantiations to reduce library bloat. -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField; -extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) + RepeatedField; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT) RepeatedPtrField; } // namespace protobuf diff --git a/src/google/protobuf/repeated_field_reflection_unittest.cc b/src/google/protobuf/repeated_field_reflection_unittest.cc index a04effa46caa..384d32f530df 100644 --- a/src/google/protobuf/repeated_field_reflection_unittest.cc +++ b/src/google/protobuf/repeated_field_reflection_unittest.cc @@ -52,11 +52,7 @@ namespace { static int Func(int i, int j) { return i * j; } -static std::string StrFunc(int i, int j) { - std::string str; - SStringPrintf(&str, "%d", Func(i, 4)); - return str; -} +static std::string StrFunc(int i, int j) { return StrCat(Func(i, 4)); } TEST(RepeatedFieldReflectionTest, RegularFields) { TestAllTypes message; diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index c8265f5e1822..9f09bec1375b 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -69,9 +69,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = { - &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", 251, + false, false, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", 251, &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_sccs, descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, @@ -89,18 +88,19 @@ class SourceContext::_Internal { public: }; -SourceContext::SourceContext() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { +SourceContext::SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.SourceContext) + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceContext) } SourceContext::SourceContext(const SourceContext& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_file_name().empty()) { - file_name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.file_name_); + file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_file_name(), + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } @@ -113,12 +113,20 @@ void SourceContext::SharedCtor() { SourceContext::~SourceContext() { // @@protoc_insertion_point(destructor:google.protobuf.SourceContext) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void SourceContext::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } +void SourceContext::ArenaDtor(void* object) { + SourceContext* _this = reinterpret_cast< SourceContext* >(object); + (void)_this; +} +void SourceContext::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} void SourceContext::SetCachedSize(int size) const { _cached_size_.Set(size); } @@ -134,12 +142,13 @@ void SourceContext::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - file_name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - _internal_metadata_.Clear(); + file_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SourceContext::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -160,7 +169,9 @@ const char* SourceContext::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -192,7 +203,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* SourceContext::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceContext) return target; @@ -240,13 +251,12 @@ void SourceContext::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void SourceContext::MergeFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.file_name().size() > 0) { - - file_name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.file_name_); + _internal_set_file_name(from._internal_file_name()); } } @@ -270,9 +280,8 @@ bool SourceContext::IsInitialized() const { void SourceContext::InternalSwap(SourceContext* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - file_name_.Swap(&other->file_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + file_name_.Swap(&other->file_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const { @@ -284,7 +293,7 @@ ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const { PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::SourceContext* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::SourceContext >(Arena* arena) { - return Arena::CreateInternal< PROTOBUF_NAMESPACE_ID::SourceContext >(arena); + return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::SourceContext >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 2861a69db17c..85062c910c48 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -66,10 +66,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT SourceContext : +class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ { public: - SourceContext(); + inline SourceContext() : SourceContext(nullptr) {}; virtual ~SourceContext(); SourceContext(const SourceContext& from); @@ -83,7 +83,7 @@ class PROTOBUF_EXPORT SourceContext : return *this; } inline SourceContext& operator=(SourceContext&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -115,6 +115,15 @@ class PROTOBUF_EXPORT SourceContext : } inline void Swap(SourceContext* other) { if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceContext* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -149,13 +158,11 @@ class PROTOBUF_EXPORT SourceContext : static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.SourceContext"; } + protected: + explicit SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena); private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return nullptr; - } - inline void* MaybeArenaPtr() const { - return nullptr; - } + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -184,6 +191,15 @@ class PROTOBUF_EXPORT SourceContext : std::string* mutable_file_name(); std::string* release_file_name(); void set_allocated_file_name(std::string* file_name); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_file_name(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_file_name( + std::string* file_name); private: const std::string& _internal_file_name() const; void _internal_set_file_name(const std::string& value); @@ -194,7 +210,9 @@ class PROTOBUF_EXPORT SourceContext : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr file_name_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; friend struct ::TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto; @@ -212,7 +230,7 @@ class PROTOBUF_EXPORT SourceContext : // string file_name = 1; inline void SourceContext::clear_file_name() { - file_name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + file_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) @@ -227,38 +245,40 @@ inline std::string* SourceContext::mutable_file_name() { return _internal_mutable_file_name(); } inline const std::string& SourceContext::_internal_file_name() const { - return file_name_.GetNoArena(); + return file_name_.Get(); } inline void SourceContext::_internal_set_file_name(const std::string& value) { - file_name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); + file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void SourceContext::set_file_name(std::string&& value) { - file_name_.SetNoArena( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + file_name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name) } inline void SourceContext::set_file_name(const char* value) { GOOGLE_DCHECK(value != nullptr); - file_name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name) } -inline void SourceContext::set_file_name(const char* value, size_t size) { +inline void SourceContext::set_file_name(const char* value, + size_t size) { - file_name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name) } inline std::string* SourceContext::_internal_mutable_file_name() { - return file_name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return file_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* SourceContext::release_file_name() { // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name) - return file_name_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + return file_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void SourceContext::set_allocated_file_name(std::string* file_name) { if (file_name != nullptr) { @@ -266,9 +286,29 @@ inline void SourceContext::set_allocated_file_name(std::string* file_name) { } else { } - file_name_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name); + file_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name, + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } +inline std::string* SourceContext::unsafe_arena_release_file_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.SourceContext.file_name) + GOOGLE_DCHECK(GetArena() != nullptr); + + return file_name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void SourceContext::unsafe_arena_set_allocated_file_name( + std::string* file_name) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (file_name != nullptr) { + + } else { + + } + file_name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + file_name, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.SourceContext.file_name) +} #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 2ef6c2dc736c..027fef6f5546 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -148,9 +148,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fstruct_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = { - &descriptor_table_google_2fprotobuf_2fstruct_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", 641, + false, false, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", 641, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, descriptor_table_google_2fprotobuf_2fstruct_2eproto_sccs, descriptor_table_google_2fprotobuf_2fstruct_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fstruct_2eproto, 4, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto, @@ -198,23 +197,16 @@ class Struct::_Internal { public: }; -Struct::Struct() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Struct) -} Struct::Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), fields_(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) } Struct::Struct(const Struct& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); fields_.MergeFrom(from.fields_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct) } @@ -226,10 +218,11 @@ void Struct::SharedCtor() { Struct::~Struct() { // @@protoc_insertion_point(destructor:google.protobuf.Struct) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Struct::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void Struct::ArenaDtor(void* object) { @@ -254,12 +247,12 @@ void Struct::Clear() { (void) cached_has_bits; fields_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Struct::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -283,7 +276,9 @@ const char* Struct::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -346,7 +341,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Struct::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Struct) return target; @@ -396,7 +391,7 @@ void Struct::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Struct::MergeFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -423,7 +418,7 @@ bool Struct::IsInitialized() const { void Struct::InternalSwap(Struct* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); fields_.Swap(&other->fields_); } @@ -460,7 +455,7 @@ Value::_Internal::list_value(const Value* msg) { return *msg->kind_.list_value_; } void Value::set_allocated_struct_value(PROTOBUF_NAMESPACE_ID::Struct* struct_value) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); clear_kind(); if (struct_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = @@ -475,7 +470,7 @@ void Value::set_allocated_struct_value(PROTOBUF_NAMESPACE_ID::Struct* struct_val // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) } void Value::set_allocated_list_value(PROTOBUF_NAMESPACE_ID::ListValue* list_value) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); clear_kind(); if (list_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = @@ -489,22 +484,15 @@ void Value::set_allocated_list_value(PROTOBUF_NAMESPACE_ID::ListValue* list_valu } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) } -Value::Value() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Value) -} Value::Value(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) } Value::Value(const Value& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); clear_has_kind(); switch (from.kind_case()) { case kNullValue: { @@ -546,10 +534,11 @@ void Value::SharedCtor() { Value::~Value() { // @@protoc_insertion_point(destructor:google.protobuf.Value) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Value::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); if (has_kind()) { clear_kind(); } @@ -582,8 +571,7 @@ void Value::clear_kind() { break; } case kStringValue: { - kind_.string_value_.Destroy(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + kind_.string_value_.Destroy(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); break; } case kBoolValue: { @@ -591,13 +579,13 @@ void Value::clear_kind() { break; } case kStructValue: { - if (GetArenaNoVirtual() == nullptr) { + if (GetArena() == nullptr) { delete kind_.struct_value_; } break; } case kListValue: { - if (GetArenaNoVirtual() == nullptr) { + if (GetArena() == nullptr) { delete kind_.list_value_; } break; @@ -617,12 +605,12 @@ void Value::Clear() { (void) cached_has_bits; clear_kind(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -679,7 +667,9 @@ const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -746,7 +736,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Value::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Value) return target; @@ -829,7 +819,7 @@ void Value::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Value::MergeFrom(const Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -884,7 +874,7 @@ bool Value::IsInitialized() const { void Value::InternalSwap(Value* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(kind_, other->kind_); swap(_oneof_case_[0], other->_oneof_case_[0]); } @@ -902,14 +892,8 @@ class ListValue::_Internal { public: }; -ListValue::ListValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.ListValue) -} ListValue::ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), values_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -917,9 +901,8 @@ ListValue::ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) } ListValue::ListValue(const ListValue& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), values_(from.values_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue) } @@ -930,10 +913,11 @@ void ListValue::SharedCtor() { ListValue::~ListValue() { // @@protoc_insertion_point(destructor:google.protobuf.ListValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void ListValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void ListValue::ArenaDtor(void* object) { @@ -958,12 +942,12 @@ void ListValue::Clear() { (void) cached_has_bits; values_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* ListValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -987,7 +971,9 @@ const char* ListValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1017,7 +1003,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* ListValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ListValue) return target; @@ -1065,7 +1051,7 @@ void ListValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void ListValue::MergeFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1092,7 +1078,7 @@ bool ListValue::IsInitialized() const { void ListValue::InternalSwap(ListValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); values_.InternalSwap(&other->values_); } diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 46363e4b75c0..993de2c67fb3 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -138,10 +138,10 @@ class Struct_FieldsEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::Ma // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Struct : +class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ { public: - Struct(); + inline Struct() : Struct(nullptr) {}; virtual ~Struct(); Struct(const Struct& from); @@ -155,7 +155,7 @@ class PROTOBUF_EXPORT Struct : return *this; } inline Struct& operator=(Struct&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -163,12 +163,6 @@ class PROTOBUF_EXPORT Struct : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -193,7 +187,7 @@ class PROTOBUF_EXPORT Struct : } inline void Swap(Struct* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -201,7 +195,7 @@ class PROTOBUF_EXPORT Struct : } void UnsafeArenaSwap(Struct* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -241,13 +235,6 @@ class PROTOBUF_EXPORT Struct : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -288,7 +275,6 @@ class PROTOBUF_EXPORT Struct : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -303,10 +289,10 @@ class PROTOBUF_EXPORT Struct : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Value : +class PROTOBUF_EXPORT Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ { public: - Value(); + inline Value() : Value(nullptr) {}; virtual ~Value(); Value(const Value& from); @@ -320,7 +306,7 @@ class PROTOBUF_EXPORT Value : return *this; } inline Value& operator=(Value&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -328,12 +314,6 @@ class PROTOBUF_EXPORT Value : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -368,7 +348,7 @@ class PROTOBUF_EXPORT Value : } inline void Swap(Value* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -376,7 +356,7 @@ class PROTOBUF_EXPORT Value : } void UnsafeArenaSwap(Value* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -416,13 +396,6 @@ class PROTOBUF_EXPORT Value : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -561,7 +534,6 @@ class PROTOBUF_EXPORT Value : inline bool has_kind() const; inline void clear_has_kind(); - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -581,10 +553,10 @@ class PROTOBUF_EXPORT Value : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ListValue : +class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ { public: - ListValue(); + inline ListValue() : ListValue(nullptr) {}; virtual ~ListValue(); ListValue(const ListValue& from); @@ -598,7 +570,7 @@ class PROTOBUF_EXPORT ListValue : return *this; } inline ListValue& operator=(ListValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -606,12 +578,6 @@ class PROTOBUF_EXPORT ListValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -636,7 +602,7 @@ class PROTOBUF_EXPORT ListValue : } inline void Swap(ListValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -644,7 +610,7 @@ class PROTOBUF_EXPORT ListValue : } void UnsafeArenaSwap(ListValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -684,13 +650,6 @@ class PROTOBUF_EXPORT ListValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -731,7 +690,6 @@ class PROTOBUF_EXPORT ListValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -864,8 +822,7 @@ inline void Value::set_has_string_value() { } inline void Value::clear_string_value() { if (_internal_has_string_value()) { - kind_.string_value_.Destroy(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + kind_.string_value_.Destroy(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); clear_has_kind(); } } @@ -893,8 +850,7 @@ inline void Value::_internal_set_string_value(const std::string& value) { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArenaNoVirtual()); + kind_.string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Value::set_string_value(std::string&& value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) @@ -904,7 +860,7 @@ inline void Value::set_string_value(std::string&& value) { kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } kind_.string_value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Value.string_value) } inline void Value::set_string_value(const char* value) { @@ -915,7 +871,7 @@ inline void Value::set_string_value(const char* value) { kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } kind_.string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ::std::string(value), GetArenaNoVirtual()); + ::std::string(value), GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value) } inline void Value::set_string_value(const char* value, @@ -928,7 +884,7 @@ inline void Value::set_string_value(const char* value, kind_.string_value_.Set( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast(value), size), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) } inline std::string* Value::_internal_mutable_string_value() { @@ -937,15 +893,13 @@ inline std::string* Value::_internal_mutable_string_value() { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } - return kind_.string_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + return kind_.string_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) if (_internal_has_string_value()) { clear_has_kind(); - return kind_.string_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + return kind_.string_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } else { return nullptr; } @@ -962,24 +916,24 @@ inline void Value::set_allocated_string_value(std::string* string_value) { } inline std::string* Value::unsafe_arena_release_string_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (_internal_has_string_value()) { clear_has_kind(); return kind_.string_value_.UnsafeArenaRelease( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } else { return nullptr; } } inline void Value::unsafe_arena_set_allocated_string_value(std::string* string_value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (!_internal_has_string_value()) { kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } clear_kind(); if (string_value) { set_has_string_value(); - kind_.string_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value, GetArenaNoVirtual()); + kind_.string_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value, GetArena()); } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) } @@ -1031,7 +985,7 @@ inline void Value::set_has_struct_value() { } inline void Value::clear_struct_value() { if (_internal_has_struct_value()) { - if (GetArenaNoVirtual() == nullptr) { + if (GetArena() == nullptr) { delete kind_.struct_value_; } clear_has_kind(); @@ -1042,7 +996,7 @@ inline PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() { if (_internal_has_struct_value()) { clear_has_kind(); PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_; - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } kind_.struct_value_ = nullptr; @@ -1083,8 +1037,7 @@ inline PROTOBUF_NAMESPACE_ID::Struct* Value::_internal_mutable_struct_value() { if (!_internal_has_struct_value()) { clear_kind(); set_has_struct_value(); - kind_.struct_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Struct >( - GetArenaNoVirtual()); + kind_.struct_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Struct >(GetArena()); } return kind_.struct_value_; } @@ -1105,7 +1058,7 @@ inline void Value::set_has_list_value() { } inline void Value::clear_list_value() { if (_internal_has_list_value()) { - if (GetArenaNoVirtual() == nullptr) { + if (GetArena() == nullptr) { delete kind_.list_value_; } clear_has_kind(); @@ -1116,7 +1069,7 @@ inline PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() { if (_internal_has_list_value()) { clear_has_kind(); PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_; - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } kind_.list_value_ = nullptr; @@ -1157,8 +1110,7 @@ inline PROTOBUF_NAMESPACE_ID::ListValue* Value::_internal_mutable_list_value() { if (!_internal_has_list_value()) { clear_kind(); set_has_list_value(); - kind_.list_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::ListValue >( - GetArenaNoVirtual()); + kind_.list_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::ListValue >(GetArena()); } return kind_.list_value_; } diff --git a/src/google/protobuf/stubs/casts.h b/src/google/protobuf/stubs/casts.h index 780857baadda..83750bd7868e 100644 --- a/src/google/protobuf/stubs/casts.h +++ b/src/google/protobuf/stubs/casts.h @@ -31,11 +31,10 @@ #ifndef GOOGLE_PROTOBUF_CASTS_H__ #define GOOGLE_PROTOBUF_CASTS_H__ -#include - #include #include +#include namespace google { namespace protobuf { diff --git a/src/google/protobuf/stubs/structurally_valid.cc b/src/google/protobuf/stubs/structurally_valid.cc index 03f3bc07f268..4d424a15ae68 100644 --- a/src/google/protobuf/stubs/structurally_valid.cc +++ b/src/google/protobuf/stubs/structurally_valid.cc @@ -456,7 +456,6 @@ int UTF8GenericScan(const UTF8ScanObj* st, } //---------------------------- - // Exit possibilities: // Some exit code, !state0, back up over last char // Some exit code, state0, back up one byte exactly diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 4a1246bfa433..24ae286dc3ef 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -2284,16 +2284,19 @@ int EncodeAsUTF8Char(uint32 code_point, char* output) { // Table of UTF-8 character lengths, based on first byte static const unsigned char kUTF8LenTbl[256] = { - 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, - - 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3, 4,4,4,4,4,1,1,1, 1,1,1,1,1,1,1,1 -}; + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // Return length of a single UTF-8 source character int UTF8FirstLetterNumBytes(const char* src, int len) { diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index f319bfc71f39..79a7aeb5006b 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -33,13 +33,13 @@ #ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ #define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ -#include -#include -#include #include #include +#include +#include #include +#include namespace google { namespace protobuf { @@ -118,11 +118,10 @@ inline bool HasPrefixString(const string& str, return str.size() >= prefix.size() && str.compare(0, prefix.size(), prefix) == 0; } - -inline bool HasPrefixString(StringPiece str, - StringPiece prefix) { + +inline bool HasPrefixString(StringPiece str, StringPiece prefix) { return str.size() >= prefix.size() && - memcmp(str.data(), prefix.data(), prefix.size()) == 0; + memcmp(str.data(), prefix.data(), prefix.size()) == 0; } inline string StripPrefixString(const string& str, const string& prefix) { diff --git a/src/google/protobuf/test_messages_proto2.proto b/src/google/protobuf/test_messages_proto2.proto index 1d0c33f566eb..f8207431e3f5 100644 --- a/src/google/protobuf/test_messages_proto2.proto +++ b/src/google/protobuf/test_messages_proto2.proto @@ -1,3 +1,33 @@ +// 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. + // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ diff --git a/src/google/protobuf/test_messages_proto3.proto b/src/google/protobuf/test_messages_proto3.proto index a10f44d946e1..803e2c31ea76 100644 --- a/src/google/protobuf/test_messages_proto3.proto +++ b/src/google/protobuf/test_messages_proto3.proto @@ -1,3 +1,33 @@ +// 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. + // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 6b3308892764..8f4771dee79c 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -101,7 +101,7 @@ std::string Message::ShortDebugString() const { printer.PrintToString(*this, &debug_string); // Single line mode currently might have an extra space at the end. - if (debug_string.size() > 0 && debug_string[debug_string.size() - 1] == ' ') { + if (!debug_string.empty() && debug_string[debug_string.size() - 1] == ' ') { debug_string.resize(debug_string.size() - 1); } @@ -1670,6 +1670,11 @@ void TextFormat::FastFieldValuePrinter::PrintMessageStart( generator->PrintLiteral(" {\n"); } } +bool TextFormat::FastFieldValuePrinter::PrintMessageContent( + const Message& message, int field_index, int field_count, + bool single_line_mode, BaseTextGenerator* generator) const { + return false; // Use the default printing function. +} void TextFormat::FastFieldValuePrinter::PrintMessageEnd( const Message& message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator* generator) const { @@ -1886,12 +1891,16 @@ bool TextFormat::Printer::Print(const Message& message, return !generator.failed(); } +// Maximum recursion depth for heuristically printing out length-delimited +// unknown fields as messages. +static constexpr int kUnknownFieldRecursionLimit = 10; + bool TextFormat::Printer::PrintUnknownFields( const UnknownFieldSet& unknown_fields, io::ZeroCopyOutputStream* output) const { TextGenerator generator(output, initial_indent_level_); - PrintUnknownFields(unknown_fields, &generator); + PrintUnknownFields(unknown_fields, &generator, kUnknownFieldRecursionLimit); // Output false if the generator failed internally. return !generator.failed(); @@ -1941,7 +1950,8 @@ bool TextFormat::Printer::PrintAny(const Message& message, finder_ ? finder_->FindAnyType(message, url_prefix, full_type_name) : DefaultFinderFindAnyType(message, url_prefix, full_type_name); if (value_descriptor == nullptr) { - GOOGLE_LOG(WARNING) << "Proto type " << type_url << " not found"; + GOOGLE_LOG(WARNING) << "Can't print proto content: proto type " << type_url + << " not found"; return false; } DynamicMessageFactory factory; @@ -1976,7 +1986,7 @@ void TextFormat::Printer::Print(const Message& message, io::ArrayInputStream input(serialized.data(), serialized.size()); unknown_fields.ParseFromZeroCopyStream(&input); } - PrintUnknownFields(unknown_fields, generator); + PrintUnknownFields(unknown_fields, generator, kUnknownFieldRecursionLimit); return; } const Descriptor* descriptor = message.GetDescriptor(); @@ -2004,7 +2014,8 @@ void TextFormat::Printer::Print(const Message& message, PrintField(message, reflection, fields[i], generator); } if (!hide_unknown_fields_) { - PrintUnknownFields(reflection->GetUnknownFields(message), generator); + PrintUnknownFields(reflection->GetUnknownFields(message), generator, + kUnknownFieldRecursionLimit); } } @@ -2239,7 +2250,10 @@ void TextFormat::Printer::PrintField(const Message& message, printer->PrintMessageStart(sub_message, field_index, count, single_line_mode_, generator); generator->Indent(); - Print(sub_message, generator); + if (!printer->PrintMessageContent(sub_message, field_index, count, + single_line_mode_, generator)) { + Print(sub_message, generator); + } generator->Outdent(); printer->PrintMessageEnd(sub_message, field_index, count, single_line_mode_, generator); @@ -2413,7 +2427,8 @@ void TextFormat::Printer::PrintFieldValue(const Message& message, } void TextFormat::Printer::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, TextGenerator* generator) const { + const UnknownFieldSet& unknown_fields, TextGenerator* generator, + int recursion_budget) const { for (int i = 0; i < unknown_fields.field_count(); i++) { const UnknownField& field = unknown_fields.field(i); std::string field_number = StrCat(field.number()); @@ -2456,8 +2471,15 @@ void TextFormat::Printer::PrintUnknownFields( case UnknownField::TYPE_LENGTH_DELIMITED: { generator->PrintString(field_number); const std::string& value = field.length_delimited(); + // We create a CodedInputStream so that we can adhere to our recursion + // budget when we attempt to parse the data. UnknownFieldSet parsing is + // recursive because of groups. + io::CodedInputStream input_stream( + reinterpret_cast(value.data()), value.size()); + input_stream.SetRecursionLimit(recursion_budget); UnknownFieldSet embedded_unknown_fields; - if (!value.empty() && embedded_unknown_fields.ParseFromString(value)) { + if (!value.empty() && recursion_budget > 0 && + embedded_unknown_fields.ParseFromCodedStream(&input_stream)) { // This field is parseable as a Message. // So it is probably an embedded message. if (single_line_mode_) { @@ -2466,7 +2488,8 @@ void TextFormat::Printer::PrintUnknownFields( generator->PrintLiteral(" {\n"); generator->Indent(); } - PrintUnknownFields(embedded_unknown_fields, generator); + PrintUnknownFields(embedded_unknown_fields, generator, + recursion_budget - 1); if (single_line_mode_) { generator->PrintLiteral("} "); } else { @@ -2474,8 +2497,8 @@ void TextFormat::Printer::PrintUnknownFields( generator->PrintLiteral("}\n"); } } else { - // This field is not parseable as a Message. - // So it is probably just a plain string. + // This field is not parseable as a Message (or we ran out of + // recursion budget). So it is probably just a plain string. generator->PrintLiteral(": \""); generator->PrintString(CEscape(value)); if (single_line_mode_) { @@ -2494,7 +2517,10 @@ void TextFormat::Printer::PrintUnknownFields( generator->PrintLiteral(" {\n"); generator->Indent(); } - PrintUnknownFields(field.group(), generator); + // For groups, we recurse without checking the budget. This is OK, + // because if the groups were too deeply nested then we would have + // already rejected the message when we originally parsed it. + PrintUnknownFields(field.group(), generator, recursion_budget - 1); if (single_line_mode_) { generator->PrintLiteral("} "); } else { diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index ab34cd82bffd..26c4afbf7796 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -149,6 +149,14 @@ class PROTOBUF_EXPORT TextFormat { virtual void PrintMessageStart(const Message& message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator* generator) const; + // Allows to override the logic on how to print the content of a message. + // Return false to use the default printing logic. Note that it is legal for + // this function to print something and then return false to use the default + // content printing (although at that point it would behave similarly to + // PrintMessageStart). + virtual bool PrintMessageContent(const Message& message, int field_index, + int field_count, bool single_line_mode, + BaseTextGenerator* generator) const; virtual void PrintMessageEnd(const Message& message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator* generator) const; @@ -391,9 +399,10 @@ class PROTOBUF_EXPORT TextFormat { // Print the fields in an UnknownFieldSet. They are printed by tag number // only. Embedded messages are heuristically identified by attempting to - // parse them. + // parse them (subject to the recursion budget). void PrintUnknownFields(const UnknownFieldSet& unknown_fields, - TextGenerator* generator) const; + TextGenerator* generator, + int recursion_budget) const; bool PrintAny(const Message& message, TextGenerator* generator) const; diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 555976f18716..72a2e6ddff08 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -356,6 +356,39 @@ TEST_F(TextFormatTest, PrintUnknownMessage) { text); } +TEST_F(TextFormatTest, PrintDeeplyNestedUnknownMessage) { + // Create a deeply nested message. + static constexpr int kNestingDepth = 25000; + static constexpr int kUnknownFieldNumber = 1; + std::vector lengths; + lengths.reserve(kNestingDepth); + lengths.push_back(0); + for (int i = 0; i < kNestingDepth - 1; ++i) { + lengths.push_back( + internal::WireFormatLite::TagSize( + kUnknownFieldNumber, internal::WireFormatLite::TYPE_BYTES) + + internal::WireFormatLite::LengthDelimitedSize(lengths.back())); + } + std::string serialized; + { + io::StringOutputStream zero_copy_stream(&serialized); + io::CodedOutputStream coded_stream(&zero_copy_stream); + for (int i = kNestingDepth - 1; i >= 0; --i) { + internal::WireFormatLite::WriteTag( + kUnknownFieldNumber, + internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, &coded_stream); + coded_stream.WriteVarint32(lengths[i]); + } + } + + // Parse the data and verify that we can print it without overflowing the + // stack. + unittest::TestEmptyMessage message; + ASSERT_TRUE(message.ParseFromString(serialized)); + std::string text; + EXPECT_TRUE(TextFormat::PrintToString(message, &text)); +} + TEST_F(TextFormatTest, PrintMessageWithIndent) { // Test adding an initial indent to printing. @@ -539,6 +572,54 @@ TEST_F(TextFormatTest, CustomPrinterForComments) { text); } +class CustomMessageContentFieldValuePrinter + : public TextFormat::FastFieldValuePrinter { + public: + bool PrintMessageContent( + const Message& message, int field_index, int field_count, + bool single_line_mode, + TextFormat::BaseTextGenerator* generator) const override { + if (message.ByteSizeLong() > 0) { + generator->PrintString( + strings::Substitute("# REDACTED, $0 bytes\n", message.ByteSizeLong())); + } + return true; + } +}; + +TEST_F(TextFormatTest, CustomPrinterForMessageContent) { + protobuf_unittest::TestAllTypes message; + message.mutable_optional_nested_message(); + message.mutable_optional_import_message()->set_d(42); + message.add_repeated_nested_message(); + message.add_repeated_nested_message(); + message.add_repeated_import_message()->set_d(43); + message.add_repeated_import_message()->set_d(44); + TextFormat::Printer printer; + CustomMessageContentFieldValuePrinter my_field_printer; + printer.SetDefaultFieldValuePrinter( + new CustomMessageContentFieldValuePrinter()); + std::string text; + printer.PrintToString(message, &text); + EXPECT_EQ( + "optional_nested_message {\n" + "}\n" + "optional_import_message {\n" + " # REDACTED, 2 bytes\n" + "}\n" + "repeated_nested_message {\n" + "}\n" + "repeated_nested_message {\n" + "}\n" + "repeated_import_message {\n" + " # REDACTED, 2 bytes\n" + "}\n" + "repeated_import_message {\n" + " # REDACTED, 2 bytes\n" + "}\n", + text); +} + class CustomMultilineCommentPrinter : public TextFormat::FieldValuePrinter { public: virtual std::string PrintMessageStart(const Message& message, int field_index, @@ -726,8 +807,8 @@ TEST_F(TextFormatExtensionsTest, ParseExtensions) { TEST_F(TextFormatTest, ParseEnumFieldFromNumber) { // Create a parse string with a numerical value for an enum field. - std::string parse_string = strings::Substitute("optional_nested_enum: $0", - unittest::TestAllTypes::BAZ); + std::string parse_string = + strings::Substitute("optional_nested_enum: $0", unittest::TestAllTypes::BAZ); EXPECT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); EXPECT_TRUE(proto_.has_optional_nested_enum()); EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.optional_nested_enum()); @@ -1365,7 +1446,7 @@ class TextFormatParserTest : public testing::Test { // implements ErrorCollector ------------------------------------- void AddError(int line, int column, const std::string& message) { strings::SubstituteAndAppend(&text_, "$0:$1: $2\n", line + 1, column + 1, - message); + message); } void AddWarning(int line, int column, const std::string& message) { diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 43de52e8b857..8b2721022d7c 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -69,9 +69,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = { - &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", 231, + false, false, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", 231, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_sccs, descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto, @@ -89,22 +88,15 @@ class Timestamp::_Internal { public: }; -Timestamp::Timestamp() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) -} Timestamp::Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } Timestamp::Timestamp(const Timestamp& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&seconds_, &from.seconds_, static_cast(reinterpret_cast(&nanos_) - reinterpret_cast(&seconds_)) + sizeof(nanos_)); @@ -120,10 +112,11 @@ void Timestamp::SharedCtor() { Timestamp::~Timestamp() { // @@protoc_insertion_point(destructor:google.protobuf.Timestamp) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Timestamp::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void Timestamp::ArenaDtor(void* object) { @@ -150,12 +143,12 @@ void Timestamp::Clear() { ::memset(&seconds_, 0, static_cast( reinterpret_cast(&nanos_) - reinterpret_cast(&seconds_)) + sizeof(nanos_)); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Timestamp::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -181,7 +174,9 @@ const char* Timestamp::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -215,7 +210,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Timestamp::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Timestamp) return target; @@ -270,7 +265,7 @@ void Timestamp::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Timestamp::MergeFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -302,9 +297,13 @@ bool Timestamp::IsInitialized() const { void Timestamp::InternalSwap(Timestamp* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - swap(seconds_, other->seconds_); - swap(nanos_, other->nanos_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Timestamp, nanos_) + + sizeof(Timestamp::nanos_) + - PROTOBUF_FIELD_OFFSET(Timestamp, seconds_)>( + reinterpret_cast(&seconds_), + reinterpret_cast(&other->seconds_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Timestamp::GetMetadata() const { diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index f0a4330c58a3..84c74406d796 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -66,10 +66,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Timestamp : +class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ { public: - Timestamp(); + inline Timestamp() : Timestamp(nullptr) {}; virtual ~Timestamp(); Timestamp(const Timestamp& from); @@ -83,7 +83,7 @@ class PROTOBUF_EXPORT Timestamp : return *this; } inline Timestamp& operator=(Timestamp&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -91,12 +91,6 @@ class PROTOBUF_EXPORT Timestamp : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -121,7 +115,7 @@ class PROTOBUF_EXPORT Timestamp : } inline void Swap(Timestamp* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -129,7 +123,7 @@ class PROTOBUF_EXPORT Timestamp : } void UnsafeArenaSwap(Timestamp* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -169,13 +163,6 @@ class PROTOBUF_EXPORT Timestamp : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -217,7 +204,6 @@ class PROTOBUF_EXPORT Timestamp : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index a690acb9b6c8..8da70ecc5258 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -247,9 +247,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_Type_google_2fprotobuf_2ftype_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2ftype_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto = { - &descriptor_table_google_2fprotobuf_2ftype_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, "google/protobuf/type.proto", 1594, + false, false, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, "google/protobuf/type.proto", 1594, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, descriptor_table_google_2fprotobuf_2ftype_2eproto_sccs, descriptor_table_google_2fprotobuf_2ftype_2eproto_deps, 5, 2, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ftype_2eproto, 5, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto, @@ -368,33 +367,14 @@ const PROTOBUF_NAMESPACE_ID::SourceContext& Type::_Internal::source_context(const Type* msg) { return *msg->source_context_; } -void Type::unsafe_arena_set_allocated_source_context( - PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - if (GetArenaNoVirtual() == nullptr) { - delete source_context_; - } - source_context_ = source_context; - if (source_context) { - - } else { - - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context) -} void Type::clear_source_context() { - if (GetArenaNoVirtual() == nullptr && source_context_ != nullptr) { + if (GetArena() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; } -Type::Type() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Type) -} Type::Type(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), fields_(arena), oneofs_(arena), options_(arena) { @@ -404,15 +384,14 @@ Type::Type(::PROTOBUF_NAMESPACE_ID::Arena* arena) } Type::Type(const Type& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), fields_(from.fields_), oneofs_(from.oneofs_), options_(from.options_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_source_context()) { source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); @@ -434,10 +413,11 @@ void Type::SharedCtor() { Type::~Type() { // @@protoc_insertion_point(destructor:google.protobuf.Type) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Type::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete source_context_; } @@ -466,18 +446,18 @@ void Type::Clear() { fields_.Clear(); oneofs_.Clear(); options_.Clear(); - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == nullptr && source_context_ != nullptr) { + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + if (GetArena() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; syntax_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -551,7 +531,9 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -624,7 +606,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Type::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Type) return target; @@ -707,7 +689,7 @@ void Type::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Type::MergeFrom(const Type& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -745,14 +727,17 @@ bool Type::IsInitialized() const { void Type::InternalSwap(Type* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); fields_.InternalSwap(&other->fields_); oneofs_.InternalSwap(&other->oneofs_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(source_context_, other->source_context_); - swap(syntax_, other->syntax_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Type, syntax_) + + sizeof(Type::syntax_) + - PROTOBUF_FIELD_OFFSET(Type, source_context_)>( + reinterpret_cast(&source_context_), + reinterpret_cast(&other->source_context_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Type::GetMetadata() const { @@ -768,14 +753,8 @@ class Field::_Internal { public: }; -Field::Field() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Field) -} Field::Field(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), options_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -783,28 +762,27 @@ Field::Field(::PROTOBUF_NAMESPACE_ID::Arena* arena) } Field::Field(const Field& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), options_(from.options_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_type_url().empty()) { type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type_url(), - GetArenaNoVirtual()); + GetArena()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_json_name().empty()) { json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_json_name(), - GetArenaNoVirtual()); + GetArena()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_default_value().empty()) { default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_default_value(), - GetArenaNoVirtual()); + GetArena()); } ::memcpy(&kind_, &from.kind_, static_cast(reinterpret_cast(&packed_) - @@ -826,10 +804,11 @@ void Field::SharedCtor() { Field::~Field() { // @@protoc_insertion_point(destructor:google.protobuf.Field) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Field::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -858,19 +837,19 @@ void Field::Clear() { (void) cached_has_bits; options_.Clear(); - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::memset(&kind_, 0, static_cast( reinterpret_cast(&packed_) - reinterpret_cast(&kind_)) + sizeof(packed_)); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -967,7 +946,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1069,7 +1050,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Field::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Field) return target; @@ -1176,7 +1157,7 @@ void Field::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Field::MergeFrom(const Field& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1230,21 +1211,18 @@ bool Field::IsInitialized() const { void Field::InternalSwap(Field* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(kind_, other->kind_); - swap(cardinality_, other->cardinality_); - swap(number_, other->number_); - swap(oneof_index_, other->oneof_index_); - swap(packed_, other->packed_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Field, packed_) + + sizeof(Field::packed_) + - PROTOBUF_FIELD_OFFSET(Field, kind_)>( + reinterpret_cast(&kind_), + reinterpret_cast(&other->kind_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Field::GetMetadata() const { @@ -1267,33 +1245,14 @@ const PROTOBUF_NAMESPACE_ID::SourceContext& Enum::_Internal::source_context(const Enum* msg) { return *msg->source_context_; } -void Enum::unsafe_arena_set_allocated_source_context( - PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - if (GetArenaNoVirtual() == nullptr) { - delete source_context_; - } - source_context_ = source_context; - if (source_context) { - - } else { - - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context) -} void Enum::clear_source_context() { - if (GetArenaNoVirtual() == nullptr && source_context_ != nullptr) { + if (GetArena() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; } -Enum::Enum() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Enum) -} Enum::Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), enumvalue_(arena), options_(arena) { SharedCtor(); @@ -1302,14 +1261,13 @@ Enum::Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena) } Enum::Enum(const Enum& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), enumvalue_(from.enumvalue_), options_(from.options_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_source_context()) { source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); @@ -1331,10 +1289,11 @@ void Enum::SharedCtor() { Enum::~Enum() { // @@protoc_insertion_point(destructor:google.protobuf.Enum) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Enum::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete source_context_; } @@ -1362,18 +1321,18 @@ void Enum::Clear() { enumvalue_.Clear(); options_.Clear(); - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == nullptr && source_context_ != nullptr) { + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + if (GetArena() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; syntax_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1433,7 +1392,9 @@ const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1496,7 +1457,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Enum::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Enum) return target; @@ -1571,7 +1532,7 @@ void Enum::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Enum::MergeFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1608,13 +1569,16 @@ bool Enum::IsInitialized() const { void Enum::InternalSwap(Enum* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); enumvalue_.InternalSwap(&other->enumvalue_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - swap(source_context_, other->source_context_); - swap(syntax_, other->syntax_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Enum, syntax_) + + sizeof(Enum::syntax_) + - PROTOBUF_FIELD_OFFSET(Enum, source_context_)>( + reinterpret_cast(&source_context_), + reinterpret_cast(&other->source_context_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Enum::GetMetadata() const { @@ -1630,14 +1594,8 @@ class EnumValue::_Internal { public: }; -EnumValue::EnumValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) -} EnumValue::EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena), + : ::PROTOBUF_NAMESPACE_ID::Message(arena), options_(arena) { SharedCtor(); RegisterArenaDtor(arena); @@ -1645,13 +1603,12 @@ EnumValue::EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) } EnumValue::EnumValue(const EnumValue& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr), options_(from.options_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } number_ = from.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) @@ -1666,10 +1623,11 @@ void EnumValue::SharedCtor() { EnumValue::~EnumValue() { // @@protoc_insertion_point(destructor:google.protobuf.EnumValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void EnumValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -1695,14 +1653,14 @@ void EnumValue::Clear() { (void) cached_has_bits; options_.Clear(); - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); number_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1742,7 +1700,9 @@ const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1788,7 +1748,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* EnumValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValue) return target; @@ -1850,7 +1810,7 @@ void EnumValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void EnumValue::MergeFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1883,10 +1843,9 @@ bool EnumValue::IsInitialized() const { void EnumValue::InternalSwap(EnumValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(number_, other->number_); } @@ -1910,45 +1869,25 @@ const PROTOBUF_NAMESPACE_ID::Any& Option::_Internal::value(const Option* msg) { return *msg->value_; } -void Option::unsafe_arena_set_allocated_value( - PROTOBUF_NAMESPACE_ID::Any* value) { - if (GetArenaNoVirtual() == nullptr) { - delete value_; - } - value_ = value; - if (value) { - - } else { - - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value) -} void Option::clear_value() { - if (GetArenaNoVirtual() == nullptr && value_ != nullptr) { + if (GetArena() == nullptr && value_ != nullptr) { delete value_; } value_ = nullptr; } -Option::Option() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Option) -} Option::Option(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) } Option::Option(const Option& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), - GetArenaNoVirtual()); + GetArena()); } if (from._internal_has_value()) { value_ = new PROTOBUF_NAMESPACE_ID::Any(*from.value_); @@ -1967,10 +1906,11 @@ void Option::SharedCtor() { Option::~Option() { // @@protoc_insertion_point(destructor:google.protobuf.Option) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Option::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete value_; } @@ -1996,17 +1936,17 @@ void Option::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == nullptr && value_ != nullptr) { + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + if (GetArena() == nullptr && value_ != nullptr) { delete value_; } value_ = nullptr; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Option::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -2034,7 +1974,9 @@ const char* Option::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -2074,7 +2016,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Option::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Option) return target; @@ -2129,7 +2071,7 @@ void Option::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Option::MergeFrom(const Option& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2161,9 +2103,8 @@ bool Option::IsInitialized() const { void Option::InternalSwap(Option* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); swap(value_, other->value_); } diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 8756c93e0200..6e589f2234e8 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -179,10 +179,10 @@ inline bool Syntax_Parse( } // =================================================================== -class PROTOBUF_EXPORT Type : +class PROTOBUF_EXPORT Type PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ { public: - Type(); + inline Type() : Type(nullptr) {}; virtual ~Type(); Type(const Type& from); @@ -196,7 +196,7 @@ class PROTOBUF_EXPORT Type : return *this; } inline Type& operator=(Type&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -204,12 +204,6 @@ class PROTOBUF_EXPORT Type : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -234,7 +228,7 @@ class PROTOBUF_EXPORT Type : } inline void Swap(Type* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -242,7 +236,7 @@ class PROTOBUF_EXPORT Type : } void UnsafeArenaSwap(Type* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -282,13 +276,6 @@ class PROTOBUF_EXPORT Type : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -428,7 +415,6 @@ class PROTOBUF_EXPORT Type : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -443,10 +429,10 @@ class PROTOBUF_EXPORT Type : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Field : +class PROTOBUF_EXPORT Field PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ { public: - Field(); + inline Field() : Field(nullptr) {}; virtual ~Field(); Field(const Field& from); @@ -460,7 +446,7 @@ class PROTOBUF_EXPORT Field : return *this; } inline Field& operator=(Field&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -468,12 +454,6 @@ class PROTOBUF_EXPORT Field : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -498,7 +478,7 @@ class PROTOBUF_EXPORT Field : } inline void Swap(Field* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -506,7 +486,7 @@ class PROTOBUF_EXPORT Field : } void UnsafeArenaSwap(Field* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -546,13 +526,6 @@ class PROTOBUF_EXPORT Field : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -845,7 +818,6 @@ class PROTOBUF_EXPORT Field : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -864,10 +836,10 @@ class PROTOBUF_EXPORT Field : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Enum : +class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ { public: - Enum(); + inline Enum() : Enum(nullptr) {}; virtual ~Enum(); Enum(const Enum& from); @@ -881,7 +853,7 @@ class PROTOBUF_EXPORT Enum : return *this; } inline Enum& operator=(Enum&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -889,12 +861,6 @@ class PROTOBUF_EXPORT Enum : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -919,7 +885,7 @@ class PROTOBUF_EXPORT Enum : } inline void Swap(Enum* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -927,7 +893,7 @@ class PROTOBUF_EXPORT Enum : } void UnsafeArenaSwap(Enum* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -967,13 +933,6 @@ class PROTOBUF_EXPORT Enum : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1088,7 +1047,6 @@ class PROTOBUF_EXPORT Enum : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1102,10 +1060,10 @@ class PROTOBUF_EXPORT Enum : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumValue : +class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ { public: - EnumValue(); + inline EnumValue() : EnumValue(nullptr) {}; virtual ~EnumValue(); EnumValue(const EnumValue& from); @@ -1119,7 +1077,7 @@ class PROTOBUF_EXPORT EnumValue : return *this; } inline EnumValue& operator=(EnumValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1127,12 +1085,6 @@ class PROTOBUF_EXPORT EnumValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1157,7 +1109,7 @@ class PROTOBUF_EXPORT EnumValue : } inline void Swap(EnumValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1165,7 +1117,7 @@ class PROTOBUF_EXPORT EnumValue : } void UnsafeArenaSwap(EnumValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1205,13 +1157,6 @@ class PROTOBUF_EXPORT EnumValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1288,7 +1233,6 @@ class PROTOBUF_EXPORT EnumValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1300,10 +1244,10 @@ class PROTOBUF_EXPORT EnumValue : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Option : +class PROTOBUF_EXPORT Option PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ { public: - Option(); + inline Option() : Option(nullptr) {}; virtual ~Option(); Option(const Option& from); @@ -1317,7 +1261,7 @@ class PROTOBUF_EXPORT Option : return *this; } inline Option& operator=(Option&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1325,12 +1269,6 @@ class PROTOBUF_EXPORT Option : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1355,7 +1293,7 @@ class PROTOBUF_EXPORT Option : } inline void Swap(Option* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1363,7 +1301,7 @@ class PROTOBUF_EXPORT Option : } void UnsafeArenaSwap(Option* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1403,13 +1341,6 @@ class PROTOBUF_EXPORT Option : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1476,7 +1407,6 @@ class PROTOBUF_EXPORT Option : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1498,7 +1428,7 @@ class PROTOBUF_EXPORT Option : // string name = 1; inline void Type::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) @@ -1517,36 +1447,36 @@ inline const std::string& Type::_internal_name() const { } inline void Type::_internal_set_name(const std::string& value) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Type::set_name(std::string&& value) { name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Type.name) } inline void Type::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name) } inline void Type::set_name(const char* value, size_t size) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) } inline std::string* Type::_internal_mutable_name() { - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Type::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Type.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Type::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1555,26 +1485,26 @@ inline void Type::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) } inline std::string* Type::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Type::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { } else { } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.name) } @@ -1746,9 +1676,22 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Type::source_context() const // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context) return _internal_source_context(); } +inline void Type::unsafe_arena_set_allocated_source_context( + PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context) +} inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() { auto temp = unsafe_arena_release_source_context(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -1763,7 +1706,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::unsafe_arena_release_source_c inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::_internal_mutable_source_context() { if (source_context_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); source_context_ = p; } return source_context_; @@ -1773,12 +1716,13 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::mutable_source_context() { return _internal_mutable_source_context(); } inline void Type::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); } if (source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr; + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena(); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, source_context, submessage_arena); @@ -1877,7 +1821,7 @@ inline void Field::set_number(::PROTOBUF_NAMESPACE_ID::int32 value) { // string name = 4; inline void Field::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) @@ -1896,36 +1840,36 @@ inline const std::string& Field::_internal_name() const { } inline void Field::_internal_set_name(const std::string& value) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Field::set_name(std::string&& value) { name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.name) } inline void Field::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name) } inline void Field::set_name(const char* value, size_t size) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) } inline std::string* Field::_internal_mutable_name() { - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Field::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Field::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1934,32 +1878,32 @@ inline void Field::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) } inline std::string* Field::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Field::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { } else { } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) } // string type_url = 6; inline void Field::clear_type_url() { - type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + type_url_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) @@ -1978,36 +1922,36 @@ inline const std::string& Field::_internal_type_url() const { } inline void Field::_internal_set_type_url(const std::string& value) { - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Field::set_type_url(std::string&& value) { type_url_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.type_url) } inline void Field::set_type_url(const char* value) { GOOGLE_DCHECK(value != nullptr); type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url) } inline void Field::set_type_url(const char* value, size_t size) { type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) } inline std::string* Field::_internal_mutable_type_url() { - return type_url_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return type_url_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Field::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) - return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Field::set_allocated_type_url(std::string* type_url) { if (type_url != nullptr) { @@ -2016,26 +1960,26 @@ inline void Field::set_allocated_type_url(std::string* type_url) { } type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) } inline std::string* Field::unsafe_arena_release_type_url() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Field::unsafe_arena_set_allocated_type_url( std::string* type_url) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (type_url != nullptr) { } else { } type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - type_url, GetArenaNoVirtual()); + type_url, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) } @@ -2120,7 +2064,7 @@ Field::options() const { // string json_name = 10; inline void Field::clear_json_name() { - json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) @@ -2139,36 +2083,36 @@ inline const std::string& Field::_internal_json_name() const { } inline void Field::_internal_set_json_name(const std::string& value) { - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Field::set_json_name(std::string&& value) { json_name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.json_name) } inline void Field::set_json_name(const char* value) { GOOGLE_DCHECK(value != nullptr); json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name) } inline void Field::set_json_name(const char* value, size_t size) { json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) } inline std::string* Field::_internal_mutable_json_name() { - return json_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return json_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Field::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) - return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Field::set_allocated_json_name(std::string* json_name) { if (json_name != nullptr) { @@ -2177,32 +2121,32 @@ inline void Field::set_allocated_json_name(std::string* json_name) { } json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) } inline std::string* Field::unsafe_arena_release_json_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return json_name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Field::unsafe_arena_set_allocated_json_name( std::string* json_name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (json_name != nullptr) { } else { } json_name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - json_name, GetArenaNoVirtual()); + json_name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) } // string default_value = 11; inline void Field::clear_default_value() { - default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) @@ -2221,36 +2165,36 @@ inline const std::string& Field::_internal_default_value() const { } inline void Field::_internal_set_default_value(const std::string& value) { - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Field::set_default_value(std::string&& value) { default_value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.default_value) } inline void Field::set_default_value(const char* value) { GOOGLE_DCHECK(value != nullptr); default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value) } inline void Field::set_default_value(const char* value, size_t size) { default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) } inline std::string* Field::_internal_mutable_default_value() { - return default_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return default_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Field::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) - return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Field::set_allocated_default_value(std::string* default_value) { if (default_value != nullptr) { @@ -2259,26 +2203,26 @@ inline void Field::set_allocated_default_value(std::string* default_value) { } default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) } inline std::string* Field::unsafe_arena_release_default_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return default_value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Field::unsafe_arena_set_allocated_default_value( std::string* default_value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (default_value != nullptr) { } else { } default_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - default_value, GetArenaNoVirtual()); + default_value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) } @@ -2288,7 +2232,7 @@ inline void Field::unsafe_arena_set_allocated_default_value( // string name = 1; inline void Enum::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) @@ -2307,36 +2251,36 @@ inline const std::string& Enum::_internal_name() const { } inline void Enum::_internal_set_name(const std::string& value) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Enum::set_name(std::string&& value) { name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Enum.name) } inline void Enum::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name) } inline void Enum::set_name(const char* value, size_t size) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) } inline std::string* Enum::_internal_mutable_name() { - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Enum::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Enum::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -2345,26 +2289,26 @@ inline void Enum::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) } inline std::string* Enum::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Enum::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { } else { } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.name) } @@ -2462,9 +2406,22 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Enum::source_context() const // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context) return _internal_source_context(); } +inline void Enum::unsafe_arena_set_allocated_source_context( + PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context) +} inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() { auto temp = unsafe_arena_release_source_context(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -2479,7 +2436,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::unsafe_arena_release_source_c inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::_internal_mutable_source_context() { if (source_context_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); source_context_ = p; } return source_context_; @@ -2489,12 +2446,13 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::mutable_source_context() { return _internal_mutable_source_context(); } inline void Enum::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); } if (source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr; + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena(); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, source_context, submessage_arena); @@ -2533,7 +2491,7 @@ inline void Enum::set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value) { // string name = 1; inline void EnumValue::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) @@ -2552,36 +2510,36 @@ inline const std::string& EnumValue::_internal_name() const { } inline void EnumValue::_internal_set_name(const std::string& value) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void EnumValue::set_name(std::string&& value) { name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValue.name) } inline void EnumValue::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name) } inline void EnumValue::set_name(const char* value, size_t size) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) } inline std::string* EnumValue::_internal_mutable_name() { - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* EnumValue::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void EnumValue::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -2590,26 +2548,26 @@ inline void EnumValue::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) } inline std::string* EnumValue::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void EnumValue::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { } else { } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) } @@ -2678,7 +2636,7 @@ EnumValue::options() const { // string name = 1; inline void Option::clear_name() { - name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) @@ -2697,36 +2655,36 @@ inline const std::string& Option::_internal_name() const { } inline void Option::_internal_set_name(const std::string& value) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void Option::set_name(std::string&& value) { name_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Option.name) } inline void Option::set_name(const char* value) { GOOGLE_DCHECK(value != nullptr); name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name) } inline void Option::set_name(const char* value, size_t size) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name) } inline std::string* Option::_internal_mutable_name() { - return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* Option::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Option.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void Option::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -2735,26 +2693,26 @@ inline void Option::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) } inline std::string* Option::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void Option::unsafe_arena_set_allocated_name( std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (name != nullptr) { } else { } name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); + name, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) } @@ -2774,9 +2732,22 @@ inline const PROTOBUF_NAMESPACE_ID::Any& Option::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.value) return _internal_value(); } +inline void Option::unsafe_arena_set_allocated_value( + PROTOBUF_NAMESPACE_ID::Any* value) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_); + } + value_ = value; + if (value) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value) +} inline PROTOBUF_NAMESPACE_ID::Any* Option::release_value() { auto temp = unsafe_arena_release_value(); - if (GetArenaNoVirtual() != nullptr) { + if (GetArena() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -2791,7 +2762,7 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::unsafe_arena_release_value() { inline PROTOBUF_NAMESPACE_ID::Any* Option::_internal_mutable_value() { if (value_ == nullptr) { - auto* p = CreateMaybeMessage(GetArenaNoVirtual()); + auto* p = CreateMaybeMessage(GetArena()); value_ = p; } return value_; @@ -2801,12 +2772,13 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::mutable_value() { return _internal_mutable_value(); } inline void Option::set_allocated_value(PROTOBUF_NAMESPACE_ID::Any* value) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_); } if (value) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr; + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value)->GetArena(); if (message_arena != submessage_arena) { value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, value, submessage_arena); diff --git a/src/google/protobuf/unittest_custom_options.proto b/src/google/protobuf/unittest_custom_options.proto index c4aad2edf686..50bb99600244 100644 --- a/src/google/protobuf/unittest_custom_options.proto +++ b/src/google/protobuf/unittest_custom_options.proto @@ -38,8 +38,8 @@ syntax = "proto2"; // Some generic_services option(s) added automatically. // See: http://go/proto2-generic-services-default -option cc_generic_services = true; // auto-added -option java_generic_services = true; // auto-added +option cc_generic_services = true; // auto-added +option java_generic_services = true; // auto-added option py_generic_services = true; // A custom file option (defined below). @@ -51,7 +51,6 @@ import "google/protobuf/descriptor.proto"; // that the generated code doesn't depend on being in the proto2 namespace. package protobuf_unittest; - // Some simple test custom options of various types. extend google.protobuf.FileOptions { @@ -66,7 +65,7 @@ extend google.protobuf.FieldOptions { optional fixed64 field_opt1 = 7740936; // This is useful for testing that we correctly register default values for // extension options. - optional int32 field_opt2 = 7753913 [default=42]; + optional int32 field_opt2 = 7753913 [default = 42]; } extend google.protobuf.OneofOptions { @@ -98,14 +97,13 @@ extend google.protobuf.MethodOptions { // regular options, to make sure they interact nicely). message TestMessageWithCustomOptions { option message_set_wire_format = false; - option (message_opt1) = -56; - optional string field1 = 1 [ctype=CORD, - (field_opt1)=8765432109]; + optional string field1 = 1 [ctype = CORD, (field_opt1) = 8765432109]; oneof AnOneof { option (oneof_opt1) = -99; + int32 oneof_field = 2; } @@ -117,20 +115,15 @@ message TestMessageWithCustomOptions { } } - // A test RPC service with custom options at all possible locations (and also // some regular options, to make sure they interact nicely). -message CustomOptionFooRequest { -} +message CustomOptionFooRequest {} -message CustomOptionFooResponse { -} +message CustomOptionFooResponse {} -message CustomOptionFooClientMessage { -} +message CustomOptionFooClientMessage {} -message CustomOptionFooServerMessage { -} +message CustomOptionFooServerMessage {} service TestServiceWithCustomOptions { option (service_opt1) = -9876543210; @@ -140,8 +133,6 @@ service TestServiceWithCustomOptions { } } - - // Options of every possible field type, so we can test them all exhaustively. message DummyMessageContainingEnum { @@ -151,74 +142,73 @@ message DummyMessageContainingEnum { } } -message DummyMessageInvalidAsOptionType { -} +message DummyMessageInvalidAsOptionType {} extend google.protobuf.MessageOptions { - optional bool bool_opt = 7706090; - optional int32 int32_opt = 7705709; - optional int64 int64_opt = 7705542; - optional uint32 uint32_opt = 7704880; - optional uint64 uint64_opt = 7702367; - optional sint32 sint32_opt = 7701568; - optional sint64 sint64_opt = 7700863; - optional fixed32 fixed32_opt = 7700307; - optional fixed64 fixed64_opt = 7700194; - optional sfixed32 sfixed32_opt = 7698645; - optional sfixed64 sfixed64_opt = 7685475; - optional float float_opt = 7675390; - optional double double_opt = 7673293; - optional string string_opt = 7673285; - optional bytes bytes_opt = 7673238; + optional bool bool_opt = 7706090; + optional int32 int32_opt = 7705709; + optional int64 int64_opt = 7705542; + optional uint32 uint32_opt = 7704880; + optional uint64 uint64_opt = 7702367; + optional sint32 sint32_opt = 7701568; + optional sint64 sint64_opt = 7700863; + optional fixed32 fixed32_opt = 7700307; + optional fixed64 fixed64_opt = 7700194; + optional sfixed32 sfixed32_opt = 7698645; + optional sfixed64 sfixed64_opt = 7685475; + optional float float_opt = 7675390; + optional double double_opt = 7673293; + optional string string_opt = 7673285; + optional bytes bytes_opt = 7673238; optional DummyMessageContainingEnum.TestEnumType enum_opt = 7673233; optional DummyMessageInvalidAsOptionType message_type_opt = 7665967; } message CustomOptionMinIntegerValues { - option (bool_opt) = false; - option (int32_opt) = -0x80000000; - option (int64_opt) = -0x8000000000000000; - option (uint32_opt) = 0; - option (uint64_opt) = 0; - option (sint32_opt) = -0x80000000; - option (sint64_opt) = -0x8000000000000000; - option (fixed32_opt) = 0; - option (fixed64_opt) = 0; + option (bool_opt) = false; + option (int32_opt) = -0x80000000; + option (int64_opt) = -0x8000000000000000; + option (uint32_opt) = 0; + option (uint64_opt) = 0; + option (sint32_opt) = -0x80000000; + option (sint64_opt) = -0x8000000000000000; + option (fixed32_opt) = 0; + option (fixed64_opt) = 0; option (sfixed32_opt) = -0x80000000; option (sfixed64_opt) = -0x8000000000000000; } message CustomOptionMaxIntegerValues { - option (bool_opt) = true; - option (int32_opt) = 0x7FFFFFFF; - option (int64_opt) = 0x7FFFFFFFFFFFFFFF; - option (uint32_opt) = 0xFFFFFFFF; - option (uint64_opt) = 0xFFFFFFFFFFFFFFFF; - option (sint32_opt) = 0x7FFFFFFF; - option (sint64_opt) = 0x7FFFFFFFFFFFFFFF; - option (fixed32_opt) = 0xFFFFFFFF; - option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF; + option (bool_opt) = true; + option (int32_opt) = 0x7FFFFFFF; + option (int64_opt) = 0x7FFFFFFFFFFFFFFF; + option (uint32_opt) = 0xFFFFFFFF; + option (uint64_opt) = 0xFFFFFFFFFFFFFFFF; + option (sint32_opt) = 0x7FFFFFFF; + option (sint64_opt) = 0x7FFFFFFFFFFFFFFF; + option (fixed32_opt) = 0xFFFFFFFF; + option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF; option (sfixed32_opt) = 0x7FFFFFFF; option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF; } message CustomOptionOtherValues { - option (int32_opt) = -100; // To test sign-extension. - option (float_opt) = 12.3456789; + option (int32_opt) = -100; // To test sign-extension. + option (float_opt) = 12.3456789; option (double_opt) = 1.234567890123456789; option (string_opt) = "Hello, \"World\""; - option (bytes_opt) = "Hello\0World"; - option (enum_opt) = TEST_OPTION_ENUM_TYPE2; + option (bytes_opt) = "Hello\0World"; + option (enum_opt) = TEST_OPTION_ENUM_TYPE2; } message SettingRealsFromPositiveInts { - option (float_opt) = 12; + option (float_opt) = 12; option (double_opt) = 154; } message SettingRealsFromNegativeInts { - option (float_opt) = -12; - option (double_opt) = -154; + option (float_opt) = -12; + option (double_opt) = -154; } // Options of complex message types, themselves combined and extended in @@ -295,8 +285,12 @@ message VariousComplexOptions { option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121; option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; option (complex_opt2).fred.waldo = 321; - option (complex_opt2).barney = { waldo: 101 }; - option (complex_opt2).barney = { waldo: 212 }; + option (complex_opt2).barney = { + waldo: 101 + }; + option (complex_opt2).barney = { + waldo: 212 + }; option (protobuf_unittest.complex_opt3).qux = 9; option (complex_opt3).complexoptiontype5.plugh = 22; option (complexopt6).xyzzy = 24; @@ -308,6 +302,7 @@ message VariousComplexOptions { message AggregateMessageSet { option message_set_wire_format = true; + extensions 4 to max; } @@ -338,28 +333,41 @@ message Aggregate { // Allow Aggregate to be used as an option at all possible locations // in the .proto grammar. -extend google.protobuf.FileOptions { optional Aggregate fileopt = 15478479; } -extend google.protobuf.MessageOptions { optional Aggregate msgopt = 15480088; } -extend google.protobuf.FieldOptions { optional Aggregate fieldopt = 15481374; } -extend google.protobuf.EnumOptions { optional Aggregate enumopt = 15483218; } -extend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 15486921; } -extend google.protobuf.ServiceOptions { optional Aggregate serviceopt = 15497145; } -extend google.protobuf.MethodOptions { optional Aggregate methodopt = 15512713; } +extend google.protobuf.FileOptions { + optional Aggregate fileopt = 15478479; +} +extend google.protobuf.MessageOptions { + optional Aggregate msgopt = 15480088; +} +extend google.protobuf.FieldOptions { + optional Aggregate fieldopt = 15481374; +} +extend google.protobuf.EnumOptions { + optional Aggregate enumopt = 15483218; +} +extend google.protobuf.EnumValueOptions { + optional Aggregate enumvalopt = 15486921; +} +extend google.protobuf.ServiceOptions { + optional Aggregate serviceopt = 15497145; +} +extend google.protobuf.MethodOptions { + optional Aggregate methodopt = 15512713; +} // Try using AggregateOption at different points in the proto grammar option (fileopt) = { s: 'FileAnnotation' // Also test the handling of comments - /* of both types */ i: 100 + /* of both types */ + i: 100 sub { s: 'NestedFileAnnotation' } // Include a google.protobuf.FileOptions and recursively extend it with // another fileopt. file { - [protobuf_unittest.fileopt] { - s:'FileExtensionAnnotation' - } + [protobuf_unittest.fileopt] { s: 'FileExtensionAnnotation' } } // A message set inside an option value @@ -371,30 +379,44 @@ option (fileopt) = { }; message AggregateMessage { - option (msgopt) = { i:101 s:'MessageAnnotation' }; - optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }]; + option (msgopt) = { + i: 101 + s: 'MessageAnnotation' + }; + + optional int32 fieldname = 1 [(fieldopt) = { s: 'FieldAnnotation' }]; } service AggregateService { - option (serviceopt) = { s:'ServiceAnnotation' }; - rpc Method (AggregateMessage) returns (AggregateMessage) { - option (methodopt) = { s:'MethodAnnotation' }; + option (serviceopt) = { + s: 'ServiceAnnotation' + }; + + rpc Method(AggregateMessage) returns (AggregateMessage) { + option (methodopt) = { + s: 'MethodAnnotation' + }; } } enum AggregateEnum { - option (enumopt) = { s:'EnumAnnotation' }; - VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }]; + option (enumopt) = { + s: 'EnumAnnotation' + }; + + VALUE = 1 [(enumvalopt) = { s: 'EnumValueAnnotation' }]; } // Test custom options for nested type. message NestedOptionType { message NestedMessage { option (message_opt1) = 1001; + optional int32 nested_field = 1 [(field_opt1) = 1002]; } enum NestedEnum { option (enum_opt1) = 1003; + NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004]; } extend google.protobuf.FileOptions { @@ -405,9 +427,7 @@ message NestedOptionType { // Custom message option that has a required enum field. // WARNING: this is strongly discouraged! message OldOptionType { - enum TestEnum { - OLD_VALUE = 0; - } + enum TestEnum { OLD_VALUE = 0; } required TestEnum value = 1; } @@ -426,5 +446,7 @@ extend google.protobuf.MessageOptions { // Test message using the "required_enum_opt" option defined above. message TestMessageWithRequiredEnumOption { - option (required_enum_opt) = { value: OLD_VALUE }; + option (required_enum_opt) = { + value: OLD_VALUE + }; } diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto index 979c8416b470..4c3d84585353 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto @@ -38,6 +38,7 @@ package protobuf_unittest; import "google/protobuf/unittest_import_lite.proto"; +option cc_enable_arenas = false; option optimize_for = LITE_RUNTIME; option java_package = "com.google.protobuf"; diff --git a/src/google/protobuf/unittest_no_arena_import.proto b/src/google/protobuf/unittest_no_arena_import.proto index 072af49e3c70..6f3f04f535d5 100644 --- a/src/google/protobuf/unittest_no_arena_import.proto +++ b/src/google/protobuf/unittest_no_arena_import.proto @@ -32,6 +32,8 @@ syntax = "proto2"; package proto2_arena_unittest; +option cc_enable_arenas = false; + message ImportNoArenaNestedMessage { optional int32 d = 1; -}; +} diff --git a/src/google/protobuf/unittest_no_arena_lite.proto b/src/google/protobuf/unittest_no_arena_lite.proto index 34c7b7ce99a9..58d85532f525 100644 --- a/src/google/protobuf/unittest_no_arena_lite.proto +++ b/src/google/protobuf/unittest_no_arena_lite.proto @@ -37,6 +37,8 @@ option optimize_for = LITE_RUNTIME; // In test_util.h we do "using namespace unittest = protobuf_unittest". package protobuf_unittest_no_arena; +option cc_enable_arenas = false; + message ForeignMessageLite { optional int32 c = 1; } diff --git a/src/google/protobuf/unittest_proto3_arena_lite.proto b/src/google/protobuf/unittest_proto3_arena_lite.proto index b3c91f570efb..0d4218b97fc5 100644 --- a/src/google/protobuf/unittest_proto3_arena_lite.proto +++ b/src/google/protobuf/unittest_proto3_arena_lite.proto @@ -30,12 +30,12 @@ syntax = "proto3"; -option cc_enable_arenas = true; -option optimize_for = LITE_RUNTIME; +package proto3_arena_lite_unittest; import "google/protobuf/unittest_import.proto"; -package proto3_arena_lite_unittest; +option cc_enable_arenas = true; +option optimize_for = LITE_RUNTIME; // This proto includes every type of field in both singular and repeated // forms. @@ -56,86 +56,86 @@ message TestAllTypes { } // Singular - int32 optional_int32 = 1; - int64 optional_int64 = 2; - uint32 optional_uint32 = 3; - uint64 optional_uint64 = 4; - sint32 optional_sint32 = 5; - sint64 optional_sint64 = 6; - fixed32 optional_fixed32 = 7; - fixed64 optional_fixed64 = 8; - sfixed32 optional_sfixed32 = 9; + int32 optional_int32 = 1; + int64 optional_int64 = 2; + uint32 optional_uint32 = 3; + uint64 optional_uint64 = 4; + sint32 optional_sint32 = 5; + sint64 optional_sint64 = 6; + fixed32 optional_fixed32 = 7; + fixed64 optional_fixed64 = 8; + sfixed32 optional_sfixed32 = 9; sfixed64 optional_sfixed64 = 10; - float optional_float = 11; - double optional_double = 12; - bool optional_bool = 13; - string optional_string = 14; - bytes optional_bytes = 15; + float optional_float = 11; + double optional_double = 12; + bool optional_bool = 13; + string optional_string = 14; + bytes optional_bytes = 15; // Groups are not allowed in proto3. // optional group OptionalGroup = 16 { // optional int32 a = 17; // } - NestedMessage optional_nested_message = 18; - ForeignMessage optional_foreign_message = 19; - protobuf_unittest_import.ImportMessage optional_import_message = 20; + NestedMessage optional_nested_message = 18; + ForeignMessage optional_foreign_message = 19; + protobuf_unittest_import.ImportMessage optional_import_message = 20; - NestedEnum optional_nested_enum = 21; - ForeignEnum optional_foreign_enum = 22; + NestedEnum optional_nested_enum = 21; + ForeignEnum optional_foreign_enum = 22; // Omitted (compared to unittest.proto) because proto2 enums are not allowed // inside proto2 messages. // // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23; - string optional_string_piece = 24 [ctype=STRING_PIECE]; - string optional_cord = 25 [ctype=CORD]; + string optional_string_piece = 24 [ctype = STRING_PIECE]; + string optional_cord = 25 [ctype = CORD]; // Defined in unittest_import_public.proto - protobuf_unittest_import.PublicImportMessage - optional_public_import_message = 26; + protobuf_unittest_import.PublicImportMessage optional_public_import_message = + 26; - NestedMessage optional_lazy_message = 27 [lazy=true]; + NestedMessage optional_lazy_message = 27 [lazy = true]; // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; repeated sfixed32 repeated_sfixed32 = 39; repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; // Groups are not allowed in proto3. // repeated group RepeatedGroup = 46 { // optional int32 a = 47; // } - repeated NestedMessage repeated_nested_message = 48; - repeated ForeignMessage repeated_foreign_message = 49; - repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; - repeated NestedEnum repeated_nested_enum = 51; - repeated ForeignEnum repeated_foreign_enum = 52; + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; // Omitted (compared to unittest.proto) because proto2 enums are not allowed // inside proto2 messages. // // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; - repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; - repeated string repeated_cord = 55 [ctype=CORD]; + repeated string repeated_string_piece = 54 [ctype = STRING_PIECE]; + repeated string repeated_cord = 55 [ctype = CORD]; - repeated NestedMessage repeated_lazy_message = 57 [lazy=true]; + repeated NestedMessage repeated_lazy_message = 57 [lazy = true]; oneof oneof_field { uint32 oneof_uint32 = 111; @@ -148,37 +148,37 @@ message TestAllTypes { // Test messages for packed fields message TestPackedTypes { - repeated int32 packed_int32 = 90 [packed = true]; - repeated int64 packed_int64 = 91 [packed = true]; - repeated uint32 packed_uint32 = 92 [packed = true]; - repeated uint64 packed_uint64 = 93 [packed = true]; - repeated sint32 packed_sint32 = 94 [packed = true]; - repeated sint64 packed_sint64 = 95 [packed = true]; - repeated fixed32 packed_fixed32 = 96 [packed = true]; - repeated fixed64 packed_fixed64 = 97 [packed = true]; - repeated sfixed32 packed_sfixed32 = 98 [packed = true]; - repeated sfixed64 packed_sfixed64 = 99 [packed = true]; - repeated float packed_float = 100 [packed = true]; - repeated double packed_double = 101 [packed = true]; - repeated bool packed_bool = 102 [packed = true]; - repeated ForeignEnum packed_enum = 103 [packed = true]; + repeated int32 packed_int32 = 90 [packed = true]; + repeated int64 packed_int64 = 91 [packed = true]; + repeated uint32 packed_uint32 = 92 [packed = true]; + repeated uint64 packed_uint64 = 93 [packed = true]; + repeated sint32 packed_sint32 = 94 [packed = true]; + repeated sint64 packed_sint64 = 95 [packed = true]; + repeated fixed32 packed_fixed32 = 96 [packed = true]; + repeated fixed64 packed_fixed64 = 97 [packed = true]; + repeated sfixed32 packed_sfixed32 = 98 [packed = true]; + repeated sfixed64 packed_sfixed64 = 99 [packed = true]; + repeated float packed_float = 100 [packed = true]; + repeated double packed_double = 101 [packed = true]; + repeated bool packed_bool = 102 [packed = true]; + repeated ForeignEnum packed_enum = 103 [packed = true]; } // Explicitly set packed to false message TestUnpackedTypes { - repeated int32 repeated_int32 = 1 [packed = false]; - repeated int64 repeated_int64 = 2 [packed = false]; - repeated uint32 repeated_uint32 = 3 [packed = false]; - repeated uint64 repeated_uint64 = 4 [packed = false]; - repeated sint32 repeated_sint32 = 5 [packed = false]; - repeated sint64 repeated_sint64 = 6 [packed = false]; - repeated fixed32 repeated_fixed32 = 7 [packed = false]; - repeated fixed64 repeated_fixed64 = 8 [packed = false]; - repeated sfixed32 repeated_sfixed32 = 9 [packed = false]; + repeated int32 repeated_int32 = 1 [packed = false]; + repeated int64 repeated_int64 = 2 [packed = false]; + repeated uint32 repeated_uint32 = 3 [packed = false]; + repeated uint64 repeated_uint64 = 4 [packed = false]; + repeated sint32 repeated_sint32 = 5 [packed = false]; + repeated sint64 repeated_sint64 = 6 [packed = false]; + repeated fixed32 repeated_fixed32 = 7 [packed = false]; + repeated fixed64 repeated_fixed64 = 8 [packed = false]; + repeated sfixed32 repeated_sfixed32 = 9 [packed = false]; repeated sfixed64 repeated_sfixed64 = 10 [packed = false]; - repeated float repeated_float = 11 [packed = false]; - repeated double repeated_double = 12 [packed = false]; - repeated bool repeated_bool = 13 [packed = false]; + repeated float repeated_float = 11 [packed = false]; + repeated double repeated_double = 12 [packed = false]; + repeated bool repeated_bool = 13 [packed = false]; repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false]; } @@ -202,6 +202,4 @@ enum ForeignEnum { } // TestEmptyMessage is used to test behavior of unknown fields. -message TestEmptyMessage { -} - +message TestEmptyMessage {} diff --git a/src/google/protobuf/unittest_proto3_lite.proto b/src/google/protobuf/unittest_proto3_lite.proto index 6ee8bc8085bc..837bb03c5f1f 100644 --- a/src/google/protobuf/unittest_proto3_lite.proto +++ b/src/google/protobuf/unittest_proto3_lite.proto @@ -30,11 +30,11 @@ syntax = "proto3"; -option optimize_for = LITE_RUNTIME; +package proto3_lite_unittest; import "google/protobuf/unittest_import.proto"; -package proto3_lite_unittest; +option optimize_for = LITE_RUNTIME; // This proto includes every type of field in both singular and repeated // forms. @@ -55,86 +55,86 @@ message TestAllTypes { } // Singular - int32 optional_int32 = 1; - int64 optional_int64 = 2; - uint32 optional_uint32 = 3; - uint64 optional_uint64 = 4; - sint32 optional_sint32 = 5; - sint64 optional_sint64 = 6; - fixed32 optional_fixed32 = 7; - fixed64 optional_fixed64 = 8; - sfixed32 optional_sfixed32 = 9; + int32 optional_int32 = 1; + int64 optional_int64 = 2; + uint32 optional_uint32 = 3; + uint64 optional_uint64 = 4; + sint32 optional_sint32 = 5; + sint64 optional_sint64 = 6; + fixed32 optional_fixed32 = 7; + fixed64 optional_fixed64 = 8; + sfixed32 optional_sfixed32 = 9; sfixed64 optional_sfixed64 = 10; - float optional_float = 11; - double optional_double = 12; - bool optional_bool = 13; - string optional_string = 14; - bytes optional_bytes = 15; + float optional_float = 11; + double optional_double = 12; + bool optional_bool = 13; + string optional_string = 14; + bytes optional_bytes = 15; // Groups are not allowed in proto3. // optional group OptionalGroup = 16 { // optional int32 a = 17; // } - NestedMessage optional_nested_message = 18; - ForeignMessage optional_foreign_message = 19; - protobuf_unittest_import.ImportMessage optional_import_message = 20; + NestedMessage optional_nested_message = 18; + ForeignMessage optional_foreign_message = 19; + protobuf_unittest_import.ImportMessage optional_import_message = 20; - NestedEnum optional_nested_enum = 21; - ForeignEnum optional_foreign_enum = 22; + NestedEnum optional_nested_enum = 21; + ForeignEnum optional_foreign_enum = 22; // Omitted (compared to unittest.proto) because proto2 enums are not allowed // inside proto2 messages. // // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23; - string optional_string_piece = 24 [ctype=STRING_PIECE]; - string optional_cord = 25 [ctype=CORD]; + string optional_string_piece = 24 [ctype = STRING_PIECE]; + string optional_cord = 25 [ctype = CORD]; // Defined in unittest_import_public.proto - protobuf_unittest_import.PublicImportMessage - optional_public_import_message = 26; + protobuf_unittest_import.PublicImportMessage optional_public_import_message = + 26; - NestedMessage optional_lazy_message = 27 [lazy=true]; + NestedMessage optional_lazy_message = 27 [lazy = true]; // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; repeated sfixed32 repeated_sfixed32 = 39; repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; // Groups are not allowed in proto3. // repeated group RepeatedGroup = 46 { // optional int32 a = 47; // } - repeated NestedMessage repeated_nested_message = 48; - repeated ForeignMessage repeated_foreign_message = 49; - repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; - repeated NestedEnum repeated_nested_enum = 51; - repeated ForeignEnum repeated_foreign_enum = 52; + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; // Omitted (compared to unittest.proto) because proto2 enums are not allowed // inside proto2 messages. // // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; - repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; - repeated string repeated_cord = 55 [ctype=CORD]; + repeated string repeated_string_piece = 54 [ctype = STRING_PIECE]; + repeated string repeated_cord = 55 [ctype = CORD]; - repeated NestedMessage repeated_lazy_message = 57 [lazy=true]; + repeated NestedMessage repeated_lazy_message = 57 [lazy = true]; oneof oneof_field { uint32 oneof_uint32 = 111; @@ -147,37 +147,37 @@ message TestAllTypes { // Test messages for packed fields message TestPackedTypes { - repeated int32 packed_int32 = 90 [packed = true]; - repeated int64 packed_int64 = 91 [packed = true]; - repeated uint32 packed_uint32 = 92 [packed = true]; - repeated uint64 packed_uint64 = 93 [packed = true]; - repeated sint32 packed_sint32 = 94 [packed = true]; - repeated sint64 packed_sint64 = 95 [packed = true]; - repeated fixed32 packed_fixed32 = 96 [packed = true]; - repeated fixed64 packed_fixed64 = 97 [packed = true]; - repeated sfixed32 packed_sfixed32 = 98 [packed = true]; - repeated sfixed64 packed_sfixed64 = 99 [packed = true]; - repeated float packed_float = 100 [packed = true]; - repeated double packed_double = 101 [packed = true]; - repeated bool packed_bool = 102 [packed = true]; - repeated ForeignEnum packed_enum = 103 [packed = true]; + repeated int32 packed_int32 = 90 [packed = true]; + repeated int64 packed_int64 = 91 [packed = true]; + repeated uint32 packed_uint32 = 92 [packed = true]; + repeated uint64 packed_uint64 = 93 [packed = true]; + repeated sint32 packed_sint32 = 94 [packed = true]; + repeated sint64 packed_sint64 = 95 [packed = true]; + repeated fixed32 packed_fixed32 = 96 [packed = true]; + repeated fixed64 packed_fixed64 = 97 [packed = true]; + repeated sfixed32 packed_sfixed32 = 98 [packed = true]; + repeated sfixed64 packed_sfixed64 = 99 [packed = true]; + repeated float packed_float = 100 [packed = true]; + repeated double packed_double = 101 [packed = true]; + repeated bool packed_bool = 102 [packed = true]; + repeated ForeignEnum packed_enum = 103 [packed = true]; } // Explicitly set packed to false message TestUnpackedTypes { - repeated int32 repeated_int32 = 1 [packed = false]; - repeated int64 repeated_int64 = 2 [packed = false]; - repeated uint32 repeated_uint32 = 3 [packed = false]; - repeated uint64 repeated_uint64 = 4 [packed = false]; - repeated sint32 repeated_sint32 = 5 [packed = false]; - repeated sint64 repeated_sint64 = 6 [packed = false]; - repeated fixed32 repeated_fixed32 = 7 [packed = false]; - repeated fixed64 repeated_fixed64 = 8 [packed = false]; - repeated sfixed32 repeated_sfixed32 = 9 [packed = false]; + repeated int32 repeated_int32 = 1 [packed = false]; + repeated int64 repeated_int64 = 2 [packed = false]; + repeated uint32 repeated_uint32 = 3 [packed = false]; + repeated uint64 repeated_uint64 = 4 [packed = false]; + repeated sint32 repeated_sint32 = 5 [packed = false]; + repeated sint64 repeated_sint64 = 6 [packed = false]; + repeated fixed32 repeated_fixed32 = 7 [packed = false]; + repeated fixed64 repeated_fixed64 = 8 [packed = false]; + repeated sfixed32 repeated_sfixed32 = 9 [packed = false]; repeated sfixed64 repeated_sfixed64 = 10 [packed = false]; - repeated float repeated_float = 11 [packed = false]; - repeated double repeated_double = 12 [packed = false]; - repeated bool repeated_bool = 13 [packed = false]; + repeated float repeated_float = 11 [packed = false]; + repeated double repeated_double = 12 [packed = false]; + repeated bool repeated_bool = 13 [packed = false]; repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false]; } @@ -201,6 +201,4 @@ enum ForeignEnum { } // TestEmptyMessage is used to test behavior of unknown fields. -message TestEmptyMessage { -} - +message TestEmptyMessage {} diff --git a/src/google/protobuf/unittest_proto3_optional.proto b/src/google/protobuf/unittest_proto3_optional.proto new file mode 100755 index 000000000000..b93e7550b05e --- /dev/null +++ b/src/google/protobuf/unittest_proto3_optional.proto @@ -0,0 +1,73 @@ +// 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. + +syntax = "proto3"; + +package protobuf_unittest; + +option java_multiple_files = true; +option java_package = "com.google.protobuf.testing.proto"; + +message TestProto3Optional { + message NestedMessage { + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + optional int32 bb = 1; + } + + enum NestedEnum { + UNSPECIFIED = 0; + FOO = 1; + BAR = 2; + BAZ = 3; + NEG = -1; // Intentionally negative. + } + + // Singular + optional int32 optional_int32 = 1; + optional int64 optional_int64 = 2; + optional uint32 optional_uint32 = 3; + optional uint64 optional_uint64 = 4; + optional sint32 optional_sint32 = 5; + optional sint64 optional_sint64 = 6; + optional fixed32 optional_fixed32 = 7; + optional fixed64 optional_fixed64 = 8; + optional sfixed32 optional_sfixed32 = 9; + optional sfixed64 optional_sfixed64 = 10; + optional float optional_float = 11; + optional double optional_double = 12; + optional bool optional_bool = 13; + optional string optional_string = 14; + optional bytes optional_bytes = 15; + + optional NestedMessage optional_nested_message = 18; + optional NestedEnum optional_nested_enum = 21; +} diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc index fcffe85fcd6d..451209c79750 100644 --- a/src/google/protobuf/unknown_field_set.cc +++ b/src/google/protobuf/unknown_field_set.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include #include @@ -50,9 +49,9 @@ namespace google { namespace protobuf { -const UnknownFieldSet* UnknownFieldSet::default_instance() { +const UnknownFieldSet& UnknownFieldSet::default_instance() { static auto instance = internal::OnShutdownDelete(new UnknownFieldSet()); - return instance; + return *instance; } void UnknownFieldSet::ClearFallback() { @@ -99,10 +98,9 @@ void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) { other->fields_.clear(); } -void UnknownFieldSet::MergeToInternalMetdata( - const UnknownFieldSet& other, - internal::InternalMetadataWithArena* metadata) { - metadata->mutable_unknown_fields()->MergeFrom(other); +void UnknownFieldSet::MergeToInternalMetadata( + const UnknownFieldSet& other, internal::InternalMetadata* metadata) { + metadata->mutable_unknown_fields()->MergeFrom(other); } size_t UnknownFieldSet::SpaceUsedExcludingSelfLong() const { @@ -279,34 +277,6 @@ uint8* UnknownField::InternalSerializeLengthDelimitedNoTag( } namespace internal { -const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), - InternalMetadataWithArena* metadata, - int field_num) { - return ctx->ReadPackedVarint( - ptr, [object, is_valid, metadata, field_num](uint64 val) { - if (is_valid(val)) { - static_cast*>(object)->Add(val); - } else { - WriteVarint(field_num, val, metadata->mutable_unknown_fields()); - } - }); -} -const char* PackedEnumParserArg(void* object, const char* ptr, - ParseContext* ctx, - bool (*is_valid)(const void*, int), - const void* data, - InternalMetadataWithArena* metadata, - int field_num) { - return ctx->ReadPackedVarint( - ptr, [object, is_valid, data, metadata, field_num](uint64 val) { - if (is_valid(data, val)) { - static_cast*>(object)->Add(val); - } else { - WriteVarint(field_num, val, metadata->mutable_unknown_fields()); - } - }); -} class UnknownFieldParserHelper { public: @@ -352,11 +322,6 @@ const char* UnknownFieldParse(uint64 tag, UnknownFieldSet* unknown, return FieldParser(tag, field_parser, ptr, ctx); } -const char* UnknownFieldParse(uint32 tag, InternalMetadataWithArena* metadata, - const char* ptr, ParseContext* ctx) { - return UnknownFieldParse(tag, metadata->mutable_unknown_fields(), ptr, ctx); -} - } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h index b6134691b19e..ab3633daddd8 100644 --- a/src/google/protobuf/unknown_field_set.h +++ b/src/google/protobuf/unknown_field_set.h @@ -60,7 +60,7 @@ namespace google { namespace protobuf { namespace internal { -class InternalMetadataWithArena; // metadata.h +class InternalMetadata; // metadata_lite.h class WireFormat; // wire_format.h class MessageSetFieldSkipperUsingCord; // extension_set_heavy.cc @@ -104,9 +104,8 @@ class PROTOBUF_EXPORT UnknownFieldSet { // Merge the contents an UnknownFieldSet with the UnknownFieldSet in // *metadata, if there is one. If *metadata doesn't have an UnknownFieldSet // then add one to it and make it be a copy of the first arg. - static void MergeToInternalMetdata( - const UnknownFieldSet& other, - internal::InternalMetadataWithArena* metadata); + static void MergeToInternalMetadata(const UnknownFieldSet& other, + internal::InternalMetadata* metadata); // Swaps the contents of some other UnknownFieldSet with this one. inline void Swap(UnknownFieldSet* x); @@ -173,7 +172,7 @@ class PROTOBUF_EXPORT UnknownFieldSet { template bool MergeFromMessage(const MessageType& message); - static const UnknownFieldSet* default_instance(); + static const UnknownFieldSet& default_instance(); private: // For InternalMergeFrom @@ -218,27 +217,12 @@ inline void WriteLengthDelimited(uint32 num, StringPiece val, unknown->AddLengthDelimited(num)->assign(val.data(), val.size()); } -PROTOBUF_EXPORT -const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), - InternalMetadataWithArena* unknown, int field_num); -PROTOBUF_EXPORT -const char* PackedEnumParserArg(void* object, const char* ptr, - ParseContext* ctx, - bool (*is_valid)(const void*, int), - const void* data, - InternalMetadataWithArena* unknown, - int field_num); - PROTOBUF_EXPORT const char* UnknownGroupParse(UnknownFieldSet* unknown, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT const char* UnknownFieldParse(uint64 tag, UnknownFieldSet* unknown, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT -const char* UnknownFieldParse(uint32 tag, InternalMetadataWithArena* metadata, - const char* ptr, ParseContext* ctx); } // namespace internal diff --git a/src/google/protobuf/unknown_field_set_unittest.cc b/src/google/protobuf/unknown_field_set_unittest.cc index b1ccb5c5a1e4..0083208e4756 100644 --- a/src/google/protobuf/unknown_field_set_unittest.cc +++ b/src/google/protobuf/unknown_field_set_unittest.cc @@ -50,6 +50,7 @@ #include #include #include +#include #include namespace google { diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index d3f347ed32b6..547a4dcc7226 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -30,6 +30,7 @@ #include +#include #include #include diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h index 75ea5206426a..ea6c5cc7e907 100644 --- a/src/google/protobuf/util/field_mask_util.h +++ b/src/google/protobuf/util/field_mask_util.h @@ -55,6 +55,20 @@ class PROTOBUF_EXPORT FieldMaskUtil { static std::string ToString(const FieldMask& mask); static void FromString(StringPiece str, FieldMask* out); + // Populates the FieldMask with the paths corresponding to the fields with the + // given numbers, after checking that all field numbers are valid. + template + static void FromFieldNumbers(const std::vector& field_numbers, + FieldMask* out) { + for (const auto field_number : field_numbers) { + const FieldDescriptor* field_desc = + T::descriptor()->FindFieldByNumber(field_number); + GOOGLE_CHECK(field_desc != nullptr) << "Invalid field number for " + << typeid(T).name() << ": " << field_number; + AddPathToFieldMask(field_desc->lowercase_name(), out); + } + } + // Converts FieldMask to/from string, formatted according to proto3 JSON // spec for FieldMask (e.g., "fooBar,baz.quz"). If the field name is not // style conforming (i.e., not snake_case when converted to string, or not @@ -90,7 +104,7 @@ class PROTOBUF_EXPORT FieldMaskUtil { // This method check-fails if the path is not a valid path for type T. template static void AddPathToFieldMask(StringPiece path, FieldMask* mask) { - GOOGLE_CHECK(IsValidPath(path)); + GOOGLE_CHECK(IsValidPath(path)) << path; mask->add_paths(path); } @@ -180,8 +194,8 @@ class PROTOBUF_EXPORT FieldMaskUtil { static bool SnakeCaseToCamelCase(StringPiece input, std::string* output); // Converts a field name from camelCase to snake_case: - // 1. Every uppercase letter is converted to lowercase with a additional - // preceding "-". + // 1. Every uppercase letter is converted to lowercase with an additional + // preceding "_". // The conversion will fail if: // 1. The field name contains "_"s. // If the conversion succeeds, it's guaranteed that the resulted diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc index 22fe329a5653..5fe9f65bb7ab 100644 --- a/src/google/protobuf/util/field_mask_util_test.cc +++ b/src/google/protobuf/util/field_mask_util_test.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -161,6 +162,20 @@ TEST(FieldMaskUtilTest, JsonStringFormat) { EXPECT_EQ("baz_quz", mask.paths(1)); } +TEST(FieldMaskUtilTest, FromFieldNumbers) { + FieldMask mask; + std::vector field_numbers = { + TestAllTypes::kOptionalInt64FieldNumber, + TestAllTypes::kOptionalBoolFieldNumber, + TestAllTypes::kRepeatedStringFieldNumber, + }; + FieldMaskUtil::FromFieldNumbers(field_numbers, &mask); + ASSERT_EQ(3, mask.paths_size()); + EXPECT_EQ("optional_int64", mask.paths(0)); + EXPECT_EQ("optional_bool", mask.paths(1)); + EXPECT_EQ("repeated_string", mask.paths(2)); +} + TEST(FieldMaskUtilTest, GetFieldDescriptors) { std::vector field_descriptors; EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors( diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 041ff7b74dce..6c18b6cd2123 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -317,7 +317,9 @@ StatusOr DataPiece::ToEnum(const google::protobuf::Enum* enum_type, // If ignore_unknown_enum_values is true an unknown enum value is ignored. if (ignore_unknown_enum_values) { *is_unknown_enum_value = true; - return enum_type->enumvalue(0).number(); + if (enum_type->enumvalue_size() > 0) { + return enum_type->enumvalue(0).number(); + } } } else { // We don't need to check whether the value is actually declared in the diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index a221b98c3133..b94e3c2ed99d 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -86,6 +86,26 @@ inline bool IsKeySeparator(char c) { c == '[' || c == ']' || c == ':' || c == ','); } +inline void ReplaceInvalidCodePoints(StringPiece str, + const std::string& replacement, + std::string* dst) { + while (!str.empty()) { + int n_valid_bytes = internal::UTF8SpnStructurallyValid(str); + StringPiece valid_part = str.substr(0, n_valid_bytes); + StrAppend(dst, valid_part); + + if (n_valid_bytes == str.size()) { + break; + } + + // Append replacement value. + StrAppend(dst, replacement); + + // Move past valid bytes + one invalid byte. + str.remove_prefix(n_valid_bytes + 1); + } +} + static bool ConsumeKey(StringPiece* input, StringPiece* key) { if (input->empty() || !IsLetter((*input)[0])) return false; int len = 1; @@ -132,6 +152,7 @@ JsonStreamParser::JsonStreamParser(ObjectWriter* ow) string_open_(0), chunk_storage_(), coerce_to_utf8_(false), + utf8_replacement_character_(" "), allow_empty_null_(false), allow_permissive_key_naming_(false), loose_float_number_conversion_(false), @@ -180,15 +201,20 @@ util::Status JsonStreamParser::FinishParse() { return util::Status(); } - // Storage for UTF8-coerced string. - std::unique_ptr utf8; - if (coerce_to_utf8_) { - utf8.reset(new char[leftover_.size()]); - char* coerced = internal::UTF8CoerceToStructurallyValid(leftover_, utf8.get(), ' '); - p_ = json_ = StringPiece(coerced, leftover_.size()); + // Lifetime needs to last until RunParser returns, so keep this variable + // outside of the coerce_to_utf8 block. + std::unique_ptr scratch; + + bool is_valid_utf8 = internal::IsStructurallyValidUTF8(leftover_); + if (coerce_to_utf8_ && !is_valid_utf8) { + scratch.reset(new std::string); + scratch->reserve(leftover_.size() * utf8_replacement_character_.size()); + ReplaceInvalidCodePoints(leftover_, utf8_replacement_character_, + scratch.get()); + p_ = json_ = *scratch; } else { p_ = json_ = leftover_; - if (!internal::IsStructurallyValidUTF8(leftover_)) { + if (!is_valid_utf8) { return ReportFailure("Encountered non UTF-8 code points."); } } diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 0292bf26c0f9..c2993e5599e0 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h @@ -269,6 +269,9 @@ class PROTOBUF_EXPORT JsonStreamParser { // Whether to allow non UTF-8 encoded input and replace invalid code points. bool coerce_to_utf8_; + // Replacement character for invalid UTF-8 code points. + std::string utf8_replacement_character_; + // Whether allows empty string represented null array value or object entry // value. bool allow_empty_null_; diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index 6bb22a6c0efe..6638ce88315a 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -32,10 +32,10 @@ #include #include -#include #include #include #include +#include #include diff --git a/src/google/protobuf/util/internal/object_writer.cc b/src/google/protobuf/util/internal/object_writer.cc index bb1b3e5710b0..72f658745b25 100644 --- a/src/google/protobuf/util/internal/object_writer.cc +++ b/src/google/protobuf/util/internal/object_writer.cc @@ -86,6 +86,7 @@ void ObjectWriter::RenderDataPieceTo(const DataPiece& data, } } + } // namespace converter } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/internal/object_writer.h b/src/google/protobuf/util/internal/object_writer.h index 856d77d074fc..29b05c166822 100644 --- a/src/google/protobuf/util/internal/object_writer.h +++ b/src/google/protobuf/util/internal/object_writer.h @@ -42,6 +42,7 @@ namespace protobuf { namespace util { namespace converter { + class DataPiece; // An ObjectWriter is an interface for writing a stream of events @@ -92,7 +93,6 @@ class PROTOBUF_EXPORT ObjectWriter { // Renders a double value. virtual ObjectWriter* RenderDouble(StringPiece name, double value) = 0; - // Renders a float value. virtual ObjectWriter* RenderFloat(StringPiece name, float value) = 0; @@ -111,6 +111,7 @@ class PROTOBUF_EXPORT ObjectWriter { static void RenderDataPieceTo(const DataPiece& data, StringPiece name, ObjectWriter* ow); + // Indicates whether this ObjectWriter has completed writing the root message, // usually this means writing of one complete object. Subclasses must override // this behavior appropriately. diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc index 31288b351e4f..f2ee0224566c 100644 --- a/src/google/protobuf/util/internal/proto_writer.cc +++ b/src/google/protobuf/util/internal/proto_writer.cc @@ -34,13 +34,13 @@ #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -449,7 +449,8 @@ void ProtoWriter::MissingField(StringPiece missing_name) { listener_->MissingField(location(), missing_name); } -ProtoWriter* ProtoWriter::StartObject(StringPiece name) { +ProtoWriter* ProtoWriter::StartObject( + StringPiece name) { // Starting the root message. Create the root ProtoElement and return. if (element_ == nullptr) { if (!name.empty()) { @@ -459,8 +460,8 @@ ProtoWriter* ProtoWriter::StartObject(StringPiece name) { return this; } - const google::protobuf::Field* field = nullptr; - field = BeginNamed(name, false); + const google::protobuf::Field* field = BeginNamed(name, false); + if (field == nullptr) return this; // Check to see if this field is a oneof and that no oneof in that group has @@ -481,6 +482,7 @@ ProtoWriter* ProtoWriter::StartObject(StringPiece name) { return StartObjectField(*field, *type); } + ProtoWriter* ProtoWriter::EndObject() { if (invalid_depth_ > 0) { --invalid_depth_; @@ -500,8 +502,11 @@ ProtoWriter* ProtoWriter::EndObject() { return this; } -ProtoWriter* ProtoWriter::StartList(StringPiece name) { +ProtoWriter* ProtoWriter::StartList( + StringPiece name) { + const google::protobuf::Field* field = BeginNamed(name, true); + if (field == nullptr) return this; if (!ValidOneof(*field, name)) { @@ -520,6 +525,7 @@ ProtoWriter* ProtoWriter::StartList(StringPiece name) { return StartListField(*field, *type); } + ProtoWriter* ProtoWriter::EndList() { if (invalid_depth_ > 0) { --invalid_depth_; @@ -529,12 +535,13 @@ ProtoWriter* ProtoWriter::EndList() { return this; } -ProtoWriter* ProtoWriter::RenderDataPiece(StringPiece name, - const DataPiece& data) { +ProtoWriter* ProtoWriter::RenderDataPiece( + StringPiece name, const DataPiece& data) { Status status; if (invalid_depth_ > 0) return this; const google::protobuf::Field* field = Lookup(name); + if (field == nullptr) return this; if (!ValidOneof(*field, name)) return this; diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h index f81117364adf..7e79ce31e845 100644 --- a/src/google/protobuf/util/internal/proto_writer.h +++ b/src/google/protobuf/util/internal/proto_writer.h @@ -49,6 +49,7 @@ #include #include +// Must be included last. #include namespace google { @@ -56,6 +57,7 @@ namespace protobuf { namespace util { namespace converter { + class ObjectLocationTracker; // An ObjectWriter that can write protobuf bytes directly from writer events. @@ -102,10 +104,12 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { return RenderDataPiece(name, DataPiece(value, use_strict_base64_decoding())); } + ProtoWriter* RenderBytes(StringPiece name, StringPiece value) override { return RenderDataPiece( name, DataPiece(value, false, use_strict_base64_decoding())); } + ProtoWriter* RenderNull(StringPiece name) override { return RenderDataPiece(name, DataPiece::NullData()); } @@ -114,7 +118,8 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { // Renders a DataPiece 'value' into a field whose wire type is determined // from the given field 'name'. virtual ProtoWriter* RenderDataPiece(StringPiece name, - const DataPiece& value); + const DataPiece& data); + // Returns the location tracker to use for tracking locations for errors. const LocationTrackerInterface& location() { @@ -299,7 +304,7 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { // Renders a primitive field given the field and the enclosing type. ProtoWriter* RenderPrimitiveField(const google::protobuf::Field& field, const google::protobuf::Type& type, - const DataPiece& value); + const DataPiece& data); private: // Writes an ENUM field, including tag, to the stream. diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 4fc026fa81b0..fad62f5a233e 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,7 @@ #include #include #include +#include #include #include @@ -201,14 +201,14 @@ Status ProtoStreamObjectSource::WriteMessage(const google::protobuf::Type& type, uint32 tag = stream_->ReadTag(), last_tag = tag + 1; UnknownFieldSet unknown_fields; - if (tag == end_tag && suppress_empty_object_) { + if (!name.empty() && tag == end_tag && suppress_empty_object_) { return util::Status(); } if (include_start_and_end) { ow->StartObject(name); } - while (tag != end_tag) { + while (tag != end_tag && tag != 0) { if (tag != last_tag) { // Update field only if tag is changed. last_tag = tag; field = FindAndVerifyField(type, tag); diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 0b89ae297247..752c3f0b779d 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include @@ -480,6 +480,7 @@ bool ProtoStreamObjectWriter::Item::InsertMapKeyIfNotPresent( return InsertIfNotPresent(map_keys_.get(), std::string(map_key)); } + ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject( StringPiece name) { if (invalid_depth() > 0) { @@ -583,6 +584,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject( } const google::protobuf::Field* field = BeginNamed(name, false); + if (field == nullptr) return this; if (IsStruct(*field)) { @@ -648,6 +650,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::EndObject() { return this; } + ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartList( StringPiece name) { if (invalid_depth() > 0) { @@ -796,6 +799,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartList( // name is not empty const google::protobuf::Field* field = Lookup(name); + if (field == nullptr) { IncrementInvalidDepth(); return this; @@ -1217,7 +1221,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece( // Map of functions that are responsible for rendering well known type // represented by the key. std::unordered_map* - ProtoStreamObjectWriter::renderers_ = NULL; + ProtoStreamObjectWriter::renderers_ = nullptr; PROTOBUF_NAMESPACE_ID::internal::once_flag writer_renderers_init_; void ProtoStreamObjectWriter::InitRendererMap() { @@ -1272,7 +1276,7 @@ void ProtoStreamObjectWriter::InitRendererMap() { void ProtoStreamObjectWriter::DeleteRendererMap() { delete ProtoStreamObjectWriter::renderers_; - renderers_ = NULL; + renderers_ = nullptr; } ProtoStreamObjectWriter::TypeRenderer* @@ -1296,9 +1300,9 @@ bool ProtoStreamObjectWriter::ValidMapKey(StringPiece unnormalized_name) { return true; } -void ProtoStreamObjectWriter::Push(StringPiece name, - Item::ItemType item_type, - bool is_placeholder, bool is_list) { +void ProtoStreamObjectWriter::Push( + StringPiece name, Item::ItemType item_type, bool is_placeholder, + bool is_list) { is_list ? ProtoWriter::StartList(name) : ProtoWriter::StartObject(name); // invalid_depth == 0 means it is a successful StartObject or StartList. diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.h b/src/google/protobuf/util/internal/protostream_objectwriter.h index 5fb23a993de5..f3aeb61f11fb 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.h +++ b/src/google/protobuf/util/internal/protostream_objectwriter.h @@ -116,7 +116,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { } }; -// Constructor. Does not take ownership of any parameter passed in. + // Constructor. Does not take ownership of any parameter passed in. ProtoStreamObjectWriter(TypeResolver* type_resolver, const google::protobuf::Type& type, strings::ByteSink* output, ErrorListener* listener, @@ -241,7 +241,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { int depth_; // True if the type is a well-known type. Well-known types in Any - // has a special formating: + // has a special formatting: // { // "@type": "type.googleapis.com/google.protobuf.XXX", // "value": , @@ -347,24 +347,24 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { // Renders google.protobuf.Value in struct.proto. It picks the right oneof // type based on value's type. static util::Status RenderStructValue(ProtoStreamObjectWriter* ow, - const DataPiece& value); + const DataPiece& data); // Renders google.protobuf.Timestamp value. static util::Status RenderTimestamp(ProtoStreamObjectWriter* ow, - const DataPiece& value); + const DataPiece& data); // Renders google.protobuf.FieldMask value. static util::Status RenderFieldMask(ProtoStreamObjectWriter* ow, - const DataPiece& value); + const DataPiece& data); // Renders google.protobuf.Duration value. static util::Status RenderDuration(ProtoStreamObjectWriter* ow, - const DataPiece& value); + const DataPiece& data); // Renders wrapper message types for primitive types in // google/protobuf/wrappers.proto. static util::Status RenderWrapperType(ProtoStreamObjectWriter* ow, - const DataPiece& value); + const DataPiece& data); static void InitRendererMap(); static void DeleteRendererMap(); @@ -387,6 +387,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { void Push(StringPiece name, Item::ItemType item_type, bool is_placeholder, bool is_list); + // Pops items from the stack. All placeholder items are popped until a // non-placeholder item is found. void Pop(); diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc index 6b22b5286709..b1d76a5a0f0e 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +65,7 @@ namespace protobuf { namespace util { namespace converter { + using proto_util_converter::testing::AnyM; using proto_util_converter::testing::AnyOut; using proto_util_converter::testing::Author; @@ -278,6 +281,7 @@ TEST_P(ProtoStreamObjectWriterTest, ConflictingJsonName) { CheckOutput(message2); } + TEST_P(ProtoStreamObjectWriterTest, IntEnumValuesAreAccepted) { Book book; book.set_title("Some Book"); @@ -2537,7 +2541,7 @@ TEST_P(ProtoStreamObjectWriterFieldMaskTest, SimpleFieldMaskTest) { CheckOutput(expected); } -TEST_P(ProtoStreamObjectWriterFieldMaskTest, MutipleMasksInCompactForm) { +TEST_P(ProtoStreamObjectWriterFieldMaskTest, MultipleMasksInCompactForm) { FieldMaskTest expected; expected.set_id("1"); expected.mutable_single_mask()->add_paths("camel_case1"); diff --git a/src/google/protobuf/util/internal/testdata/books.proto b/src/google/protobuf/util/internal/testdata/books.proto index 4f02ae1444c8..328c5ce0d74a 100644 --- a/src/google/protobuf/util/internal/testdata/books.proto +++ b/src/google/protobuf/util/internal/testdata/books.proto @@ -34,6 +34,7 @@ // Some of the older enums don't use CAPITALS_WITH_UNDERSCORES for testing. // LINT: LEGACY_NAMES +// LINT: ALLOW_GROUPS syntax = "proto2"; @@ -212,3 +213,39 @@ message TestJsonName1 { message TestJsonName2 { optional int32 another_value = 1 [json_name = "value"]; } + +message TestPrimitiveFieldsWithSameJsonName { + optional string val_str1 = 1; + optional string val_str_1 = 2; + + optional int32 val_int321 = 3; + optional int32 val_int32_1 = 4; + + optional uint32 val_uint321 = 5; + optional uint32 val_uint32_1 = 6; + + optional int64 val_int641 = 7; + optional int64 val_int64_1 = 8; + + optional uint64 val_uint641 = 9; + optional uint64 val_uint64_1 = 10; + + optional bool val_bool1 = 11; + optional bool val_bool_1 = 12; + + optional double val_double1 = 13; + optional double val_double_1 = 14; + + optional float val_float1 = 15; + optional float val_float_1 = 16; +} + +message TestRepeatedFieldsWithSameJsonName { + repeated string rep_str1 = 1; + repeated string rep_str_1 = 2; +} + +message TestMessageFieldsWithSameJsonName { + optional Primitive prim1 = 1; + optional Primitive prim_1 = 2; +} diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 26fb8999f363..f5e0860c1c99 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -576,12 +576,12 @@ bool MessageDifferencer::Compare(const Message& message1, bool unknown_compare_result = true; // Ignore unknown fields in EQUIVALENT mode if (message_field_comparison_ != EQUIVALENT) { - const UnknownFieldSet* unknown_field_set1 = - &reflection1->GetUnknownFields(message1); - const UnknownFieldSet* unknown_field_set2 = - &reflection2->GetUnknownFields(message2); - if (!CompareUnknownFields(message1, message2, *unknown_field_set1, - *unknown_field_set2, parent_fields)) { + const UnknownFieldSet& unknown_field_set1 = + reflection1->GetUnknownFields(message1); + const UnknownFieldSet& unknown_field_set2 = + reflection2->GetUnknownFields(message2); + if (!CompareUnknownFields(message1, message2, unknown_field_set1, + unknown_field_set2, parent_fields)) { if (reporter_ == NULL) { return false; } @@ -1243,7 +1243,7 @@ bool MessageDifferencer::UnpackAny(const Message& any, } data->reset(dynamic_message_factory_->GetPrototype(desc)->New()); std::string serialized_value = reflection->GetString(any, value_field); - if (!(*data)->ParseFromString(serialized_value)) { + if (!(*data)->ParsePartialFromString(serialized_value)) { GOOGLE_DLOG(ERROR) << "Failed to parse value for " << full_type_name; return false; } diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index 21cf374dd0e7..f7317c80feb3 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -225,6 +225,19 @@ class PROTOBUF_EXPORT MessageDifferencer { // FieldDescriptors. The first will be the field of the embedded message // itself and the second will be the actual field in the embedded message // that was added/deleted/modified. + // Fields will be reported in PostTraversalOrder. + // For example, given following proto, if both baz and quux are changed. + // foo { + // bar { + // baz: 1 + // quux: 2 + // } + // } + // ReportModified will be invoked with following order: + // 1. foo.bar.baz or foo.bar.quux + // 2. foo.bar.quux or foo.bar.baz + // 2. foo.bar + // 3. foo class PROTOBUF_EXPORT Reporter { public: Reporter(); diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index b57062ad6227..637d4d3c0c68 100644 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -3444,6 +3444,7 @@ TEST_F(MatchingTest, ReportMatchedForMovedFields) { RunWithResult(&differencer, msg1, msg2, true)); } + TEST_F(MatchingTest, MatchesAppearInPostTraversalOrderForMovedFields) { protobuf_unittest::TestDiffMessage msg1, msg2; protobuf_unittest::TestDiffMessage::Item* item; diff --git a/src/google/protobuf/util/time_util.cc b/src/google/protobuf/util/time_util.cc index e61562733de9..4b80e7ca66d0 100644 --- a/src/google/protobuf/util/time_util.cc +++ b/src/google/protobuf/util/time_util.cc @@ -30,13 +30,14 @@ #include -#include #include #include -#include #include #include +#include +#include +// Must go after other includes. #include namespace google { diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc index f60b774f3bf7..444510c560b3 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ #include #include #include +#include #include #include @@ -653,6 +655,379 @@ bool WireFormat::ParseAndMergeMessageSetItem(io::CodedInputStream* input, input, MSReflective{message->GetReflection(), message}); } +struct WireFormat::MessageSetParser { + const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) { + // Parse a MessageSetItem + auto metadata = reflection->MutableInternalMetadata(msg); + std::string payload; + uint32 type_id = 0; + while (!ctx->Done(&ptr)) { + // We use 64 bit tags in order to allow typeid's that span the whole + // range of 32 bit numbers. + uint32 tag = static_cast(*ptr++); + if (tag == WireFormatLite::kMessageSetTypeIdTag) { + uint64 tmp; + ptr = ParseBigVarint(ptr, &tmp); + GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); + type_id = tmp; + if (!payload.empty()) { + const FieldDescriptor* field; + if (ctx->data().pool == nullptr) { + field = reflection->FindKnownExtensionByNumber(type_id); + } else { + field = + ctx->data().pool->FindExtensionByNumber(descriptor, type_id); + } + if (field == nullptr || field->message_type() == nullptr) { + WriteLengthDelimited( + type_id, payload, + metadata->mutable_unknown_fields()); + } else { + Message* value = + field->is_repeated() + ? reflection->AddMessage(msg, field, ctx->data().factory) + : reflection->MutableMessage(msg, field, + ctx->data().factory); + const char* p; + // We can't use regular parse from string as we have to track + // proper recursion depth and descriptor pools. + ParseContext tmp_ctx(ctx->depth(), false, &p, payload); + tmp_ctx.data().pool = ctx->data().pool; + tmp_ctx.data().factory = ctx->data().factory; + GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) && + tmp_ctx.EndedAtLimit()); + } + type_id = 0; + } + continue; + } else if (tag == WireFormatLite::kMessageSetMessageTag) { + if (type_id == 0) { + int32 size = ReadSize(&ptr); + GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); + ptr = ctx->ReadString(ptr, size, &payload); + GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); + } else { + // We're now parsing the payload + const FieldDescriptor* field = nullptr; + if (descriptor->IsExtensionNumber(type_id)) { + if (ctx->data().pool == nullptr) { + field = reflection->FindKnownExtensionByNumber(type_id); + } else { + field = + ctx->data().pool->FindExtensionByNumber(descriptor, type_id); + } + } + ptr = WireFormat::_InternalParseAndMergeField( + msg, ptr, ctx, static_cast(type_id) * 8 + 2, reflection, + field); + type_id = 0; + } + } else { + // An unknown field in MessageSetItem. + ptr = ReadTag(ptr - 1, &tag); + if (tag == 0 || (tag & 7) == WireFormatLite::WIRETYPE_END_GROUP) { + ctx->SetLastTag(tag); + return ptr; + } + // Skip field. + ptr = internal::UnknownFieldParse( + tag, static_cast(nullptr), ptr, ctx); + } + GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); + } + return ptr; + } + + const char* ParseMessageSet(const char* ptr, internal::ParseContext* ctx) { + while (!ctx->Done(&ptr)) { + uint32 tag; + ptr = ReadTag(ptr, &tag); + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr; + if (tag == 0 || (tag & 7) == WireFormatLite::WIRETYPE_END_GROUP) { + ctx->SetLastTag(tag); + break; + } + if (tag == WireFormatLite::kMessageSetItemStartTag) { + // A message set item starts + ptr = ctx->ParseGroup(this, ptr, tag); + } else { + // Parse other fields as normal extensions. + int field_number = WireFormatLite::GetTagFieldNumber(tag); + const FieldDescriptor* field = nullptr; + if (descriptor->IsExtensionNumber(field_number)) { + if (ctx->data().pool == nullptr) { + field = reflection->FindKnownExtensionByNumber(field_number); + } else { + field = ctx->data().pool->FindExtensionByNumber(descriptor, + field_number); + } + } + ptr = WireFormat::_InternalParseAndMergeField(msg, ptr, ctx, tag, + reflection, field); + } + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr; + } + return ptr; + } + + Message* msg; + const Descriptor* descriptor; + const Reflection* reflection; +}; + +const char* WireFormat::_InternalParse(Message* msg, const char* ptr, + internal::ParseContext* ctx) { + const Descriptor* descriptor = msg->GetDescriptor(); + const Reflection* reflection = msg->GetReflection(); + GOOGLE_DCHECK(descriptor); + GOOGLE_DCHECK(reflection); + if (descriptor->options().message_set_wire_format()) { + MessageSetParser message_set{msg, descriptor, reflection}; + return message_set.ParseMessageSet(ptr, ctx); + } + while (!ctx->Done(&ptr)) { + uint32 tag; + ptr = ReadTag(ptr, &tag); + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr; + if (tag == 0 || (tag & 7) == WireFormatLite::WIRETYPE_END_GROUP) { + ctx->SetLastTag(tag); + break; + } + const FieldDescriptor* field = nullptr; + + int field_number = WireFormatLite::GetTagFieldNumber(tag); + field = descriptor->FindFieldByNumber(field_number); + + // If that failed, check if the field is an extension. + if (field == nullptr && descriptor->IsExtensionNumber(field_number)) { + if (ctx->data().pool == nullptr) { + field = reflection->FindKnownExtensionByNumber(field_number); + } else { + field = + ctx->data().pool->FindExtensionByNumber(descriptor, field_number); + } + } + + ptr = _InternalParseAndMergeField(msg, ptr, ctx, tag, reflection, field); + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr; + } + return ptr; +} + +const char* WireFormat::_InternalParseAndMergeField( + Message* msg, const char* ptr, internal::ParseContext* ctx, uint64 tag, + const Reflection* reflection, const FieldDescriptor* field) { + if (field == nullptr) { + // unknown field set parser takes 64bit tags, because message set type ids + // span the full 32 bit range making the tag span [0, 2^35) range. + return internal::UnknownFieldParse( + tag, reflection->MutableUnknownFields(msg), ptr, ctx); + } + if (WireFormatLite::GetTagWireType(tag) != + WireTypeForFieldType(field->type())) { + if (field->is_packable() && WireFormatLite::GetTagWireType(tag) == + WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + switch (field->type()) { +#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ + case FieldDescriptor::TYPE_##TYPE: { \ + ptr = internal::Packed##CPPTYPE_METHOD##Parser( \ + reflection->MutableRepeatedFieldInternal(msg, field), ptr, \ + ctx); \ + return ptr; \ + } + + HANDLE_PACKED_TYPE(INT32, int32, Int32) + HANDLE_PACKED_TYPE(INT64, int64, Int64) + HANDLE_PACKED_TYPE(SINT32, int32, SInt32) + HANDLE_PACKED_TYPE(SINT64, int64, SInt64) + HANDLE_PACKED_TYPE(UINT32, uint32, UInt32) + HANDLE_PACKED_TYPE(UINT64, uint64, UInt64) + + HANDLE_PACKED_TYPE(FIXED32, uint32, Fixed32) + HANDLE_PACKED_TYPE(FIXED64, uint64, Fixed64) + HANDLE_PACKED_TYPE(SFIXED32, int32, SFixed32) + HANDLE_PACKED_TYPE(SFIXED64, int64, SFixed64) + + HANDLE_PACKED_TYPE(FLOAT, float, Float) + HANDLE_PACKED_TYPE(DOUBLE, double, Double) + + HANDLE_PACKED_TYPE(BOOL, bool, Bool) +#undef HANDLE_PACKED_TYPE + + case FieldDescriptor::TYPE_ENUM: { + auto rep_enum = + reflection->MutableRepeatedFieldInternal(msg, field); + bool open_enum = false; + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 || + open_enum) { + ptr = internal::PackedEnumParser(rep_enum, ptr, ctx); + } else { + return ctx->ReadPackedVarint( + ptr, [rep_enum, field, reflection, msg](uint64 val) { + if (field->enum_type()->FindValueByNumber(val) != nullptr) { + rep_enum->Add(val); + } else { + WriteVarint(field->number(), val, + reflection->MutableUnknownFields(msg)); + } + }); + } + return ptr; + } + + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_GROUP: + case FieldDescriptor::TYPE_MESSAGE: + case FieldDescriptor::TYPE_BYTES: + GOOGLE_LOG(FATAL) << "Can't reach"; + return nullptr; + } + } else { + // mismatched wiretype; + return internal::UnknownFieldParse( + tag, reflection->MutableUnknownFields(msg), ptr, ctx); + } + } + + // Non-packed value + bool utf8_check = false; + bool strict_utf8_check = false; + switch (field->type()) { +#define HANDLE_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ + case FieldDescriptor::TYPE_##TYPE: { \ + CPPTYPE value; \ + ptr = VarintParse(ptr, &value); \ + if (ptr == nullptr) return nullptr; \ + if (field->is_repeated()) { \ + reflection->Add##CPPTYPE_METHOD(msg, field, value); \ + } else { \ + reflection->Set##CPPTYPE_METHOD(msg, field, value); \ + } \ + return ptr; \ + } + + HANDLE_TYPE(BOOL, uint64, Bool) + HANDLE_TYPE(INT32, uint32, Int32) + HANDLE_TYPE(INT64, uint64, Int64) + HANDLE_TYPE(UINT32, uint32, UInt32) + HANDLE_TYPE(UINT64, uint64, UInt64) + + case FieldDescriptor::TYPE_SINT32: { + int32 value = ReadVarintZigZag32(&ptr); + if (ptr == nullptr) return nullptr; + if (field->is_repeated()) { + reflection->AddInt32(msg, field, value); + } else { + reflection->SetInt32(msg, field, value); + } + return ptr; + } + case FieldDescriptor::TYPE_SINT64: { + int64 value = ReadVarintZigZag64(&ptr); + if (ptr == nullptr) return nullptr; + if (field->is_repeated()) { + reflection->AddInt64(msg, field, value); + } else { + reflection->SetInt64(msg, field, value); + } + return ptr; + } +#undef HANDLE_TYPE +#define HANDLE_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ + case FieldDescriptor::TYPE_##TYPE: { \ + CPPTYPE value; \ + value = UnalignedLoad(ptr); \ + ptr += sizeof(CPPTYPE); \ + if (field->is_repeated()) { \ + reflection->Add##CPPTYPE_METHOD(msg, field, value); \ + } else { \ + reflection->Set##CPPTYPE_METHOD(msg, field, value); \ + } \ + return ptr; \ + } + + HANDLE_TYPE(FIXED32, uint32, UInt32) + HANDLE_TYPE(FIXED64, uint64, UInt64) + HANDLE_TYPE(SFIXED32, int32, Int32) + HANDLE_TYPE(SFIXED64, int64, Int64) + + HANDLE_TYPE(FLOAT, float, Float) + HANDLE_TYPE(DOUBLE, double, Double) + +#undef HANDLE_TYPE + + case FieldDescriptor::TYPE_ENUM: { + uint32 value; + ptr = VarintParse(ptr, &value); + if (ptr == nullptr) return nullptr; + if (field->is_repeated()) { + reflection->AddEnumValue(msg, field, value); + } else { + reflection->SetEnumValue(msg, field, value); + } + return ptr; + } + + // Handle strings separately so that we can optimize the ctype=CORD case. + case FieldDescriptor::TYPE_STRING: + utf8_check = true; + strict_utf8_check = StrictUtf8Check(field); + PROTOBUF_FALLTHROUGH_INTENDED; + case FieldDescriptor::TYPE_BYTES: { + int size = ReadSize(&ptr); + if (ptr == nullptr) return nullptr; + std::string value; + ptr = ctx->ReadString(ptr, size, &value); + if (ptr == nullptr) return nullptr; + if (utf8_check) { + if (strict_utf8_check) { + if (!WireFormatLite::VerifyUtf8String(value.data(), value.length(), + WireFormatLite::PARSE, + field->full_name().c_str())) { + return nullptr; + } + } else { + VerifyUTF8StringNamedField(value.data(), value.length(), PARSE, + field->full_name().c_str()); + } + } + if (field->is_repeated()) { + reflection->AddString(msg, field, value); + } else { + reflection->SetString(msg, field, value); + } + return ptr; + } + + case FieldDescriptor::TYPE_GROUP: { + Message* sub_message; + if (field->is_repeated()) { + sub_message = reflection->AddMessage(msg, field, ctx->data().factory); + } else { + sub_message = + reflection->MutableMessage(msg, field, ctx->data().factory); + } + + return ctx->ParseGroup(sub_message, ptr, tag); + } + + case FieldDescriptor::TYPE_MESSAGE: { + Message* sub_message; + if (field->is_repeated()) { + sub_message = reflection->AddMessage(msg, field, ctx->data().factory); + } else { + sub_message = + reflection->MutableMessage(msg, field, ctx->data().factory); + } + return ctx->ParseMessage(sub_message, ptr); + } + } + + // GCC 8 complains about control reaching end of non-void function here. + // Let's keep it happy by returning a nullptr. + return nullptr; +} + // =================================================================== uint8* WireFormat::_InternalSerialize(const Message& message, uint8* target, @@ -1359,9 +1734,11 @@ size_t WireFormat::MessageSetItemByteSize(const FieldDescriptor* field, } // Compute the size of the UnknownFieldSet on the wire. -size_t ComputeUnknownFieldsSize(const InternalMetadataWithArena& metadata, +size_t ComputeUnknownFieldsSize(const InternalMetadata& metadata, size_t total_size, CachedSize* cached_size) { - total_size += WireFormat::ComputeUnknownFieldsSize(metadata.unknown_fields()); + total_size += WireFormat::ComputeUnknownFieldsSize( + metadata.unknown_fields( + UnknownFieldSet::default_instance)); cached_size->Set(ToCachedSize(total_size)); return total_size; } diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index c88f3dae0c91..d42cefb65c28 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -42,9 +42,12 @@ #include #include +#include #include #include +#include #include +#include #include #include @@ -106,6 +109,11 @@ class PROTOBUF_EXPORT WireFormat { static bool ParseAndMergePartial(io::CodedInputStream* input, Message* message); + // This is meant for internal protobuf use (WireFormat is an internal class). + // This is the reflective implementation of the _InternalParse functionality. + static const char* _InternalParse(Message* msg, const char* ptr, + internal::ParseContext* ctx); + // Serialize a message in protocol buffer wire format. // // Any embedded messages within the message must have their correct sizes @@ -275,6 +283,7 @@ class PROTOBUF_EXPORT WireFormat { Operation op, const char* field_name); private: + struct MessageSetParser; // Skip a MessageSet field. static bool SkipMessageSetField(io::CodedInputStream* input, uint32 field_number, @@ -285,6 +294,12 @@ class PROTOBUF_EXPORT WireFormat { const FieldDescriptor* field, Message* message, io::CodedInputStream* input); + // Parses the value from the wire that belongs to tag. + static const char* _InternalParseAndMergeField(Message* msg, const char* ptr, + internal::ParseContext* ctx, + uint64 tag, + const Reflection* reflection, + const FieldDescriptor* field); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormat); }; @@ -380,8 +395,8 @@ inline size_t ComputeUnknownMessageSetItemsSize( // Compute the size of the UnknownFieldSet on the wire. PROTOBUF_EXPORT -size_t ComputeUnknownFieldsSize(const InternalMetadataWithArena& metadata, - size_t size, CachedSize* cached_size); +size_t ComputeUnknownFieldsSize(const InternalMetadata& metadata, size_t size, + CachedSize* cached_size); } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index aa2a1adbd44e..d022e42bdc53 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -49,6 +49,7 @@ #include #include #include +#include // Do UTF-8 validation on string type in Debug build only #ifndef NDEBUG @@ -806,39 +807,19 @@ inline size_t WireFormatLite::TagSize(int field_number, } inline uint32 WireFormatLite::EncodeFloat(float value) { - union { - float f; - uint32 i; - }; - f = value; - return i; + return bit_cast(value); } inline float WireFormatLite::DecodeFloat(uint32 value) { - union { - float f; - uint32 i; - }; - i = value; - return f; + return bit_cast(value); } inline uint64 WireFormatLite::EncodeDouble(double value) { - union { - double f; - uint64 i; - }; - f = value; - return i; + return bit_cast(value); } inline double WireFormatLite::DecodeDouble(uint64 value) { - union { - double f; - uint64 i; - }; - i = value; - return f; + return bit_cast(value); } // ZigZag Transform: Encodes signed integers so that they can be diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc index ff502d6ddf34..24cb58f6296d 100644 --- a/src/google/protobuf/wire_format_unittest.cc +++ b/src/google/protobuf/wire_format_unittest.cc @@ -33,6 +33,10 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include + +#include +#include +#include #include #include #include @@ -40,11 +44,9 @@ #include #include #include +#include #include - -#include -#include -#include +#include #include #include #include diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index abb68fae7903..be039b420a3f 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -290,9 +290,8 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo &scc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once; -static bool descriptor_table_google_2fprotobuf_2fwrappers_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto = { - &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_initialized, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, "google/protobuf/wrappers.proto", 447, + false, false, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, "google/protobuf/wrappers.proto", 447, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, descriptor_table_google_2fprotobuf_2fwrappers_2eproto_sccs, descriptor_table_google_2fprotobuf_2fwrappers_2eproto_deps, 9, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, 9, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto, file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto, @@ -310,22 +309,15 @@ class DoubleValue::_Internal { public: }; -DoubleValue::DoubleValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue) -} DoubleValue::DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue) } DoubleValue::DoubleValue(const DoubleValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue) } @@ -337,10 +329,11 @@ void DoubleValue::SharedCtor() { DoubleValue::~DoubleValue() { // @@protoc_insertion_point(destructor:google.protobuf.DoubleValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void DoubleValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void DoubleValue::ArenaDtor(void* object) { @@ -365,12 +358,12 @@ void DoubleValue::Clear() { (void) cached_has_bits; value_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* DoubleValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -389,7 +382,9 @@ const char* DoubleValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -417,7 +412,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* DoubleValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DoubleValue) return target; @@ -463,7 +458,7 @@ void DoubleValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void DoubleValue::MergeFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -492,7 +487,7 @@ bool DoubleValue::IsInitialized() const { void DoubleValue::InternalSwap(DoubleValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -509,22 +504,15 @@ class FloatValue::_Internal { public: }; -FloatValue::FloatValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.FloatValue) -} FloatValue::FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue) } FloatValue::FloatValue(const FloatValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue) } @@ -536,10 +524,11 @@ void FloatValue::SharedCtor() { FloatValue::~FloatValue() { // @@protoc_insertion_point(destructor:google.protobuf.FloatValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void FloatValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void FloatValue::ArenaDtor(void* object) { @@ -564,12 +553,12 @@ void FloatValue::Clear() { (void) cached_has_bits; value_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* FloatValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -588,7 +577,9 @@ const char* FloatValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -616,7 +607,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* FloatValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FloatValue) return target; @@ -662,7 +653,7 @@ void FloatValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void FloatValue::MergeFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -691,7 +682,7 @@ bool FloatValue::IsInitialized() const { void FloatValue::InternalSwap(FloatValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -708,22 +699,15 @@ class Int64Value::_Internal { public: }; -Int64Value::Int64Value() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Int64Value) -} Int64Value::Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value) } Int64Value::Int64Value(const Int64Value& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value) } @@ -735,10 +719,11 @@ void Int64Value::SharedCtor() { Int64Value::~Int64Value() { // @@protoc_insertion_point(destructor:google.protobuf.Int64Value) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Int64Value::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void Int64Value::ArenaDtor(void* object) { @@ -763,12 +748,12 @@ void Int64Value::Clear() { (void) cached_has_bits; value_ = PROTOBUF_LONGLONG(0); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Int64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -787,7 +772,9 @@ const char* Int64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -815,7 +802,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Int64Value::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int64Value) return target; @@ -863,7 +850,7 @@ void Int64Value::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Int64Value::MergeFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -892,7 +879,7 @@ bool Int64Value::IsInitialized() const { void Int64Value::InternalSwap(Int64Value* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -909,22 +896,15 @@ class UInt64Value::_Internal { public: }; -UInt64Value::UInt64Value() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value) -} UInt64Value::UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value) } UInt64Value::UInt64Value(const UInt64Value& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value) } @@ -936,10 +916,11 @@ void UInt64Value::SharedCtor() { UInt64Value::~UInt64Value() { // @@protoc_insertion_point(destructor:google.protobuf.UInt64Value) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void UInt64Value::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void UInt64Value::ArenaDtor(void* object) { @@ -964,12 +945,12 @@ void UInt64Value::Clear() { (void) cached_has_bits; value_ = PROTOBUF_ULONGLONG(0); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* UInt64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -988,7 +969,9 @@ const char* UInt64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1016,7 +999,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* UInt64Value::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt64Value) return target; @@ -1064,7 +1047,7 @@ void UInt64Value::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void UInt64Value::MergeFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1093,7 +1076,7 @@ bool UInt64Value::IsInitialized() const { void UInt64Value::InternalSwap(UInt64Value* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -1110,22 +1093,15 @@ class Int32Value::_Internal { public: }; -Int32Value::Int32Value() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.Int32Value) -} Int32Value::Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value) } Int32Value::Int32Value(const Int32Value& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value) } @@ -1137,10 +1113,11 @@ void Int32Value::SharedCtor() { Int32Value::~Int32Value() { // @@protoc_insertion_point(destructor:google.protobuf.Int32Value) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void Int32Value::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void Int32Value::ArenaDtor(void* object) { @@ -1165,12 +1142,12 @@ void Int32Value::Clear() { (void) cached_has_bits; value_ = 0; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Int32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1189,7 +1166,9 @@ const char* Int32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1217,7 +1196,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* Int32Value::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int32Value) return target; @@ -1265,7 +1244,7 @@ void Int32Value::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void Int32Value::MergeFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1294,7 +1273,7 @@ bool Int32Value::IsInitialized() const { void Int32Value::InternalSwap(Int32Value* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -1311,22 +1290,15 @@ class UInt32Value::_Internal { public: }; -UInt32Value::UInt32Value() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value) -} UInt32Value::UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value) } UInt32Value::UInt32Value(const UInt32Value& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value) } @@ -1338,10 +1310,11 @@ void UInt32Value::SharedCtor() { UInt32Value::~UInt32Value() { // @@protoc_insertion_point(destructor:google.protobuf.UInt32Value) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void UInt32Value::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void UInt32Value::ArenaDtor(void* object) { @@ -1366,12 +1339,12 @@ void UInt32Value::Clear() { (void) cached_has_bits; value_ = 0u; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* UInt32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1390,7 +1363,9 @@ const char* UInt32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1418,7 +1393,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* UInt32Value::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt32Value) return target; @@ -1466,7 +1441,7 @@ void UInt32Value::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void UInt32Value::MergeFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1495,7 +1470,7 @@ bool UInt32Value::IsInitialized() const { void UInt32Value::InternalSwap(UInt32Value* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -1512,22 +1487,15 @@ class BoolValue::_Internal { public: }; -BoolValue::BoolValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.BoolValue) -} BoolValue::BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue) } BoolValue::BoolValue(const BoolValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue) } @@ -1539,10 +1507,11 @@ void BoolValue::SharedCtor() { BoolValue::~BoolValue() { // @@protoc_insertion_point(destructor:google.protobuf.BoolValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void BoolValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); } void BoolValue::ArenaDtor(void* object) { @@ -1567,12 +1536,12 @@ void BoolValue::Clear() { (void) cached_has_bits; value_ = false; - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* BoolValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1591,7 +1560,9 @@ const char* BoolValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1619,7 +1590,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* BoolValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BoolValue) return target; @@ -1665,7 +1636,7 @@ void BoolValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void BoolValue::MergeFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1694,7 +1665,7 @@ bool BoolValue::IsInitialized() const { void BoolValue::InternalSwap(BoolValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); swap(value_, other->value_); } @@ -1711,26 +1682,19 @@ class StringValue::_Internal { public: }; -StringValue::StringValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.StringValue) -} StringValue::StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue) } StringValue::StringValue(const StringValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_value().empty()) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_value(), - GetArenaNoVirtual()); + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) } @@ -1743,10 +1707,11 @@ void StringValue::SharedCtor() { StringValue::~StringValue() { // @@protoc_insertion_point(destructor:google.protobuf.StringValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void StringValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -1771,13 +1736,13 @@ void StringValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - _internal_metadata_.Clear(); + value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* StringValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1798,7 +1763,9 @@ const char* StringValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -1830,7 +1797,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* StringValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.StringValue) return target; @@ -1878,7 +1845,7 @@ void StringValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void StringValue::MergeFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1907,9 +1874,8 @@ bool StringValue::IsInitialized() const { void StringValue::InternalSwap(StringValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const { @@ -1925,26 +1891,19 @@ class BytesValue::_Internal { public: }; -BytesValue::BytesValue() - : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.BytesValue) -} BytesValue::BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue) } BytesValue::BytesValue(const BytesValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _internal_metadata_(nullptr) { - _internal_metadata_.MergeFrom(from._internal_metadata_); + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_value().empty()) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_value(), - GetArenaNoVirtual()); + GetArena()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) } @@ -1957,10 +1916,11 @@ void BytesValue::SharedCtor() { BytesValue::~BytesValue() { // @@protoc_insertion_point(destructor:google.protobuf.BytesValue) SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } void BytesValue::SharedDtor() { - GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); + GOOGLE_DCHECK(GetArena() == nullptr); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -1985,13 +1945,13 @@ void BytesValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - _internal_metadata_.Clear(); + value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* BytesValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -2011,7 +1971,9 @@ const char* BytesValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID: ctx->SetLastTag(tag); goto success; } - ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); CHK_(ptr != nullptr); continue; } @@ -2039,7 +2001,7 @@ ::PROTOBUF_NAMESPACE_ID::uint8* BytesValue::_InternalSerialize( if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target, stream); + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BytesValue) return target; @@ -2087,7 +2049,7 @@ void BytesValue::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { void BytesValue::MergeFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue) GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2116,9 +2078,8 @@ bool BytesValue::IsInitialized() const { void BytesValue::InternalSwap(BytesValue* other) { using std::swap; - _internal_metadata_.Swap(&other->_internal_metadata_); - value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } ::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const { diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index dd03416d58b9..5779c559c744 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include // IWYU pragma: export @@ -98,10 +98,10 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT DoubleValue : +class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ { public: - DoubleValue(); + inline DoubleValue() : DoubleValue(nullptr) {}; virtual ~DoubleValue(); DoubleValue(const DoubleValue& from); @@ -115,7 +115,7 @@ class PROTOBUF_EXPORT DoubleValue : return *this; } inline DoubleValue& operator=(DoubleValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -123,12 +123,6 @@ class PROTOBUF_EXPORT DoubleValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -153,7 +147,7 @@ class PROTOBUF_EXPORT DoubleValue : } inline void Swap(DoubleValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -161,7 +155,7 @@ class PROTOBUF_EXPORT DoubleValue : } void UnsafeArenaSwap(DoubleValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -201,13 +195,6 @@ class PROTOBUF_EXPORT DoubleValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -239,7 +226,6 @@ class PROTOBUF_EXPORT DoubleValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -249,10 +235,10 @@ class PROTOBUF_EXPORT DoubleValue : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FloatValue : +class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ { public: - FloatValue(); + inline FloatValue() : FloatValue(nullptr) {}; virtual ~FloatValue(); FloatValue(const FloatValue& from); @@ -266,7 +252,7 @@ class PROTOBUF_EXPORT FloatValue : return *this; } inline FloatValue& operator=(FloatValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -274,12 +260,6 @@ class PROTOBUF_EXPORT FloatValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -304,7 +284,7 @@ class PROTOBUF_EXPORT FloatValue : } inline void Swap(FloatValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -312,7 +292,7 @@ class PROTOBUF_EXPORT FloatValue : } void UnsafeArenaSwap(FloatValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -352,13 +332,6 @@ class PROTOBUF_EXPORT FloatValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -390,7 +363,6 @@ class PROTOBUF_EXPORT FloatValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -400,10 +372,10 @@ class PROTOBUF_EXPORT FloatValue : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Int64Value : +class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ { public: - Int64Value(); + inline Int64Value() : Int64Value(nullptr) {}; virtual ~Int64Value(); Int64Value(const Int64Value& from); @@ -417,7 +389,7 @@ class PROTOBUF_EXPORT Int64Value : return *this; } inline Int64Value& operator=(Int64Value&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -425,12 +397,6 @@ class PROTOBUF_EXPORT Int64Value : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -455,7 +421,7 @@ class PROTOBUF_EXPORT Int64Value : } inline void Swap(Int64Value* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -463,7 +429,7 @@ class PROTOBUF_EXPORT Int64Value : } void UnsafeArenaSwap(Int64Value* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -503,13 +469,6 @@ class PROTOBUF_EXPORT Int64Value : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -541,7 +500,6 @@ class PROTOBUF_EXPORT Int64Value : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -551,10 +509,10 @@ class PROTOBUF_EXPORT Int64Value : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT UInt64Value : +class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ { public: - UInt64Value(); + inline UInt64Value() : UInt64Value(nullptr) {}; virtual ~UInt64Value(); UInt64Value(const UInt64Value& from); @@ -568,7 +526,7 @@ class PROTOBUF_EXPORT UInt64Value : return *this; } inline UInt64Value& operator=(UInt64Value&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -576,12 +534,6 @@ class PROTOBUF_EXPORT UInt64Value : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -606,7 +558,7 @@ class PROTOBUF_EXPORT UInt64Value : } inline void Swap(UInt64Value* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -614,7 +566,7 @@ class PROTOBUF_EXPORT UInt64Value : } void UnsafeArenaSwap(UInt64Value* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -654,13 +606,6 @@ class PROTOBUF_EXPORT UInt64Value : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -692,7 +637,6 @@ class PROTOBUF_EXPORT UInt64Value : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -702,10 +646,10 @@ class PROTOBUF_EXPORT UInt64Value : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Int32Value : +class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ { public: - Int32Value(); + inline Int32Value() : Int32Value(nullptr) {}; virtual ~Int32Value(); Int32Value(const Int32Value& from); @@ -719,7 +663,7 @@ class PROTOBUF_EXPORT Int32Value : return *this; } inline Int32Value& operator=(Int32Value&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -727,12 +671,6 @@ class PROTOBUF_EXPORT Int32Value : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -757,7 +695,7 @@ class PROTOBUF_EXPORT Int32Value : } inline void Swap(Int32Value* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -765,7 +703,7 @@ class PROTOBUF_EXPORT Int32Value : } void UnsafeArenaSwap(Int32Value* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -805,13 +743,6 @@ class PROTOBUF_EXPORT Int32Value : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -843,7 +774,6 @@ class PROTOBUF_EXPORT Int32Value : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -853,10 +783,10 @@ class PROTOBUF_EXPORT Int32Value : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT UInt32Value : +class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ { public: - UInt32Value(); + inline UInt32Value() : UInt32Value(nullptr) {}; virtual ~UInt32Value(); UInt32Value(const UInt32Value& from); @@ -870,7 +800,7 @@ class PROTOBUF_EXPORT UInt32Value : return *this; } inline UInt32Value& operator=(UInt32Value&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -878,12 +808,6 @@ class PROTOBUF_EXPORT UInt32Value : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -908,7 +832,7 @@ class PROTOBUF_EXPORT UInt32Value : } inline void Swap(UInt32Value* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -916,7 +840,7 @@ class PROTOBUF_EXPORT UInt32Value : } void UnsafeArenaSwap(UInt32Value* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -956,13 +880,6 @@ class PROTOBUF_EXPORT UInt32Value : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -994,7 +911,6 @@ class PROTOBUF_EXPORT UInt32Value : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1004,10 +920,10 @@ class PROTOBUF_EXPORT UInt32Value : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT BoolValue : +class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ { public: - BoolValue(); + inline BoolValue() : BoolValue(nullptr) {}; virtual ~BoolValue(); BoolValue(const BoolValue& from); @@ -1021,7 +937,7 @@ class PROTOBUF_EXPORT BoolValue : return *this; } inline BoolValue& operator=(BoolValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1029,12 +945,6 @@ class PROTOBUF_EXPORT BoolValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1059,7 +969,7 @@ class PROTOBUF_EXPORT BoolValue : } inline void Swap(BoolValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1067,7 +977,7 @@ class PROTOBUF_EXPORT BoolValue : } void UnsafeArenaSwap(BoolValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1107,13 +1017,6 @@ class PROTOBUF_EXPORT BoolValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1145,7 +1048,6 @@ class PROTOBUF_EXPORT BoolValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1155,10 +1057,10 @@ class PROTOBUF_EXPORT BoolValue : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT StringValue : +class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ { public: - StringValue(); + inline StringValue() : StringValue(nullptr) {}; virtual ~StringValue(); StringValue(const StringValue& from); @@ -1172,7 +1074,7 @@ class PROTOBUF_EXPORT StringValue : return *this; } inline StringValue& operator=(StringValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1180,12 +1082,6 @@ class PROTOBUF_EXPORT StringValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1210,7 +1106,7 @@ class PROTOBUF_EXPORT StringValue : } inline void Swap(StringValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1218,7 +1114,7 @@ class PROTOBUF_EXPORT StringValue : } void UnsafeArenaSwap(StringValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1258,13 +1154,6 @@ class PROTOBUF_EXPORT StringValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1312,7 +1201,6 @@ class PROTOBUF_EXPORT StringValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1322,10 +1210,10 @@ class PROTOBUF_EXPORT StringValue : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT BytesValue : +class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ { public: - BytesValue(); + inline BytesValue() : BytesValue(nullptr) {}; virtual ~BytesValue(); BytesValue(const BytesValue& from); @@ -1339,7 +1227,7 @@ class PROTOBUF_EXPORT BytesValue : return *this; } inline BytesValue& operator=(BytesValue&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (GetArena() == from.GetArena()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); @@ -1347,12 +1235,6 @@ class PROTOBUF_EXPORT BytesValue : return *this; } - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArena() const final { - return GetArenaNoVirtual(); - } - inline void* GetMaybeArenaPointer() const final { - return MaybeArenaPtr(); - } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -1377,7 +1259,7 @@ class PROTOBUF_EXPORT BytesValue : } inline void Swap(BytesValue* other) { if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + if (GetArena() == other->GetArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1385,7 +1267,7 @@ class PROTOBUF_EXPORT BytesValue : } void UnsafeArenaSwap(BytesValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + GOOGLE_DCHECK(GetArena() == other->GetArena()); InternalSwap(other); } @@ -1425,13 +1307,6 @@ class PROTOBUF_EXPORT BytesValue : private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); - } - inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); - } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; @@ -1479,7 +1354,6 @@ class PROTOBUF_EXPORT BytesValue : private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -1668,7 +1542,7 @@ inline void BoolValue::set_value(bool value) { // string value = 1; inline void StringValue::clear_value() { - value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) @@ -1687,36 +1561,36 @@ inline const std::string& StringValue::_internal_value() const { } inline void StringValue::_internal_set_value(const std::string& value) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void StringValue::set_value(std::string&& value) { value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.StringValue.value) } inline void StringValue::set_value(const char* value) { GOOGLE_DCHECK(value != nullptr); value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.StringValue.value) } inline void StringValue::set_value(const char* value, size_t size) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value) } inline std::string* StringValue::_internal_mutable_value() { - return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* StringValue::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value) - return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void StringValue::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -1725,26 +1599,26 @@ inline void StringValue::set_allocated_value(std::string* value) { } value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) } inline std::string* StringValue::unsafe_arena_release_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void StringValue::unsafe_arena_set_allocated_value( std::string* value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (value != nullptr) { } else { } value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - value, GetArenaNoVirtual()); + value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value) } @@ -1754,7 +1628,7 @@ inline void StringValue::unsafe_arena_set_allocated_value( // bytes value = 1; inline void BytesValue::clear_value() { - value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline const std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) @@ -1773,36 +1647,36 @@ inline const std::string& BytesValue::_internal_value() const { } inline void BytesValue::_internal_set_value(const std::string& value) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } inline void BytesValue::set_value(std::string&& value) { value_.Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.BytesValue.value) } inline void BytesValue::set_value(const char* value) { GOOGLE_DCHECK(value != nullptr); value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_char:google.protobuf.BytesValue.value) } inline void BytesValue::set_value(const void* value, size_t size) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size), GetArenaNoVirtual()); + reinterpret_cast(value), size), GetArena()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value) } inline std::string* BytesValue::_internal_mutable_value() { - return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline std::string* BytesValue::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value) - return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } inline void BytesValue::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -1811,26 +1685,26 @@ inline void BytesValue::set_allocated_value(std::string* value) { } value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArenaNoVirtual()); + GetArena()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) } inline std::string* BytesValue::unsafe_arena_release_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value) - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); return value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); + GetArena()); } inline void BytesValue::unsafe_arena_set_allocated_value( std::string* value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != nullptr); + GOOGLE_DCHECK(GetArena() != nullptr); if (value != nullptr) { } else { } value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - value, GetArenaNoVirtual()); + value, GetArena()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) }