aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2024-06-25 08:50:35 +0300
committermikhnenko <mikhnenko@yandex-team.com>2024-06-25 09:00:27 +0300
commit509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194 (patch)
tree4b8a6a44009906ac852e59efa0bc78bb12043a5b /contrib
parent7688f2313619a39a60ef3c2734d8efbc49a0a6db (diff)
downloadydb-509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194.tar.gz
Update protobuf to 3.20.2 and pyprotobuf to 3.20.3
Если это pull-request что-то сломал, то: - если это тест с канонизацией и еще нет pr с переканонизацией, то переканонизируйте пожалуйста сами - проверьте, что тест не флапает - приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) - там вам обязательно помогут 987be5ed151f827f7f292f32420470b04b71a91d
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libs/protobuf/CHANGES.txt200
-rw-r--r--contrib/libs/protobuf/CONTRIBUTORS.txt5
-rw-r--r--contrib/libs/protobuf/src/README.md2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.cc5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.pb.cc118
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.pb.h48
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.proto6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any_lite.cc11
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/api.pb.cc330
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/api.pb.h136
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena.cc50
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena.h94
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_impl.h125
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenastring.cc250
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenastring.h467
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc177
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h208
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.cc2116
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.h79
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc2419
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h898
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.proto16
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc17
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor_database.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/duration.pb.cc78
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/duration.pb.h18
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc61
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/dynamic_message.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/empty.pb.cc49
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/empty.pb.h17
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h10
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set.cc330
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set.h152
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc114
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set_inl.h29
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc74
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h18
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc317
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h21
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.cc103
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.h351
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc106
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.h874
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_decl.h193
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_full.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.h562
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.inc92
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_lite.cc1480
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc376
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_util.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/has_bits.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc29
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h43
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc52
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h370
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc17
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h48
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc3
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/io_win32.h2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/printer.cc7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/printer.h2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.h11
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h27
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc11
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map.h17
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_entry.h36
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h285
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field.cc25
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field.h69
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field_lite.h59
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_type_handler.h57
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message.cc9
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message.h22
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message_lite.cc25
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message_lite.h26
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/metadata_lite.h41
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/parse_context.cc19
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/parse_context.h55
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/port.h44
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/port_def.inc135
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/port_undef.inc19
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection.h2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc19
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection_ops.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_field.cc11
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_field.h339
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc43
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h1128
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/service.h2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc89
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/source_context.pb.h33
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/struct.pb.cc264
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/struct.pb.h56
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/common.h8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc9
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/text_format.cc72
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/text_format.h4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc78
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h18
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/type.pb.cc473
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/type.pb.h167
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc18
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h18
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h3
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.cc8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.h5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h12
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h10
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc16
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h15
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc28
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc19
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h9
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/json_util.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/json_util.h5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc40
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/time_util.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/time_util.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.cc4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.h1
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format.cc79
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc52
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h70
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc432
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h88
-rw-r--r--contrib/libs/protobuf/ya.make32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc54
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc68
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc38
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc48
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc278
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc26
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h64
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc175
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc1026
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h29
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc258
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc1302
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h91
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc79
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h11
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc264
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h13
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h21
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/importer.cc36
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/importer.h8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc13
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc22
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc54
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc36
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc27
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc51
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/main.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc25
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h14
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc46
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc107
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h18
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc40
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc231
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc27
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc43
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h18
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h18
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.cc73
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.h9
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc97
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc360
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h152
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc271
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h24
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc138
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h62
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc558
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h104
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/scc.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc65
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h1
-rw-r--r--contrib/libs/protoc/ya.make27
-rw-r--r--contrib/python/protobuf/py3/.dist-info/METADATA8
-rw-r--r--contrib/python/protobuf/py3/README.md2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/__init__.py2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/descriptor.py52
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py16
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc17
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/builder.py130
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/containers.py279
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py75
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/well_known_types.py47
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/json_format.py288
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/message.py3
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/proto_api.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc1062
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc804
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc12
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h12
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc306
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc189
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/field.cc95
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/field.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc179
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message.cc880
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc127
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc19
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.cc66
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.cc5
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/scoped_pyobject_ptr.h7
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc227
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h1
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/service_reflection.py32
-rw-r--r--contrib/python/protobuf/py3/ya.make5
-rw-r--r--contrib/tools/protoc/ya.make.induced_deps2
331 files changed, 16467 insertions, 14453 deletions
diff --git a/contrib/libs/protobuf/CHANGES.txt b/contrib/libs/protobuf/CHANGES.txt
index db6194529d..61ab0b8994 100644
--- a/contrib/libs/protobuf/CHANGES.txt
+++ b/contrib/libs/protobuf/CHANGES.txt
@@ -1,3 +1,201 @@
+2022-09-13 version 20.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
+
+
+2022-04-05 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ PHP
+ * Fix building packaged PHP extension (#9727)
+ * Fixed composer.json to only advertise compatibility with PHP 7.0+. (#9819)
+
+ Ruby
+ * Disable the aarch64 build on macOS until it can be fixed. (#9816)
+
+ Other
+ * Fix versioning issues in 3.20.0
+
+2022-03-04 version 3.20.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Ruby
+ * Dropped Ruby 2.3 and 2.4 support for CI and releases. (#9311)
+ * Added Ruby 3.1 support for CI and releases (#9566).
+ * Message.decode/encode: Add recursion_limit option (#9218/#9486)
+ * Allocate with xrealloc()/xfree() so message allocation is visible to the
+ Ruby GC. In certain tests this leads to much lower memory usage due to more
+ frequent GC runs (#9586).
+ * Fix conversion of singleton classes in Ruby (#9342)
+ * Suppress warning for intentional circular require (#9556)
+ * JSON will now output shorter strings for double and float fields when possible
+ without losing precision.
+ * Encoding and decoding of binary format will now work properly on big-endian
+ systems.
+ * UTF-8 verification was fixed to properly reject surrogate code points.
+ * Unknown enums for proto2 protos now properly implement proto2's behavior of
+ putting such values in unknown fields.
+
+ Java
+ * Revert "Standardize on Array copyOf" (#9400)
+ * Resolve more java field accessor name conflicts (#8198)
+ * Don't support map fields in DynamicMessage.Builder.{getFieldBuilder,getRepeatedFieldBuilder}
+ * Fix parseFrom to only throw InvalidProtocolBufferException
+ * InvalidProtocolBufferException now allows arbitrary wrapped Exception types.
+ * Fix bug in `FieldSet.Builder.mergeFrom`
+ * Flush CodedOutputStream also flushes underlying OutputStream
+ * When oneof case is the same and the field type is Message, merge the
+ subfield. (previously it was replaced.)’
+ * Add @CheckReturnValue to some protobuf types
+ * Report original exceptions when parsing JSON
+ * Add more info to @deprecated javadoc for set/get/has methods
+ * Fix initialization bug in doc comment line numbers
+ * Fix comments for message set wire format.
+
+ Kotlin
+ * Add test scope to kotlin-test for protobuf-kotlin-lite (#9518)
+ * Add orNull extensions for optional message fields.
+ * Add orNull extensions to all proto3 message fields.
+
+ Python
+ * Dropped support for Python < 3.7 (#9480)
+ * Protoc is now able to generate python stubs (.pyi) with --pyi_out
+ * Pin multibuild scripts to get manylinux1 wheels back (#9216)
+ * Fix type annotations of some Duration and Timestamp methods.
+ * Repeated field containers are now generic in field types and could be used
+ in type annotations.
+ * Protobuf python generated codes are simplified. Descriptors and message
+ classes' definitions are now dynamic created in internal/builder.py.
+ Insertion Points for messages classes are discarded.
+ * has_presence is added for FieldDescriptor in python
+ * Loosen indexing type requirements to allow valid __index__() implementations
+ rather than only PyLongObjects.
+ * Fix the deepcopy bug caused by not copying message_listener.
+ * Added python JSON parse recursion limit (default 100)
+ * Path info is added for python JSON parse errors
+ * Pure python repeated scalar fields will not able to pickle. Convert to list
+ first.
+ * Timestamp.ToDatetime() now accepts an optional tzinfo parameter. If
+ specified, the function returns a timezone-aware datetime in the given time
+ zone. If omitted or None, the function returns a timezone-naive UTC datetime
+ (as previously).
+ * Adds client_streaming and server_streaming fields to MethodDescriptor.
+ * Add "ensure_ascii" parameter to json_format.MessageToJson. This allows smaller
+ JSON serializations with UTF-8 or other non-ASCII encodings.
+ * Added experimental support for directly assigning numpy scalars and array.
+ * Improve the calculation of public_dependencies in DescriptorPool.
+ * [Breaking Change] Disallow setting fields to numpy singleton arrays or repeated fields to numpy
+ multi-dimensional arrays. Numpy arrays should be indexed or flattened explicitly before assignment.
+
+ Compiler
+ * Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
+ * Implement strong qualified tags for TaggedPtr
+ * Rework allocations to power-of-two byte sizes.
+ * Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
+ * Implement strong qualified tags for TaggedPtr
+ * Make TaggedPtr Set...() calls explicitly spell out the content type.
+ * Check for parsing error before verifying UTF8.
+ * Enforce a maximum message nesting limit of 32 in the descriptor builder to
+ guard against stack overflows
+ * Fixed bugs in operators for RepeatedPtrIterator
+ * Assert a maximum map alignment for allocated values
+ * Fix proto1 group extension protodb parsing error
+ * Do not log/report the same descriptor symbol multiple times if it contains
+ more than one invalid character.
+ * Add UnknownFieldSet::SerializeToString and SerializeToCodedStream.
+ * Remove explicit default pointers and deprecated API from protocol compiler
+
+ Arenas
+ * Change Repeated*Field to reuse memory when using arenas.
+ * Implements pbarenaz for profiling proto arenas
+ * Introduce CreateString() and CreateArenaString() for cleaner semantics
+ * Fix unreferenced parameter for MSVC builds
+ * Add UnsafeSetAllocated to be used for one-of string fields.
+ * Make Arena::AllocateAligned() a public function.
+ * Determine if ArenaDtor related code generation is necessary in one place.
+ * Implement on demand register ArenaDtor for InlinedStringField
+
+ C++
+ * Enable testing via CTest (#8737)
+ * Add option to use external GTest in CMake (#8736)
+ * CMake: Set correct sonames for libprotobuf-lite.so and libprotoc.so (#8635) (#9529)
+ * Add cmake option `protobuf_INSTALL` to not install files (#7123)
+ * CMake: Allow custom plugin options e.g. to generate mocks (#9105)
+ * CMake: Use linker version scripts (#9545)
+ * Manually *struct Cord fields to work better with arenas.
+ * Manually destruct map fields.
+ * Generate narrower code
+ * Fix https://github.com/protocolbuffers/protobuf/issues/9378 by removing
+ shadowed _cached_size_ field
+ * Remove GetPointer() and explicit nullptr defaults.
+ * Add proto_h flag for speeding up large builds
+ * Add missing overload for reference wrapped fields.
+ * Add MergedDescriptorDatabase::FindAllFileNames()
+ * RepeatedField now defines an iterator type instead of using a pointer.
+ * Remove obsolete macros GOOGLE_PROTOBUF_HAS_ONEOF and GOOGLE_PROTOBUF_HAS_ARENAS.
+
+ PHP
+ * Fix: add missing reserved classnames (#9458)
+ * PHP 8.1 compatibility (#9370)
+
+ C#
+ * Fix trim warnings (#9182)
+ * Fixes NullReferenceException when accessing FieldDescriptor.IsPacked (#9430)
+ * Add ToProto() method to all descriptor classes (#9426)
+ * Add an option to preserve proto names in JsonFormatter (#6307)
+
+ Objective-C
+ * Add prefix_to_proto_package_mappings_path option. (#9498)
+ * Rename `proto_package_to_prefix_mappings_path` to `package_to_prefix_mappings_path`. (#9552)
+ * Add a generation option to control use of forward declarations in headers. (#9568)
+
+2022-01-28 version 3.19.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Python
+ * Make libprotobuf symbols local on OSX to fix issue #9395 (#9435)
+
+ Ruby
+ * Fixed a data loss bug that could occur when the number of `optional`
+ fields in a message is an exact multiple of 32. (#9440).
+
+ PHP
+ * Fixed a data loss bug that could occur when the number of `optional`
+ fields in a message is an exact multiple of 32. (#9440).
+
+2022-01-10 version 3.19.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Python
+ * Fix missing Windows wheel for Python 3.10 on PyPI
+
+2022-01-05 version 3.19.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Java
+ * Improve performance characteristics of UnknownFieldSet parsing (#9371)
+ * This release addresses a Security Advisory for Java users
+ (https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-wrvw-hg22-4m67)
+
+2022-01-05 version 3.18.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Java
+ * Improve performance characteristics of UnknownFieldSet parsing (#9371)
+ * This release addresses a Security Advisory for Java users
+ (https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-wrvw-hg22-4m67)
+
+2022-01-05 version 3.16.1 (Java)
+
+ Java
+ * Improve performance characteristics of UnknownFieldSet parsing (#9371)
+ * This release addresses a Security Advisory for Java users
+ (https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-wrvw-hg22-4m67)
+
+2021-10-28 version 3.19.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Bazel
+ * Ensure that release archives contain everything needed for Bazel (#9131)
+ * Align dependency handling with Bazel best practices (#9165)
+
+ JavaScript
+ * Fix `ReferenceError: window is not defined` when getting the global object (#9156)
+
+ Ruby
+ * Fix memory leak in MessageClass.encode (#9150)
+
2021-10-15 version 3.19.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++
@@ -17,6 +215,7 @@
Kotlin
* Switch Kotlin proto DSLs to be implemented with inline value classes
+ * Fix inlining and deprecation for repeated string fields in kotlin (#9120)
Python
* Proto2 DecodeError now includes message name in error message
@@ -37,6 +236,7 @@
* Add class method Timestamp.from_time to ruby well known types (#8562)
* Adopt pure ruby DSL implementation for JRuby (#9047)
* Add size to Map class (#8068)
+ * Fix for descriptor_pb.rb: google/protobuf should be required first (#9121)
C#
* Correctly set ExtensionRegistry when parsing with MessageParser, but using an already existing CodedInputStream (#7246)
diff --git a/contrib/libs/protobuf/CONTRIBUTORS.txt b/contrib/libs/protobuf/CONTRIBUTORS.txt
index b8d97fc23d..c2da98f2c6 100644
--- a/contrib/libs/protobuf/CONTRIBUTORS.txt
+++ b/contrib/libs/protobuf/CONTRIBUTORS.txt
@@ -100,3 +100,8 @@ Patch contributors:
Andrew Paprocki <andrew@ishiboo.com>
* Fixed minor IBM xlC compiler build issues
* Added atomicops for AIX (POWER)
+ Nipunn Koorapati <nipunn1313@gmail.com>
+ * Provide a type alias field ValueType on EnumTypeWrapper
+ * Match service argument names to abstract interface
+
+
diff --git a/contrib/libs/protobuf/src/README.md b/contrib/libs/protobuf/src/README.md
index 9db40fdde4..80e8668d99 100644
--- a/contrib/libs/protobuf/src/README.md
+++ b/contrib/libs/protobuf/src/README.md
@@ -48,7 +48,7 @@ Buffer compiler (protoc) execute the following:
./configure
- make
+ make -j$(nproc) # $(nproc) ensures it uses all cores for compilation
make check
sudo make install
sudo ldconfig # refresh shared library cache.
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.cc b/contrib/libs/protobuf/src/google/protobuf/any.cc
index 73c002f604..346fa19f17 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/any.cc
@@ -35,6 +35,7 @@
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -48,10 +49,8 @@ bool AnyMetadata::PackFrom(Arena* arena, const Message& message) {
bool AnyMetadata::PackFrom(Arena* arena, const Message& message,
StringPiece type_url_prefix) {
type_url_->Set(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(),
GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena);
- return message.SerializeToString(
- value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena));
+ return message.SerializeToString(value_->Mutable(arena));
}
bool AnyMetadata::UnpackTo(Message* message) const {
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.h b/contrib/libs/protobuf/src/google/protobuf/any.h
index 3b9e81d2ff..dbe7e31012 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.h
+++ b/contrib/libs/protobuf/src/google/protobuf/any.h
@@ -37,6 +37,7 @@
#include <google/protobuf/arenastring.h>
#include <google/protobuf/message_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.pb.cc b/contrib/libs/protobuf/src/google/protobuf/any.pb.cc
index eb5dac86cc..709b7f2b5e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/any.pb.cc
@@ -16,25 +16,33 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
+#if defined(__llvm__)
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wuninitialized"
+#endif // __llvm__
PROTOBUF_NAMESPACE_OPEN
-constexpr Any::Any(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_CONSTEXPR Any::Any(
+ ::_pbi::ConstantInitialized)
+ : type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, _any_metadata_(&type_url_, &value_){}
struct AnyDefaultTypeInternal {
- constexpr AnyDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR AnyDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~AnyDefaultTypeInternal() {}
union {
Any _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT AnyDefaultTypeInternal _Any_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 AnyDefaultTypeInternal _Any_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -46,12 +54,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_S
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, type_url_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, value_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Any)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Any_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Any_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -62,19 +70,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_
"anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT"
"ypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = {
- false, false, 212, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto",
- &descriptor_table_google_2fprotobuf_2fany_2eproto_once, nullptr, 0, 1,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = {
+ false, false, 212, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto,
+ "google/protobuf/any.proto",
+ &descriptor_table_google_2fprotobuf_2fany_2eproto_once, nullptr, 0, 1,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fany_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fany_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fany_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fany_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -83,14 +93,13 @@ bool Any::GetAnyFieldDescriptors(
const ::PROTOBUF_NAMESPACE_ID::Message& message,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** value_field) {
- return ::PROTOBUF_NAMESPACE_ID::internal::GetAnyFieldDescriptors(
+ return ::_pbi::GetAnyFieldDescriptors(
message, type_url_field, value_field);
}
bool Any::ParseAnyTypeUrl(
::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,
TProtoStringType* full_type_name) {
- return ::PROTOBUF_NAMESPACE_ID::internal::ParseAnyTypeUrl(type_url,
- full_type_name);
+ return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);
}
class Any::_Internal {
@@ -102,64 +111,57 @@ Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_any_metadata_(&type_url_, &value_) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Any)
}
Any::Any(const Any& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_any_metadata_(&type_url_, &value_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_type_url().empty()) {
- type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(),
+ type_url_.Set(from._internal_type_url(),
GetArenaForAllocation());
}
- value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
+ value_.Set(from._internal_value(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
}
inline void Any::SharedCtor() {
-type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Any::~Any() {
// @@protoc_insertion_point(destructor:google.protobuf.Any)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Any::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ type_url_.Destroy();
+ value_.Destroy();
}
-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);
}
@@ -175,19 +177,19 @@ void Any::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Any::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string type_url = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_type_url();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Any.type_url"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Any.type_url"));
} else
goto handle_unusual;
continue;
@@ -195,7 +197,7 @@ const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
} else
goto handle_unusual;
@@ -246,7 +248,7 @@ uint8_t* Any::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -323,19 +325,17 @@ void Any::InternalSwap(Any* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&type_url_, lhs_arena,
&other->type_url_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, lhs_arena,
&other->value_, rhs_arena
);
}
::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once,
file_level_metadata_google_2fprotobuf_2fany_2eproto[0]);
}
@@ -343,10 +343,14 @@ void Any::InternalSwap(Any* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Any*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Any >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
+#if defined(__llvm__)
+ #pragma clang diagnostic pop
+#endif // __llvm__
#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.pb.h b/contrib/libs/protobuf/src/google/protobuf/any.pb.h
index 833596f47e..1c07b71241 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/any.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto;
@@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Any final :
public:
inline Any() : Any(nullptr) {}
~Any() override;
- explicit constexpr Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Any(const Any& from);
Any(Any&& from) noexcept
@@ -205,9 +196,6 @@ class PROTOBUF_EXPORT Any final :
protected:
explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -287,7 +275,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Any::set_type_url(ArgT0&& arg0, ArgT... args) {
- type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
}
inline TProtoStringType* Any::mutable_type_url() {
@@ -300,15 +288,15 @@ inline const TProtoStringType& Any::_internal_type_url() const {
}
inline void Any::_internal_set_type_url(const TProtoStringType& value) {
- type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Any::_internal_mutable_type_url() {
- return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return type_url_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Any::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)
- return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return type_url_.Release();
}
inline void Any::set_allocated_type_url(TProtoStringType* type_url) {
if (type_url != nullptr) {
@@ -316,11 +304,10 @@ inline void Any::set_allocated_type_url(TProtoStringType* type_url) {
} else {
}
- type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url,
- GetArenaForAllocation());
+ type_url_.SetAllocated(type_url, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (type_url_.IsDefault()) {
+ type_url_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
@@ -338,7 +325,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Any::set_value(ArgT0&& arg0, ArgT... args) {
- value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
}
inline TProtoStringType* Any::mutable_value() {
@@ -351,15 +338,15 @@ inline const TProtoStringType& Any::_internal_value() const {
}
inline void Any::_internal_set_value(const TProtoStringType& value) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Any::_internal_mutable_value() {
- return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Any::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.value)
- return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return value_.Release();
}
inline void Any::set_allocated_value(TProtoStringType* value) {
if (value != nullptr) {
@@ -367,11 +354,10 @@ inline void Any::set_allocated_value(TProtoStringType* value) {
} else {
}
- value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
- GetArenaForAllocation());
+ value_.SetAllocated(value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (value_.IsDefault()) {
+ value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.proto b/contrib/libs/protobuf/src/google/protobuf/any.proto
index 6ed8a23cf5..e2c2042fdc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/any.proto
@@ -64,7 +64,7 @@ option objc_class_prefix = "GPB";
// foo = any.unpack(Foo.class);
// }
//
-// Example 3: Pack and unpack a message in Python.
+// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
@@ -74,7 +74,7 @@ option objc_class_prefix = "GPB";
// any.Unpack(foo)
// ...
//
-// Example 4: Pack and unpack a message in Go
+// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := anypb.New(foo)
@@ -95,7 +95,7 @@ option objc_class_prefix = "GPB";
//
//
// JSON
-// ====
+//
// The JSON representation of an `Any` value uses the regular
// representation of the deserialized, embedded message, with an
// additional field `@type` which contains the type URL. Example:
diff --git a/contrib/libs/protobuf/src/google/protobuf/any_lite.cc b/contrib/libs/protobuf/src/google/protobuf/any_lite.cc
index 5be2d7c401..387b6b7708 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/any_lite.cc
@@ -28,12 +28,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/any.h>
-
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/any.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -56,10 +55,8 @@ const char kTypeGoogleProdComPrefix[] = "type.googleprod.com/";
bool AnyMetadata::InternalPackFrom(Arena* arena, const MessageLite& message,
StringPiece type_url_prefix,
StringPiece type_name) {
- type_url_->Set(&::google::protobuf::internal::GetEmptyString(),
- GetTypeUrl(type_name, type_url_prefix), arena);
- return message.SerializeToString(
- value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena));
+ type_url_->Set(GetTypeUrl(type_name, type_url_prefix), arena);
+ return message.SerializeToString(value_->Mutable(arena));
}
bool AnyMetadata::InternalUnpackTo(StringPiece type_name,
diff --git a/contrib/libs/protobuf/src/google/protobuf/api.pb.cc b/contrib/libs/protobuf/src/google/protobuf/api.pb.cc
index bdaaa52ae1..8c84e4755c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/api.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/api.pb.cc
@@ -16,62 +16,66 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr Api::Api(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR Api::Api(
+ ::_pbi::ConstantInitialized)
: methods_()
, options_()
, mixins_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , version_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , version_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, source_context_(nullptr)
, syntax_(0)
{}
struct ApiDefaultTypeInternal {
- constexpr ApiDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ApiDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~ApiDefaultTypeInternal() {}
union {
Api _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ApiDefaultTypeInternal _Api_default_instance_;
-constexpr Method::Method(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ApiDefaultTypeInternal _Api_default_instance_;
+PROTOBUF_CONSTEXPR Method::Method(
+ ::_pbi::ConstantInitialized)
: options_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , request_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , response_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , request_type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , response_type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, request_streaming_(false)
, response_streaming_(false)
, syntax_(0)
{}
struct MethodDefaultTypeInternal {
- constexpr MethodDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MethodDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~MethodDefaultTypeInternal() {}
union {
Method _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MethodDefaultTypeInternal _Method_default_instance_;
-constexpr Mixin::Mixin(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , root_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDefaultTypeInternal _Method_default_instance_;
+PROTOBUF_CONSTEXPR Mixin::Mixin(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , root_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct MixinDefaultTypeInternal {
- constexpr MixinDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MixinDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~MixinDefaultTypeInternal() {}
union {
Mixin _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MixinDefaultTypeInternal _Mixin_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MixinDefaultTypeInternal _Mixin_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -109,16 +113,16 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_S
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, name_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, root_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Api)},
{ 13, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Method)},
{ 26, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Mixin)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Api_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Method_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Mixin_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Api_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Method_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Mixin_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -142,23 +146,25 @@ const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_
"otobuf/types/known/apipb\242\002\003GPB\252\002\036Google."
"Protobuf.WellKnownTypesb\006proto3"
;
-static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = {
+static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = {
&::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto,
&::descriptor_table_google_2fprotobuf_2ftype_2eproto,
};
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = {
- false, false, 751, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto",
- &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 2, 3,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = {
+ false, false, 751, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto,
+ "google/protobuf/api.proto",
+ &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 2, 3,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fapi_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fapi_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fapi_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -188,9 +194,6 @@ Api::Api(::PROTOBUF_NAMESPACE_ID::Arena* arena,
options_(arena),
mixins_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Api)
}
Api::Api(const Api& from)
@@ -199,20 +202,20 @@ Api::Api(const Api& from)
options_(from.options_),
mixins_(from.mixins_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ version_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ version_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_version().empty()) {
- version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_version(),
+ version_.Set(from._internal_version(),
GetArenaForAllocation());
}
if (from._internal_has_source_context()) {
@@ -225,13 +228,13 @@ Api::Api(const Api& from)
}
inline void Api::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+version_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ version_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)),
@@ -241,24 +244,20 @@ version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlre
Api::~Api() {
// @@protoc_insertion_point(destructor:google.protobuf.Api)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Api::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ version_.Destroy();
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);
}
@@ -282,19 +281,19 @@ void Api::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Api.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.name"));
} else
goto handle_unusual;
continue;
@@ -328,9 +327,9 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
auto str = _internal_mutable_version();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Api.version"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.version"));
} else
goto handle_unusual;
continue;
@@ -404,19 +403,19 @@ uint8_t* Api::_InternalSerialize(
}
// repeated .google.protobuf.Method methods = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_methods_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_methods_size()); i < n; i++) {
+ const auto& repfield = this->_internal_methods(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_methods(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.Option options = 3;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
+ const auto& repfield = this->_internal_options(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(3, this->_internal_options(i), target, stream);
+ InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream);
}
// string version = 4;
@@ -431,29 +430,28 @@ uint8_t* Api::_InternalSerialize(
// .google.protobuf.SourceContext source_context = 5;
if (this->_internal_has_source_context()) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 5, _Internal::source_context(this), target, stream);
+ InternalWriteMessage(5, _Internal::source_context(this),
+ _Internal::source_context(this).GetCachedSize(), target, stream);
}
// repeated .google.protobuf.Mixin mixins = 6;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_mixins_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_mixins_size()); i < n; i++) {
+ const auto& repfield = this->_internal_mixins(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(6, this->_internal_mixins(i), target, stream);
+ InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream);
}
// .google.protobuf.Syntax syntax = 7;
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
7, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -513,7 +511,7 @@ size_t Api::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 7;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -576,12 +574,10 @@ void Api::InternalSwap(Api* other) {
options_.InternalSwap(&other->options_);
mixins_.InternalSwap(&other->mixins_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&version_, lhs_arena,
&other->version_, rhs_arena
);
@@ -594,7 +590,7 @@ void Api::InternalSwap(Api* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]);
}
@@ -613,37 +609,34 @@ Method::Method(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
options_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Method)
}
Method::Method(const Method& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
options_(from.options_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ request_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ request_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_request_type_url().empty()) {
- request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_request_type_url(),
+ request_type_url_.Set(from._internal_request_type_url(),
GetArenaForAllocation());
}
- response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ response_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ response_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_response_type_url().empty()) {
- response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_response_type_url(),
+ response_type_url_.Set(from._internal_response_type_url(),
GetArenaForAllocation());
}
::memcpy(&request_streaming_, &from.request_streaming_,
@@ -653,17 +646,17 @@ Method::Method(const Method& from)
}
inline void Method::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+request_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ request_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+response_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ response_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&request_streaming_) - reinterpret_cast<char*>(this)),
@@ -673,24 +666,20 @@ response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmpty
Method::~Method() {
// @@protoc_insertion_point(destructor:google.protobuf.Method)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Method::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == 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());
+ name_.Destroy();
+ request_type_url_.Destroy();
+ response_type_url_.Destroy();
}
-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);
}
@@ -711,19 +700,19 @@ void Method::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Method.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.name"));
} else
goto handle_unusual;
continue;
@@ -731,9 +720,9 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_request_type_url();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Method.request_type_url"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.request_type_url"));
} else
goto handle_unusual;
continue;
@@ -749,9 +738,9 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
auto str = _internal_mutable_response_type_url();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Method.response_type_url"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.response_type_url"));
} else
goto handle_unusual;
continue;
@@ -837,7 +826,7 @@ uint8_t* Method::_InternalSerialize(
// bool request_streaming = 3;
if (this->_internal_request_streaming() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_request_streaming(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_request_streaming(), target);
}
// string response_type_url = 4;
@@ -853,26 +842,26 @@ uint8_t* Method::_InternalSerialize(
// bool response_streaming = 5;
if (this->_internal_response_streaming() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_response_streaming(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_response_streaming(), target);
}
// repeated .google.protobuf.Option options = 6;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
+ const auto& repfield = this->_internal_options(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(6, this->_internal_options(i), target, stream);
+ InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream);
}
// .google.protobuf.Syntax syntax = 7;
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
7, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -928,7 +917,7 @@ size_t Method::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 7;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -993,17 +982,14 @@ void Method::InternalSwap(Method* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&request_type_url_, lhs_arena,
&other->request_type_url_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&response_type_url_, lhs_arena,
&other->response_type_url_, rhs_arena
);
@@ -1016,7 +1002,7 @@ void Method::InternalSwap(Method* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]);
}
@@ -1031,63 +1017,56 @@ Mixin::Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin)
}
Mixin::Mixin(const Mixin& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ root_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ root_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_root().empty()) {
- root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_root(),
+ root_.Set(from._internal_root(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin)
}
inline void Mixin::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+root_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ root_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Mixin::~Mixin() {
// @@protoc_insertion_point(destructor:google.protobuf.Mixin)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Mixin::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ root_.Destroy();
}
-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);
}
@@ -1103,19 +1082,19 @@ void Mixin::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Mixin::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Mixin.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.name"));
} else
goto handle_unusual;
continue;
@@ -1123,9 +1102,9 @@ const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_root();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Mixin.root"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.root"));
} else
goto handle_unusual;
continue;
@@ -1179,7 +1158,7 @@ uint8_t* Mixin::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1256,19 +1235,17 @@ void Mixin::InternalSwap(Mixin* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&root_, lhs_arena,
&other->root_, rhs_arena
);
}
::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]);
}
@@ -1276,13 +1253,16 @@ void Mixin::InternalSwap(Mixin* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Api* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Api >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Api*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Api >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Api >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Method* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Method >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Method*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Method >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Method >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Mixin* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Mixin*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Mixin >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/api.pb.h b/contrib/libs/protobuf/src/google/protobuf/api.pb.h
index 85e5252b82..9c4fa9692e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/api.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/api.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -44,14 +43,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto;
@@ -80,7 +71,7 @@ class PROTOBUF_EXPORT Api final :
public:
inline Api() : Api(nullptr) {}
~Api() override;
- explicit constexpr Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Api(const Api& from);
Api(Api&& from) noexcept
@@ -182,9 +173,6 @@ class PROTOBUF_EXPORT Api final :
protected:
explicit Api(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -338,7 +326,7 @@ class PROTOBUF_EXPORT Method final :
public:
inline Method() : Method(nullptr) {}
~Method() override;
- explicit constexpr Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Method(const Method& from);
Method(Method&& from) noexcept
@@ -440,9 +428,6 @@ class PROTOBUF_EXPORT Method final :
protected:
explicit Method(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -574,7 +559,7 @@ class PROTOBUF_EXPORT Mixin final :
public:
inline Mixin() : Mixin(nullptr) {}
~Mixin() override;
- explicit constexpr Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Mixin(const Mixin& from);
Mixin(Mixin&& from) noexcept
@@ -676,9 +661,6 @@ class PROTOBUF_EXPORT Mixin final :
protected:
explicit Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -757,7 +739,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Api::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
}
inline TProtoStringType* Api::mutable_name() {
@@ -770,15 +752,15 @@ inline const TProtoStringType& Api::_internal_name() const {
}
inline void Api::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Api::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Api::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Api::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -786,11 +768,10 @@ inline void Api::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)
@@ -885,7 +866,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Api::set_version(ArgT0&& arg0, ArgT... args) {
- version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ version_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
}
inline TProtoStringType* Api::mutable_version() {
@@ -898,15 +879,15 @@ inline const TProtoStringType& Api::_internal_version() const {
}
inline void Api::_internal_set_version(const TProtoStringType& value) {
- version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ version_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Api::_internal_mutable_version() {
- return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return version_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Api::release_version() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.version)
- return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return version_.Release();
}
inline void Api::set_allocated_version(TProtoStringType* version) {
if (version != nullptr) {
@@ -914,11 +895,10 @@ inline void Api::set_allocated_version(TProtoStringType* version) {
} else {
}
- version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version,
- GetArenaForAllocation());
+ version_.SetAllocated(version, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (version_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (version_.IsDefault()) {
+ version_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
@@ -995,8 +975,7 @@ inline void Api::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCon
}
if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
- ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@@ -1086,7 +1065,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Method::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
}
inline TProtoStringType* Method::mutable_name() {
@@ -1099,15 +1078,15 @@ inline const TProtoStringType& Method::_internal_name() const {
}
inline void Method::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Method::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Method::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Method::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -1115,11 +1094,10 @@ inline void Method::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
@@ -1137,7 +1115,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
- request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ request_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
}
inline TProtoStringType* Method::mutable_request_type_url() {
@@ -1150,15 +1128,15 @@ inline const TProtoStringType& Method::_internal_request_type_url() const {
}
inline void Method::_internal_set_request_type_url(const TProtoStringType& value) {
- request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ request_type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Method::_internal_mutable_request_type_url() {
- return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return request_type_url_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Method::release_request_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url)
- return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return request_type_url_.Release();
}
inline void Method::set_allocated_request_type_url(TProtoStringType* request_type_url) {
if (request_type_url != nullptr) {
@@ -1166,11 +1144,10 @@ inline void Method::set_allocated_request_type_url(TProtoStringType* request_typ
} else {
}
- request_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url,
- GetArenaForAllocation());
+ request_type_url_.SetAllocated(request_type_url, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (request_type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (request_type_url_.IsDefault()) {
+ request_type_url_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
@@ -1208,7 +1185,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
- response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ response_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
}
inline TProtoStringType* Method::mutable_response_type_url() {
@@ -1221,15 +1198,15 @@ inline const TProtoStringType& Method::_internal_response_type_url() const {
}
inline void Method::_internal_set_response_type_url(const TProtoStringType& value) {
- response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ response_type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Method::_internal_mutable_response_type_url() {
- return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return response_type_url_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Method::release_response_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url)
- return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return response_type_url_.Release();
}
inline void Method::set_allocated_response_type_url(TProtoStringType* response_type_url) {
if (response_type_url != nullptr) {
@@ -1237,11 +1214,10 @@ inline void Method::set_allocated_response_type_url(TProtoStringType* response_t
} else {
}
- response_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url,
- GetArenaForAllocation());
+ response_type_url_.SetAllocated(response_type_url, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (response_type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (response_type_url_.IsDefault()) {
+ response_type_url_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
@@ -1340,7 +1316,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
}
inline TProtoStringType* Mixin::mutable_name() {
@@ -1353,15 +1329,15 @@ inline const TProtoStringType& Mixin::_internal_name() const {
}
inline void Mixin::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Mixin::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Mixin::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Mixin::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -1369,11 +1345,10 @@ inline void Mixin::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
@@ -1391,7 +1366,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
- root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ root_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
}
inline TProtoStringType* Mixin::mutable_root() {
@@ -1404,15 +1379,15 @@ inline const TProtoStringType& Mixin::_internal_root() const {
}
inline void Mixin::_internal_set_root(const TProtoStringType& value) {
- root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ root_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Mixin::_internal_mutable_root() {
- return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return root_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Mixin::release_root() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.root)
- return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return root_.Release();
}
inline void Mixin::set_allocated_root(TProtoStringType* root) {
if (root != nullptr) {
@@ -1420,11 +1395,10 @@ inline void Mixin::set_allocated_root(TProtoStringType* root) {
} else {
}
- root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root,
- GetArenaForAllocation());
+ root_.SetAllocated(root, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (root_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (root_.IsDefault()) {
+ root_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena.cc b/contrib/libs/protobuf/src/google/protobuf/arena.cc
index e3047f9669..b19c1c4b4a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arena.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/arena.cc
@@ -38,12 +38,15 @@
#include <typeinfo>
#include <google/protobuf/arena_impl.h>
+#include <google/protobuf/arenaz_sampler.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/stubs/mutex.h>
#ifdef ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif // ADDRESS_SANITIZER
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -91,11 +94,7 @@ class GetDeallocator {
if (dealloc_) {
dealloc_(mem.ptr, mem.size);
} else {
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
- ::operator delete(mem.ptr, mem.size);
-#else
- ::operator delete(mem.ptr);
-#endif
+ internal::SizedDelete(mem.ptr, mem.size);
}
*space_allocated_ += mem.size;
}
@@ -105,18 +104,22 @@ class GetDeallocator {
size_t* space_allocated_;
};
-SerialArena::SerialArena(Block* b, void* owner) : space_allocated_(b->size) {
+SerialArena::SerialArena(Block* b, void* owner, ThreadSafeArenaStats* stats)
+ : space_allocated_(b->size) {
owner_ = owner;
head_ = b;
ptr_ = b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize);
limit_ = b->Pointer(b->size & static_cast<size_t>(-8));
+ arena_stats_ = stats;
}
-SerialArena* SerialArena::New(Memory mem, void* owner) {
+SerialArena* SerialArena::New(Memory mem, void* owner,
+ ThreadSafeArenaStats* stats) {
GOOGLE_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize, mem.size);
-
+ ThreadSafeArenaStats::RecordAllocateStats(
+ stats, /*requested=*/mem.size, /*allocated=*/mem.size, /*wasted=*/0);
auto b = new (mem.ptr) Block{nullptr, mem.size};
- return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, owner);
+ return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, owner, stats);
}
template <typename Deallocator>
@@ -151,7 +154,14 @@ void SerialArena::AllocateNewBlock(size_t n, const AllocationPolicy* policy) {
head_->start = reinterpret_cast<CleanupNode*>(limit_);
// Record how much used in this block.
- space_used_ += ptr_ - head_->Pointer(kBlockHeaderSize);
+ size_t used = ptr_ - head_->Pointer(kBlockHeaderSize);
+ size_t wasted = head_->size - used;
+ space_used_ += used;
+
+ // TODO(sbenza): Evaluate if pushing unused space into the cached blocks is a
+ // win. In preliminary testing showed increased memory savings as expected,
+ // but with a CPU regression. The regression might have been an artifact of
+ // the microbenchmark.
auto mem = AllocateMemory(policy, head_->size, n);
// We don't want to emit an expensive RMW instruction that requires
@@ -159,6 +169,8 @@ void SerialArena::AllocateNewBlock(size_t n, const AllocationPolicy* policy) {
// regular add.
auto relaxed = std::memory_order_relaxed;
space_allocated_.store(space_allocated_.load(relaxed) + mem.size, relaxed);
+ ThreadSafeArenaStats::RecordAllocateStats(arena_stats_, /*requested=*/n,
+ /*allocated=*/mem.size, wasted);
head_ = new (mem.ptr) Block{head_, mem.size};
ptr_ = head_->Pointer(kBlockHeaderSize);
limit_ = head_->Pointer(head_->size);
@@ -312,10 +324,12 @@ void ThreadSafeArena::Init() {
#ifndef NDEBUG
GOOGLE_CHECK_EQ(was_message_owned, IsMessageOwned());
#endif // NDEBUG
+ arena_stats_ = Sample();
}
void ThreadSafeArena::SetInitialBlock(void* mem, size_t size) {
- SerialArena* serial = SerialArena::New({mem, size}, &thread_cache());
+ SerialArena* serial = SerialArena::New({mem, size}, &thread_cache(),
+ arena_stats_.MutableStats());
serial->set_next(NULL);
threads_.store(serial, std::memory_order_relaxed);
CacheSerialArena(serial);
@@ -334,6 +348,10 @@ ThreadSafeArena::~ThreadSafeArena() {
ArenaMetricsCollector* collector = p ? p->metrics_collector : nullptr;
if (alloc_policy_.is_user_owned_initial_block()) {
+#ifdef ADDRESS_SANITIZER
+ // Unpoison the initial block, now that it's going back to the user.
+ ASAN_UNPOISON_MEMORY_REGION(mem.ptr, mem.size);
+#endif // ADDRESS_SANITIZER
space_allocated += mem.size;
} else {
GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
@@ -360,6 +378,7 @@ arc_ui64 ThreadSafeArena::Reset() {
// Discard all blocks except the special block (if present).
size_t space_allocated = 0;
auto mem = Free(&space_allocated);
+ arena_stats_.RecordReset();
AllocationPolicy* policy = alloc_policy_.get();
if (policy) {
@@ -474,7 +493,8 @@ SerialArena* ThreadSafeArena::GetSerialArenaFallback(void* me) {
// This thread doesn't have any SerialArena, which also means it doesn't
// have any blocks yet. So we'll allocate its first block now.
serial = SerialArena::New(
- AllocateMemory(alloc_policy_.get(), 0, kSerialArenaSize), me);
+ AllocateMemory(alloc_policy_.get(), 0, kSerialArenaSize), me,
+ arena_stats_.MutableStats());
SerialArena* head = threads_.load(std::memory_order_relaxed);
do {
@@ -500,6 +520,12 @@ void* Arena::AllocateAlignedWithHook(size_t n, const std::type_info* type) {
}
PROTOBUF_FUNC_ALIGN(32)
+void* Arena::AllocateAlignedWithHookForArray(size_t n,
+ const std::type_info* type) {
+ return impl_.AllocateAligned<internal::AllocationClient::kArray>(n, type);
+}
+
+PROTOBUF_FUNC_ALIGN(32)
std::pair<void*, internal::SerialArena::CleanupNode*>
Arena::AllocateAlignedWithCleanup(size_t n, const std::type_info* type) {
return impl_.AllocateAlignedWithCleanup(n, type);
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena.h b/contrib/libs/protobuf/src/google/protobuf/arena.h
index 7763d7aa5f..2c95ddc8f6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arena.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arena.h
@@ -37,9 +37,6 @@
#include <limits>
#include <type_traits>
#include <utility>
-#ifdef max
-#undef max // Visual Studio defines this macro
-#endif
#if defined(_MSC_VER) && !defined(_LIBCPP_STD_VER) && !_HAS_EXCEPTIONS
// Work around bugs in MSVC <typeinfo> header when _HAS_EXCEPTIONS=0.
#include <exception>
@@ -55,6 +52,7 @@ using type_info = ::type_info;
#include <google/protobuf/arena_impl.h>
#include <google/protobuf/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -83,10 +81,11 @@ class ReflectionTester; // defined in test_util.h
namespace internal {
-struct ArenaStringPtr; // defined in arenastring.h
-class InlinedStringField; // defined in inlined_string_field.h
-class LazyField; // defined in lazy_field.h
-class EpsCopyInputStream; // defined in parse_context.h
+struct ArenaTestPeer; // defined in arena_test_util.h
+class InternalMetadata; // defined in metadata_lite.h
+class LazyField; // defined in lazy_field.h
+class EpsCopyInputStream; // defined in parse_context.h
+class RepeatedPtrFieldBase; // defined in repeated_ptr_field.h
template <typename Type>
class GenericTypeHandler; // defined in repeated_field.h
@@ -316,6 +315,20 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
static_cast<Args&&>(args)...);
}
+ // Allocates memory with the specific size and alignment.
+ void* AllocateAligned(size_t size, size_t align = 8) {
+ if (align <= 8) {
+ return AllocateAlignedNoHook(internal::AlignUpTo8(size));
+ } else {
+ // We are wasting space by over allocating align - 8 bytes. Compared
+ // to a dedicated function that takes current alignment in consideration.
+ // Such a scheme would only waste (align - 8)/2 bytes on average, but
+ // requires a dedicated function in the outline arena allocation
+ // functions. Possibly re-evaluate tradeoffs later.
+ return internal::AlignTo(AllocateAlignedNoHook(size + align - 8), align);
+ }
+ }
+
// Create an array of object type T on the arena *without* invoking the
// constructor of T. If `arena` is null, then the return value should be freed
// with `delete[] x;` (or `::operator delete[](x);`).
@@ -397,27 +410,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
template <typename T>
class InternalHelper {
- public:
+ private:
// Provides access to protected GetOwningArena to generated messages.
static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); }
- // Provides access to protected GetArenaForAllocation to generated messages.
- static Arena* GetArenaForAllocation(const T* p) {
- return GetArenaForAllocationInternal(
- p, std::is_convertible<T*, MessageLite*>());
- }
-
- // Creates message-owned arena.
- static Arena* CreateMessageOwnedArena() {
- return new Arena(internal::MessageOwned{});
- }
-
- // Checks whether the given arena is message-owned.
- static bool IsMessageOwnedArena(Arena* arena) {
- return arena->IsMessageOwned();
- }
-
- private:
static Arena* GetArenaForAllocationInternal(
const T* p, std::true_type /*is_derived_from<MessageLite>*/) {
return p->GetArenaForAllocation();
@@ -500,6 +496,29 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
friend class TestUtil::ReflectionTester;
};
+ // Provides access to protected GetOwningArena to generated messages. For
+ // internal use only.
+ template <typename T>
+ static Arena* InternalGetOwningArena(const T* p) {
+ return InternalHelper<T>::GetOwningArena(p);
+ }
+
+ // Provides access to protected GetArenaForAllocation to generated messages.
+ // For internal use only.
+ template <typename T>
+ static Arena* InternalGetArenaForAllocation(const T* p) {
+ return InternalHelper<T>::GetArenaForAllocationInternal(
+ p, std::is_convertible<T*, MessageLite*>());
+ }
+
+ // Creates message-owned arena. For internal use only.
+ static Arena* InternalCreateMessageOwnedArena() {
+ return new Arena(internal::MessageOwned{});
+ }
+
+ // Checks whether this arena is message-owned. For internal use only.
+ bool InternalIsMessageOwnedArena() { return IsMessageOwned(); }
+
// Helper typetraits that indicates support for arenas in a type T at compile
// time. This is public only to allow construction of higher-level templated
// utilities.
@@ -532,6 +551,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
return impl_.IsMessageOwned();
}
+ void ReturnArrayMemory(void* p, size_t size) {
+ impl_.ReturnArrayMemory(p, size);
+ }
+
template <typename T, typename... Args>
PROTOBUF_NDEBUG_INLINE static T* CreateMessageInternal(Arena* arena,
Args&&... args) {
@@ -622,7 +645,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
// 8 AlignUpTo can be elided.
const size_t n = sizeof(T) * num_elements;
return static_cast<T*>(
- AllocateAlignedWithHook(n, alignof(T), RTTI_TYPE_ID(T)));
+ AllocateAlignedWithHookForArray(n, alignof(T), RTTI_TYPE_ID(T)));
}
template <typename T, typename... Args>
@@ -765,17 +788,18 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
return nullptr;
}
- // For friends of arena.
- void* AllocateAligned(size_t n, size_t align = 8) {
+ void* AllocateAlignedWithHookForArray(size_t n, size_t align,
+ const std::type_info* type) {
if (align <= 8) {
- return AllocateAlignedNoHook(internal::AlignUpTo8(n));
+ return AllocateAlignedWithHookForArray(internal::AlignUpTo8(n), type);
} else {
// We are wasting space by over allocating align - 8 bytes. Compared
// to a dedicated function that takes current alignment in consideration.
// Such a scheme would only waste (align - 8)/2 bytes on average, but
// requires a dedicated function in the outline arena allocation
// functions. Possibly re-evaluate tradeoffs later.
- return internal::AlignTo(AllocateAlignedNoHook(n + align - 8), align);
+ return internal::AlignTo(
+ AllocateAlignedWithHookForArray(n + align - 8, type), align);
}
}
@@ -786,7 +810,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
} else {
// We are wasting space by over allocating align - 8 bytes. Compared
// to a dedicated function that takes current alignment in consideration.
- // Such a schemee would only waste (align - 8)/2 bytes on average, but
+ // Such a scheme would only waste (align - 8)/2 bytes on average, but
// requires a dedicated function in the outline arena allocation
// functions. Possibly re-evaluate tradeoffs later.
return internal::AlignTo(AllocateAlignedWithHook(n + align - 8, type),
@@ -796,18 +820,22 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
void* AllocateAlignedNoHook(size_t n);
void* AllocateAlignedWithHook(size_t n, const std::type_info* type);
+ void* AllocateAlignedWithHookForArray(size_t n, const std::type_info* type);
std::pair<void*, internal::SerialArena::CleanupNode*>
AllocateAlignedWithCleanup(size_t n, const std::type_info* type);
template <typename Type>
friend class internal::GenericTypeHandler;
- friend struct internal::ArenaStringPtr; // For AllocateAligned.
- friend class internal::InlinedStringField; // For AllocateAligned.
+ friend class internal::InternalMetadata; // For user_arena().
friend class internal::LazyField; // For CreateMaybeMessage.
friend class internal::EpsCopyInputStream; // For parser performance
friend class MessageLite;
template <typename Key, typename T>
friend class Map;
+ template <typename>
+ friend class RepeatedField; // For ReturnArrayMemory
+ friend class internal::RepeatedPtrFieldBase; // For ReturnArrayMemory
+ friend struct internal::ArenaTestPeer;
};
// Defined above for supporting environments without RTTI.
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena_impl.h b/contrib/libs/protobuf/src/google/protobuf/arena_impl.h
index 76aa3bb045..ccaabe7e76 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arena_impl.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_impl.h
@@ -39,11 +39,15 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/port.h>
#ifdef ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif // ADDRESS_SANITIZER
+#include <google/protobuf/arenaz_sampler.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -177,6 +181,8 @@ class TaggedAllocationPolicyPtr {
uintptr_t policy_;
};
+enum class AllocationClient { kDefault, kArray };
+
// A simple arena allocator. Calls to allocate functions must be properly
// serialized by the caller, hence this class cannot be used as a general
// purpose allocator in a multi-threaded program. It serves as a building block
@@ -208,11 +214,47 @@ class PROTOBUF_EXPORT SerialArena {
}
arc_ui64 SpaceUsed() const;
- bool HasSpace(size_t n) { return n <= static_cast<size_t>(limit_ - ptr_); }
+ bool HasSpace(size_t n) const {
+ return n <= static_cast<size_t>(limit_ - ptr_);
+ }
+
+ // See comments on `cached_blocks_` member for details.
+ PROTOBUF_ALWAYS_INLINE void* TryAllocateFromCachedBlock(size_t size) {
+ if (PROTOBUF_PREDICT_FALSE(size < 16)) return nullptr;
+ // We round up to the next larger block in case the memory doesn't match
+ // the pattern we are looking for.
+ const size_t index = Bits::Log2FloorNonZero64(size - 1) - 3;
+
+ if (index >= cached_block_length_) return nullptr;
+ auto& cached_head = cached_blocks_[index];
+ if (cached_head == nullptr) return nullptr;
+
+ void* ret = cached_head;
+#ifdef ADDRESS_SANITIZER
+ ASAN_UNPOISON_MEMORY_REGION(ret, size);
+#endif // ADDRESS_SANITIZER
+ cached_head = cached_head->next;
+ return ret;
+ }
+ // In kArray mode we look through cached blocks.
+ // We do not do this by default because most non-array allocations will not
+ // have the right size and will fail to find an appropriate cached block.
+ //
+ // TODO(sbenza): Evaluate if we should use cached blocks for message types of
+ // the right size. We can statically know if the allocation size can benefit
+ // from it.
+ template <AllocationClient alloc_client = AllocationClient::kDefault>
void* AllocateAligned(size_t n, const AllocationPolicy* policy) {
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
GOOGLE_DCHECK_GE(limit_, ptr_);
+
+ if (alloc_client == AllocationClient::kArray) {
+ if (void* res = TryAllocateFromCachedBlock(n)) {
+ return res;
+ }
+ }
+
if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) {
return AllocateAlignedFallback(n, policy);
}
@@ -229,6 +271,50 @@ class PROTOBUF_EXPORT SerialArena {
return ret;
}
+ // See comments on `cached_blocks_` member for details.
+ void ReturnArrayMemory(void* p, size_t size) {
+ // We only need to check for 32-bit platforms.
+ // In 64-bit platforms the minimum allocation size from Repeated*Field will
+ // be 16 guaranteed.
+ if (sizeof(void*) < 8) {
+ if (PROTOBUF_PREDICT_FALSE(size < 16)) return;
+ } else {
+ GOOGLE_DCHECK(size >= 16);
+ }
+
+ // We round down to the next smaller block in case the memory doesn't match
+ // the pattern we are looking for. eg, someone might have called Reserve()
+ // on the repeated field.
+ const size_t index = Bits::Log2FloorNonZero64(size) - 4;
+
+ if (PROTOBUF_PREDICT_FALSE(index >= cached_block_length_)) {
+ // We can't put this object on the freelist so make this object the
+ // freelist. It is guaranteed it is larger than the one we have, and
+ // large enough to hold another allocation of `size`.
+ CachedBlock** new_list = static_cast<CachedBlock**>(p);
+ size_t new_size = size / sizeof(CachedBlock*);
+
+ std::copy(cached_blocks_, cached_blocks_ + cached_block_length_,
+ new_list);
+ std::fill(new_list + cached_block_length_, new_list + new_size, nullptr);
+ cached_blocks_ = new_list;
+ // Make the size fit in uint8_t. This is the power of two, so we don't
+ // need anything larger.
+ cached_block_length_ =
+ static_cast<uint8_t>(std::min(size_t{64}, new_size));
+
+ return;
+ }
+
+ auto& cached_head = cached_blocks_[index];
+ auto* new_node = static_cast<CachedBlock*>(p);
+ new_node->next = cached_head;
+ cached_head = new_node;
+#ifdef ADDRESS_SANITIZER
+ ASAN_POISON_MEMORY_REGION(p, size);
+#endif // ADDRESS_SANITIZER
+ }
+
public:
// Allocate space if the current region provides enough space.
bool MaybeAllocateAligned(size_t n, void** out) {
@@ -279,7 +365,8 @@ class PROTOBUF_EXPORT SerialArena {
// Creates a new SerialArena inside mem using the remaining memory as for
// future allocations.
- static SerialArena* New(SerialArena::Memory mem, void* owner);
+ static SerialArena* New(SerialArena::Memory mem, void* owner,
+ ThreadSafeArenaStats* stats);
// Free SerialArena returning the memory passed in to New
template <typename Deallocator>
Memory Free(Deallocator deallocator);
@@ -310,10 +397,28 @@ class PROTOBUF_EXPORT SerialArena {
// head_ (and head_->pos will always be non-canonical). We keep these
// here to reduce indirection.
char* ptr_;
+ // Limiting address up to which memory can be allocated from the head block.
char* limit_;
+ // For holding sampling information. The pointer is owned by the
+ // ThreadSafeArena that holds this serial arena.
+ ThreadSafeArenaStats* arena_stats_;
+
+ // Repeated*Field and Arena play together to reduce memory consumption by
+ // reusing blocks. Currently, natural growth of the repeated field types makes
+ // them allocate blocks of size `8 + 2^N, N>=3`.
+ // When the repeated field grows returns the previous block and we put it in
+ // this free list.
+ // `cached_blocks_[i]` points to the free list for blocks of size `8+2^(i+3)`.
+ // The array of freelists is grown when needed in `ReturnArrayMemory()`.
+ struct CachedBlock {
+ // Simple linked list.
+ CachedBlock* next;
+ };
+ uint8_t cached_block_length_ = 0;
+ CachedBlock** cached_blocks_ = nullptr;
// Constructor is private as only New() should be used.
- inline SerialArena(Block* b, void* owner);
+ inline SerialArena(Block* b, void* owner, ThreadSafeArenaStats* stats);
void* AllocateAlignedFallback(size_t n, const AllocationPolicy* policy);
std::pair<void*, CleanupNode*> AllocateAlignedWithCleanupFallback(
size_t n, const AllocationPolicy* policy);
@@ -368,16 +473,24 @@ class PROTOBUF_EXPORT ThreadSafeArena {
arc_ui64 SpaceAllocated() const;
arc_ui64 SpaceUsed() const;
+ template <AllocationClient alloc_client = AllocationClient::kDefault>
void* AllocateAligned(size_t n, const std::type_info* type) {
SerialArena* arena;
if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
GetSerialArenaFast(&arena))) {
- return arena->AllocateAligned(n, AllocPolicy());
+ return arena->AllocateAligned<alloc_client>(n, AllocPolicy());
} else {
return AllocateAlignedFallback(n, type);
}
}
+ void ReturnArrayMemory(void* p, size_t size) {
+ SerialArena* arena;
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ arena->ReturnArrayMemory(p, size);
+ }
+ }
+
// This function allocates n bytes if the common happy case is true and
// returns true. Otherwise does nothing and returns false. This strange
// semantics is necessary to allow callers to program functions that only
@@ -411,6 +524,8 @@ class PROTOBUF_EXPORT ThreadSafeArena {
TaggedAllocationPolicyPtr alloc_policy_; // Tagged pointer to AllocPolicy.
+ static_assert(std::is_trivially_destructible<SerialArena>{},
+ "SerialArena needs to be trivially destructible.");
// Pointer to a linked list of SerialArena.
std::atomic<SerialArena*> threads_;
std::atomic<SerialArena*> hint_; // Fast thread-local block access
@@ -535,6 +650,8 @@ class PROTOBUF_EXPORT ThreadSafeArena {
static ThreadCache& thread_cache() { return thread_cache_; }
#endif
+ ThreadSafeArenaStatsHandle arena_stats_;
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ThreadSafeArena);
// All protos have pointers back to the arena hence Arena must have
// pointer stability.
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenastring.cc b/contrib/libs/protobuf/src/google/protobuf/arenastring.cc
index c64864e4b1..b51d403ab5 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arenastring.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/arenastring.cc
@@ -30,13 +30,14 @@
#include <google/protobuf/arenastring.h>
+#include <cstddef>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/message_lite.h>
#include <google/protobuf/stubs/mutex.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/stubs/stl_util.h>
// clang-format off
@@ -47,6 +48,27 @@ namespace google {
namespace protobuf {
namespace internal {
+namespace {
+
+// Enforce that allocated data aligns to at least 8 bytes, and that
+// the alignment of the global const string value does as well.
+// The alignment guaranteed by `new TProtoStringType` depends on both:
+// - new align = __STDCPP_DEFAULT_NEW_ALIGNMENT__ / max_align_t
+// - alignof(TProtoStringType)
+#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
+constexpr size_t kNewAlign = __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
+constexpr size_t kNewAlign = alignof(::max_align_t);
+#else
+constexpr size_t kNewAlign = alignof(std::max_align_t);
+#endif
+constexpr size_t kStringAlign = alignof(TProtoStringType);
+
+static_assert((kStringAlign > kNewAlign ? kStringAlign : kNewAlign) >= 8, "");
+static_assert(alignof(ExplicitlyConstructedArenaString) >= 8, "");
+
+} // namespace
+
const TProtoStringType& LazyString::Init() const {
static WrappedMutex mu{GOOGLE_PROTOBUF_LINKER_INITIALIZED};
mu.Lock();
@@ -61,185 +83,152 @@ const TProtoStringType& LazyString::Init() const {
return *res;
}
+namespace {
+
+
+#if defined(NDEBUG) || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
-TProtoStringType* ArenaStringPtr::SetAndReturnNewString() {
- TProtoStringType* new_string = new TProtoStringType();
- tagged_ptr_.Set(new_string);
- return new_string;
+class ScopedCheckPtrInvariants {
+ public:
+ explicit ScopedCheckPtrInvariants(const TaggedStringPtr*) {}
+};
+
+#endif // NDEBUG || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
+
+// Creates a heap allocated TProtoStringType value.
+inline TaggedStringPtr CreateString(ConstStringParam value) {
+ TaggedStringPtr res;
+ res.SetAllocated(new TProtoStringType(value.data(), value.length()));
+ return res;
+}
+
+#if !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
+
+// Creates an arena allocated TProtoStringType value.
+TaggedStringPtr CreateArenaString(Arena& arena, ConstStringParam s) {
+ TaggedStringPtr res;
+ res.SetMutableArena(Arena::Create<TProtoStringType>(&arena, s.data(), s.length()));
+ return res;
}
-void ArenaStringPtr::DestroyNoArenaSlowPath() { delete UnsafeMutablePointer(); }
+#endif // !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
-void ArenaStringPtr::Set(const TProtoStringType* default_value,
- ConstStringParam value, ::google::protobuf::Arena* arena) {
- if (IsDefault(default_value)) {
- tagged_ptr_.Set(Arena::Create<TProtoStringType>(arena, value));
+} // namespace
+
+void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (IsDefault()) {
+ // If we're not on an arena, skip straight to a true string to avoid
+ // possible copy cost later.
+ tagged_ptr_ = arena != nullptr ? CreateArenaString(*arena, value)
+ : CreateString(value);
} else {
UnsafeMutablePointer()->assign(value.data(), value.length());
}
}
-void ArenaStringPtr::Set(const TProtoStringType* default_value, TProtoStringType&& value,
- ::google::protobuf::Arena* arena) {
- if (IsDefault(default_value)) {
- if (arena == nullptr) {
- tagged_ptr_.Set(new TProtoStringType(std::move(value)));
- } else {
- tagged_ptr_.Set(Arena::Create<TProtoStringType>(arena, std::move(value)));
- }
- } else if (IsDonatedString()) {
+void ArenaStringPtr::Set(TProtoStringType&& value, Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (IsDefault()) {
+ NewString(arena, std::move(value));
+ } else if (IsFixedSizeArena()) {
TProtoStringType* current = tagged_ptr_.Get();
auto* s = new (current) TProtoStringType(std::move(value));
arena->OwnDestructor(s);
- tagged_ptr_.Set(s);
- } else /* !IsDonatedString() */ {
+ tagged_ptr_.SetMutableArena(s);
+ } else /* !IsFixedSizeArena() */ {
*UnsafeMutablePointer() = std::move(value);
}
}
-void ArenaStringPtr::Set(EmptyDefault, ConstStringParam value,
- ::google::protobuf::Arena* arena) {
- Set(&GetEmptyStringAlreadyInited(), value, arena);
-}
-
-void ArenaStringPtr::Set(EmptyDefault, TProtoStringType&& value,
- ::google::protobuf::Arena* arena) {
- Set(&GetEmptyStringAlreadyInited(), std::move(value), arena);
-}
-
-void ArenaStringPtr::Set(NonEmptyDefault, ConstStringParam value,
- ::google::protobuf::Arena* arena) {
- Set(nullptr, value, arena);
-}
-
-void ArenaStringPtr::Set(NonEmptyDefault, TProtoStringType&& value,
- ::google::protobuf::Arena* arena) {
- Set(nullptr, std::move(value), arena);
-}
-
-TProtoStringType* ArenaStringPtr::Mutable(EmptyDefault, ::google::protobuf::Arena* arena) {
- if (!IsDonatedString() && !IsDefault(&GetEmptyStringAlreadyInited())) {
- return UnsafeMutablePointer();
+TProtoStringType* ArenaStringPtr::Mutable(Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (tagged_ptr_.IsMutable()) {
+ return tagged_ptr_.Get();
} else {
return MutableSlow(arena);
}
}
TProtoStringType* ArenaStringPtr::Mutable(const LazyString& default_value,
- ::google::protobuf::Arena* arena) {
- if (!IsDonatedString() && !IsDefault(nullptr)) {
- return UnsafeMutablePointer();
+ Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (tagged_ptr_.IsMutable()) {
+ return tagged_ptr_.Get();
} else {
return MutableSlow(arena, default_value);
}
}
-TProtoStringType* ArenaStringPtr::MutableNoCopy(const TProtoStringType* default_value,
- ::google::protobuf::Arena* arena) {
- if (!IsDonatedString() && !IsDefault(default_value)) {
- return UnsafeMutablePointer();
+TProtoStringType* ArenaStringPtr::MutableNoCopy(Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (tagged_ptr_.IsMutable()) {
+ return tagged_ptr_.Get();
} else {
- GOOGLE_DCHECK(IsDefault(default_value));
+ GOOGLE_DCHECK(IsDefault());
// Allocate empty. The contents are not relevant.
- TProtoStringType* new_string = Arena::Create<TProtoStringType>(arena);
- tagged_ptr_.Set(new_string);
- return new_string;
+ return NewString(arena);
}
}
template <typename... Lazy>
TProtoStringType* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena,
const Lazy&... lazy_default) {
- const TProtoStringType* const default_value =
- sizeof...(Lazy) == 0 ? &GetEmptyStringAlreadyInited() : nullptr;
- GOOGLE_DCHECK(IsDefault(default_value));
- TProtoStringType* new_string =
- Arena::Create<TProtoStringType>(arena, lazy_default.get()...);
- tagged_ptr_.Set(new_string);
- return new_string;
-}
+ GOOGLE_DCHECK(IsDefault());
-TProtoStringType* ArenaStringPtr::Release(const TProtoStringType* default_value,
- ::google::protobuf::Arena* arena) {
- if (IsDefault(default_value)) {
- return nullptr;
- } else {
- return ReleaseNonDefault(default_value, arena);
- }
+ // For empty defaults, this ends up calling the default constructor which is
+ // more efficient than a copy construction from
+ // GetEmptyStringAlreadyInited().
+ return NewString(arena, lazy_default.get()...);
}
-TProtoStringType* ArenaStringPtr::ReleaseNonDefault(const TProtoStringType* default_value,
- ::google::protobuf::Arena* arena) {
- GOOGLE_DCHECK(!IsDefault(default_value));
-
- if (!IsDonatedString()) {
- TProtoStringType* released;
- if (arena != nullptr) {
- released = new TProtoStringType;
- released->swap(*UnsafeMutablePointer());
- } else {
- released = UnsafeMutablePointer();
- }
- tagged_ptr_.Set(const_cast<TProtoStringType*>(default_value));
- return released;
- } else /* IsDonatedString() */ {
- GOOGLE_DCHECK(arena != nullptr);
- TProtoStringType* released = new TProtoStringType(Get());
- tagged_ptr_.Set(const_cast<TProtoStringType*>(default_value));
- return released;
+TProtoStringType* ArenaStringPtr::Release() {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (IsDefault()) return nullptr;
+
+ TProtoStringType* released = tagged_ptr_.Get();
+ if (!tagged_ptr_.IsAllocated()) {
+ released = tagged_ptr_.IsMutable() ? new TProtoStringType(std::move(*released))
+ : new TProtoStringType(*released);
}
+ InitDefault();
+ return released;
}
-void ArenaStringPtr::SetAllocated(const TProtoStringType* default_value,
- TProtoStringType* value, ::google::protobuf::Arena* arena) {
+void ArenaStringPtr::SetAllocated(TProtoStringType* value, Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
// Release what we have first.
- if (arena == nullptr && !IsDefault(default_value)) {
- delete UnsafeMutablePointer();
- }
+ Destroy();
+
if (value == nullptr) {
- tagged_ptr_.Set(const_cast<TProtoStringType*>(default_value));
+ InitDefault();
} else {
-#ifdef NDEBUG
- tagged_ptr_.Set(value);
- if (arena != nullptr) {
- arena->Own(value);
- }
-#else
+#ifndef NDEBUG
// On debug builds, copy the string so the address differs. delete will
// fail if value was a stack-allocated temporary/etc., which would have
// failed when arena ran its cleanup list.
- TProtoStringType* new_value = Arena::Create<TProtoStringType>(arena, *value);
+ TProtoStringType* new_value = new TProtoStringType(std::move(*value));
delete value;
- tagged_ptr_.Set(new_value);
-#endif
+ value = new_value;
+#endif // !NDEBUG
+ InitAllocated(value, arena);
}
}
-void ArenaStringPtr::Destroy(const TProtoStringType* default_value,
- ::google::protobuf::Arena* arena) {
- if (arena == nullptr) {
- GOOGLE_DCHECK(!IsDonatedString());
- if (!IsDefault(default_value)) {
- delete UnsafeMutablePointer();
- }
+void ArenaStringPtr::Destroy() {
+ if (tagged_ptr_.IsAllocated()) {
+ delete tagged_ptr_.Get();
}
}
-void ArenaStringPtr::Destroy(EmptyDefault, ::google::protobuf::Arena* arena) {
- Destroy(&GetEmptyStringAlreadyInited(), arena);
-}
-
-void ArenaStringPtr::Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena) {
- Destroy(nullptr, arena);
-}
-
void ArenaStringPtr::ClearToEmpty() {
- if (IsDefault(&GetEmptyStringAlreadyInited())) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
+ if (IsDefault()) {
// Already set to default -- do nothing.
} else {
// Unconditionally mask away the tag.
//
- // UpdateDonatedString uses assign when capacity is larger than the new
+ // UpdateArenaString uses assign when capacity is larger than the new
// value, which is trivially true in the donated string case.
// const_cast<TProtoStringType*>(PtrValue<TProtoStringType>())->clear();
tagged_ptr_.Get()->clear();
@@ -248,34 +237,27 @@ void ArenaStringPtr::ClearToEmpty() {
void ArenaStringPtr::ClearToDefault(const LazyString& default_value,
::google::protobuf::Arena* arena) {
+ ScopedCheckPtrInvariants check(&tagged_ptr_);
(void)arena;
- if (IsDefault(nullptr)) {
+ if (IsDefault()) {
// Already set to default -- do nothing.
- } else if (!IsDonatedString()) {
+ } else {
UnsafeMutablePointer()->assign(default_value.get());
}
}
-inline void SetStrWithHeapBuffer(TProtoStringType* str, ArenaStringPtr* s) {
- TaggedPtr<TProtoStringType> res;
- res.Set(str);
- s->UnsafeSetTaggedPointer(res);
-}
-
const char* EpsCopyInputStream::ReadArenaString(const char* ptr,
ArenaStringPtr* s,
Arena* arena) {
+ ScopedCheckPtrInvariants check(&s->tagged_ptr_);
GOOGLE_DCHECK(arena != nullptr);
int size = ReadSize(&ptr);
if (!ptr) return nullptr;
- auto* str = Arena::Create<TProtoStringType>(arena);
+ auto* str = s->NewString(arena);
ptr = ReadString(ptr, size, str);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
-
- SetStrWithHeapBuffer(str, s);
-
return ptr;
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenastring.h b/contrib/libs/protobuf/src/google/protobuf/arenastring.h
index f9e65a9fc8..3619a9b930 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arenastring.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arenastring.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_ARENASTRING_H__
#define GOOGLE_PROTOBUF_ARENASTRING_H__
+#include <algorithm>
#include <string>
#include <type_traits>
#include <utility>
@@ -39,7 +40,9 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/explicitly_constructed.h>
+// must be last:
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -50,12 +53,14 @@
namespace google {
namespace protobuf {
namespace internal {
-
-template <typename T>
-class ExplicitlyConstructed;
+class EpsCopyInputStream;
class SwapFieldHelper;
+// Declared in message_lite.h
+PROTOBUF_EXPORT extern ExplicitlyConstructedArenaString
+ fixed_address_empty_string;
+
// Lazy string instance to support string fields with non-empty default.
// These are initialized on the first call to .get().
class PROTOBUF_EXPORT LazyString {
@@ -89,182 +94,222 @@ class PROTOBUF_EXPORT LazyString {
const TProtoStringType& Init() const;
};
-template <typename T>
-class TaggedPtr {
+class TaggedStringPtr {
public:
- TaggedPtr() = default;
- explicit constexpr TaggedPtr(const ExplicitlyConstructed<TProtoStringType>* ptr)
- : ptr_(const_cast<ExplicitlyConstructed<TProtoStringType>*>(ptr)) {}
+ // Bit flags qualifying string properties. We can use up to 3 bits as
+ // ptr_ is guaranteed and enforced to be aligned on 8 byte boundaries.
+ enum Flags {
+ kArenaBit = 0x1, // ptr is arena allocated
+ kAllocatedBit = 0x2, // ptr is heap allocated
+ kMutableBit = 0x4, // ptr contents are fully mutable
+ kMask = 0x7 // Bit mask
+ };
+
+ // Composed logical types
+ enum Type {
+ // Default strings are immutable and never owned.
+ kDefault = 0,
+
+ // Allocated strings are mutable and (as the name implies) owned.
+ // A heap allocated string must be deleted.
+ kAllocated = kAllocatedBit | kMutableBit,
+
+ // Mutable arena strings are strings where the string instance is owned
+ // by the arena, but the string contents itself are owned by the string
+ // instance. Mutable arena string instances need to be destroyed which is
+ // typically done through a cleanup action added to the arena owning it.
+ kMutableArena = kArenaBit | kMutableBit,
+
+ // Fixed size arena strings are strings where both the string instance and
+ // the string contents are fully owned by the arena. Fixed size arena
+ // strings are a platform and c++ library specific customization. Fixed
+ // size arena strings are immutable, with the exception of custom internal
+ // updates to the content that fit inside the existing capacity.
+ // Fixed size arena strings must never be deleted or destroyed.
+ kFixedSizeArena = kArenaBit,
+ };
+
+ TaggedStringPtr() = default;
+ explicit constexpr TaggedStringPtr(ExplicitlyConstructedArenaString* ptr)
+ : ptr_(ptr) {}
+
+ // Sets the value to `p`, tagging the value as being a 'default' value.
+ // See documentation for kDefault for more info.
+ inline const TProtoStringType* SetDefault(const TProtoStringType* p) {
+ return TagAs(kDefault, const_cast<TProtoStringType*>(p));
+ }
+
+ // Sets the value to `p`, tagging the value as a heap allocated value.
+ // Allocated strings are mutable and (as the name implies) owned.
+ // `p` must not be null
+ inline TProtoStringType* SetAllocated(TProtoStringType* p) {
+ return TagAs(kAllocated, p);
+ }
- void SetTagged(T* p) {
- Set(p);
- ptr_ = reinterpret_cast<void*>(as_int() | 1);
+ // Sets the value to `p`, tagging the value as a fixed size arena string.
+ // See documentation for kFixedSizeArena for more info.
+ // `p` must not be null
+ inline TProtoStringType* SetFixedSizeArena(TProtoStringType* p) {
+ return TagAs(kFixedSizeArena, p);
}
- void Set(T* p) { ptr_ = p; }
- T* Get() const { return reinterpret_cast<T*>(as_int() & -2); }
- bool IsTagged() const { return as_int() & 1; }
- // Returned value is only safe to dereference if IsTagged() == false.
- // It is safe to compare.
- T* UnsafeGet() const { return static_cast<T*>(ptr_); }
+ // Sets the value to `p`, tagging the value as a mutable arena string.
+ // See documentation for kMutableArena for more info.
+ // `p` must not be null
+ inline TProtoStringType* SetMutableArena(TProtoStringType* p) {
+ return TagAs(kMutableArena, p);
+ }
+
+ // Returns true if the contents of the current string are fully mutable.
+ inline bool IsMutable() const { return as_int() & kMutableBit; }
+
+ // Returns true if the current string is an immutable default value.
+ inline bool IsDefault() const { return (as_int() & kMask) == kDefault; }
+
+ // Returns true if the current string is a heap allocated mutable value.
+ inline bool IsAllocated() const { return as_int() & kAllocatedBit; }
+
+ // Returns true if the current string is an arena allocated value.
+ // This means it's either a mutable or fixed size arena string.
+ inline bool IsArena() const { return as_int() & kArenaBit; }
- bool IsNull() { return ptr_ == nullptr; }
+ // Returns true if the current string is a fixed size arena allocated value.
+ inline bool IsFixedSizeArena() const {
+ return (as_int() & kMask) == kFixedSizeArena;
+ }
+
+ // Returns the contained string pointer.
+ inline TProtoStringType* Get() const {
+ return reinterpret_cast<TProtoStringType*>(as_int() & ~kMask);
+ }
+
+ // Returns true if the contained pointer is null, indicating some error.
+ // The Null value is only used during parsing for temporary values.
+ // A persisted ArenaStringPtr value is never null.
+ inline bool IsNull() { return ptr_ == nullptr; }
private:
+ static inline void assert_aligned(const void* p) {
+ GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL);
+ }
+
+ inline TProtoStringType* TagAs(Type type, TProtoStringType* p) {
+ GOOGLE_DCHECK(p != nullptr);
+ assert_aligned(p);
+ ptr_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(p) | type);
+ return p;
+ }
+
uintptr_t as_int() const { return reinterpret_cast<uintptr_t>(ptr_); }
void* ptr_;
};
-static_assert(std::is_trivial<TaggedPtr<TProtoStringType>>::value,
- "TaggedPtr must be trivial");
+static_assert(std::is_trivial<TaggedStringPtr>::value,
+ "TaggedStringPtr must be trivial");
-// This class encapsulates a pointer to a TProtoStringType with or without a donated
-// buffer, tagged by bottom bit. It is a high-level wrapper that almost directly
-// corresponds to the interface required by string fields in generated
-// code. It replaces the old TProtoStringType* pointer in such cases.
-//
-// The object has different but similar code paths for when the default value is
-// the empty string and when it is a non-empty string.
-// The empty string is handled different throughout the library and there is a
-// single global instance of it we can share.
-//
-// For fields with an empty string default value, there are three distinct
-// states:
-//
-// - Pointer set to 'String' tag (LSB is 0), equal to
-// &GetEmptyStringAlreadyInited(): field is set to its default value. Points
-// to a true TProtoStringType*, but we do not own that TProtoStringType* (it's a
-// globally shared instance).
-//
-// - Pointer set to 'String' tag (LSB is 0), but not equal to the global empty
-// string: field points to a true TProtoStringType* instance that we own. This
-// instance is either on the heap or on the arena (i.e. registered on
-// free()/destructor-call list) as appropriate.
-//
-// - Pointer set to 'DonatedString' tag (LSB is 1): points to a TProtoStringType
-// instance with a buffer on the arena (arena is never nullptr in this case).
-//
-// For fields with a non-empty string default value, there are three distinct
-// states:
-//
-// - Pointer set to 'String' tag (LSB is 0), equal to `nullptr`:
-// Field is in "default" mode and does not point to any actual instance.
-// Methods that might need to create an instance of the object will pass a
-// `const LazyString&` for it.
+// This class encapsulates a pointer to a TProtoStringType with or without arena
+// owned contents, tagged by the bottom bits of the string pointer. It is a
+// high-level wrapper that almost directly corresponds to the interface required
+// by string fields in generated code. It replaces the old TProtoStringType* pointer
+// in such cases.
//
-// - Pointer set to 'String' tag (LSB is 0), but not equal to `nullptr`:
-// field points to a true TProtoStringType* instance that we own. This instance is
-// either on the heap or on the arena (i.e. registered on
-// free()/destructor-call list) as appropriate.
+// The string pointer is tagged to be either a default, externally owned value,
+// a mutable heap allocated value, or an arena allocated value. The object uses
+// a single global instance of an empty string that is used as the initial
+// default value. Fields that have empty default values directly use this global
+// default. Fields that have non empty default values are supported through
+// lazily initialized default values managed by the LazyString class.
//
-// - Pointer set to 'DonatedString' tag (LSB is 1): points to a TProtoStringType
-// instance with a buffer on the arena (arena is never nullptr in this case).
-//
-// Generated code and reflection code both ensure that ptr_ is never null for
-// fields with an empty default.
+// Generated code and reflection code both ensure that ptr_ is never null.
// Because ArenaStringPtr is used in oneof unions, its constructor is a NOP and
-// so the field is always manually initialized via method calls.
+// the field is always manually initialized via method calls.
//
-// Side-note: why pass information about the default on every API call? Because
-// we don't want to hold it in a member variable, or else this would go into
-// every proto message instance. This would be a huge waste of space, since the
-// default instance pointer is typically a global (static class field). We want
-// the generated code to be as efficient as possible, and if we take
-// the default value information as a parameter that's in practice taken from a
-// static class field, and compare ptr_ to the default value, we end up with a
-// single "cmp %reg, GLOBAL" in the resulting machine code. (Note that this also
-// requires the String tag to be 0 so we can avoid the mask before comparing.)
+// See TaggedPtr for more information about the types of string values being
+// held, and the mutable and ownership invariants for each type.
struct PROTOBUF_EXPORT ArenaStringPtr {
ArenaStringPtr() = default;
- explicit constexpr ArenaStringPtr(
- const ExplicitlyConstructed<TProtoStringType>* default_value)
+ constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value,
+ ConstantInitialized)
: tagged_ptr_(default_value) {}
- // Some methods below are overloaded on a `default_value` and on tags.
- // The tagged overloads help reduce code size in the callers in generated
- // code, while the `default_value` overloads are useful from reflection.
- // By-value empty struct arguments are elided in the ABI.
- struct EmptyDefault {};
- struct NonEmptyDefault {};
-
- void Set(const TProtoStringType* default_value, ConstStringParam value,
- ::google::protobuf::Arena* arena);
- void Set(const TProtoStringType* default_value, TProtoStringType&& value,
- ::google::protobuf::Arena* arena);
- void Set(EmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena);
- void Set(EmptyDefault, TProtoStringType&& value, ::google::protobuf::Arena* arena);
- void Set(NonEmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena);
- void Set(NonEmptyDefault, TProtoStringType&& value, ::google::protobuf::Arena* arena);
- template <typename FirstParam>
- void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena) {
- Set(p1, ConstStringParam(str), arena);
- }
- template <typename FirstParam>
- void Set(FirstParam p1, const char* str, size_t size,
- ::google::protobuf::Arena* arena) {
- ConstStringParam sp{str, size}; // for string_view and `const string &`
- Set(p1, sp, arena);
- }
- template <typename FirstParam, typename RefWrappedType>
- void Set(FirstParam p1,
- std::reference_wrapper<RefWrappedType> const_string_ref,
+ // Called from generated code / reflection runtime only. Resets value to point
+ // to a default string pointer, with the semantics that this ArenaStringPtr
+ // does not own the pointed-to memory. Disregards initial value of ptr_ (so
+ // this is the *ONLY* safe method to call after construction or when
+ // reinitializing after becoming the active field in a oneof union).
+ inline void InitDefault();
+
+ // Similar to `InitDefault` except that it allows the default value to be
+ // initialized to an externally owned string. This method is called from
+ // parsing code. `str` must not be null and outlive this instance.
+ inline void InitExternal(const TProtoStringType* str);
+
+ // Called from generated code / reflection runtime only. Resets the value of
+ // this instances to the heap allocated value in `str`. `str` must not be
+ // null. Invokes `arena->Own(str)` to transfer ownership into the arena if
+ // `arena` is not null, else, `str` will be owned by ArenaStringPtr. This
+ // function should only be used to initialize a ArenaStringPtr or on an
+ // instance known to not carry any heap allocated value.
+ inline void InitAllocated(TProtoStringType* str, Arena* arena);
+
+ void Set(ConstStringParam value, Arena* arena);
+ void Set(TProtoStringType&& value, Arena* arena);
+ void Set(const char* s, Arena* arena);
+ void Set(const char* s, size_t n, Arena* arena);
+
+ void SetBytes(ConstStringParam value, Arena* arena);
+ void SetBytes(TProtoStringType&& value, Arena* arena);
+ void SetBytes(const char* s, Arena* arena);
+ void SetBytes(const void* p, size_t n, Arena* arena);
+
+ template <typename RefWrappedType>
+ void Set(std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena) {
- Set(p1, const_string_ref.get(), arena);
+ Set(const_string_ref.get(), arena);
}
- template <typename FirstParam, typename SecondParam>
- void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena) {
- Set(p1, static_cast<SecondParam&&>(p2), arena);
- }
- template <typename FirstParam>
- void SetBytes(FirstParam p1, const void* str, size_t size,
- ::google::protobuf::Arena* arena) {
- // must work whether ConstStringParam is string_view or `const string &`
- ConstStringParam sp{static_cast<const char*>(str), size};
- Set(p1, sp, arena);
- }
+ // Returns a mutable TProtoStringType reference.
+ // The version accepting a `LazyString` value is used in the generated code to
+ // initialize mutable copies for fields with a non-empty default where the
+ // default value is lazily initialized.
+ TProtoStringType* Mutable(Arena* arena);
+ TProtoStringType* Mutable(const LazyString& default_value, Arena* arena);
+
+ // Gets a mutable pointer with unspecified contents.
+ // This function is identical to Mutable(), except it is optimized for the
+ // case where the caller is not interested in the current contents. For
+ // example, if the current field is not mutable, it will re-initialize the
+ // value with an empty string rather than a (non-empty) default value.
+ // Likewise, if the current value is a fixed size arena string with contents,
+ // it will be initialized into an empty mutable arena string.
+ TProtoStringType* MutableNoCopy(Arena* arena);
// Basic accessors.
PROTOBUF_NDEBUG_INLINE const TProtoStringType& Get() const {
// Unconditionally mask away the tag.
return *tagged_ptr_.Get();
}
- PROTOBUF_NDEBUG_INLINE const TProtoStringType* GetPointer() const {
- // Unconditionally mask away the tag.
+
+ // Returns a pointer to the stored contents for this instance.
+ // This method is for internal debugging and tracking purposes only.
+ PROTOBUF_NDEBUG_INLINE const TProtoStringType* UnsafeGetPointer() const
+ PROTOBUF_RETURNS_NONNULL {
return tagged_ptr_.Get();
}
- // For fields with an empty default value.
- TProtoStringType* Mutable(EmptyDefault, ::google::protobuf::Arena* arena);
- // For fields with a non-empty default value.
- TProtoStringType* Mutable(const LazyString& default_value, ::google::protobuf::Arena* arena);
-
// Release returns a TProtoStringType* instance that is heap-allocated and is not
// Own()'d by any arena. If the field is not set, this returns nullptr. The
- // caller retains ownership. Clears this field back to nullptr state. Used to
- // implement release_<field>() methods on generated classes.
- PROTOBUF_NODISCARD TProtoStringType* Release(const TProtoStringType* default_value,
- ::google::protobuf::Arena* arena);
- PROTOBUF_NODISCARD TProtoStringType* ReleaseNonDefault(
- const TProtoStringType* default_value, ::google::protobuf::Arena* arena);
+ // caller retains ownership. Clears this field back to the default state.
+ // Used to implement release_<field>() methods on generated classes.
+ PROTOBUF_NODISCARD TProtoStringType* Release();
// Takes a TProtoStringType that is heap-allocated, and takes ownership. The
// TProtoStringType's destructor is registered with the arena. Used to implement
// set_allocated_<field> in generated classes.
- void SetAllocated(const TProtoStringType* default_value, TProtoStringType* value,
- ::google::protobuf::Arena* arena);
-
- // Swaps internal pointers. Arena-safety semantics: this is guarded by the
- // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
- // 'unsafe' if called directly.
- inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(
- const TProtoStringType* default_value, ArenaStringPtr* rhs, Arena* rhs_arena,
- ArenaStringPtr* lhs, Arena* lhs_arena);
+ void SetAllocated(TProtoStringType* value, Arena* arena);
// Frees storage (if not on an arena).
- void Destroy(const TProtoStringType* default_value, ::google::protobuf::Arena* arena);
- void Destroy(EmptyDefault, ::google::protobuf::Arena* arena);
- void Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena);
+ void Destroy();
// Clears content, but keeps allocated TProtoStringType, to avoid the overhead of
// heap operations. After this returns, the content (as seen by the user) will
@@ -281,48 +326,40 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// (as seen by the user) will always be equal to |default_value|.
void ClearToDefault(const LazyString& default_value, ::google::protobuf::Arena* arena);
- // Called from generated code / reflection runtime only. Resets value to point
- // to a default string pointer, with the semantics that this
- // ArenaStringPtr does not own the pointed-to memory. Disregards initial value
- // of ptr_ (so this is the *ONLY* safe method to call after construction or
- // when reinitializing after becoming the active field in a oneof union).
- inline void UnsafeSetDefault(const TProtoStringType* default_value);
-
- // Returns a mutable pointer, but doesn't initialize the string to the
- // default value.
- TProtoStringType* MutableNoArenaNoDefault(const TProtoStringType* default_value);
-
- // Get a mutable pointer with unspecified contents.
- // Similar to `MutableNoArenaNoDefault`, but also handles the arena case.
- // If the value was donated, the contents are discarded.
- TProtoStringType* MutableNoCopy(const TProtoStringType* default_value,
- ::google::protobuf::Arena* arena);
-
- // Destroy the string. Assumes `arena == nullptr`.
- void DestroyNoArena(const TProtoStringType* default_value);
+ // Swaps internal pointers. Arena-safety semantics: this is guarded by the
+ // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
+ // 'unsafe' if called directly.
+ inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(ArenaStringPtr* rhs,
+ Arena* rhs_arena,
+ ArenaStringPtr* lhs,
+ Arena* lhs_arena);
// Internal setter used only at parse time to directly set a donated string
// value.
- void UnsafeSetTaggedPointer(TaggedPtr<TProtoStringType> value) {
- tagged_ptr_ = value;
- }
+ void UnsafeSetTaggedPointer(TaggedStringPtr value) { tagged_ptr_ = value; }
// Generated code only! An optimization, in certain cases the generated
// code is certain we can obtain a TProtoStringType with no default checks and
// tag tests.
TProtoStringType* UnsafeMutablePointer() PROTOBUF_RETURNS_NONNULL;
- inline bool IsDefault(const TProtoStringType* default_value) const {
- // Relies on the fact that kPtrTagString == 0, so if IsString(), ptr_ is the
- // actual TProtoStringType pointer (and if !IsString(), ptr_ will never be equal
- // to any aligned |default_value| pointer). The key is that we want to avoid
- // masking in the fastpath const-pointer Get() case for non-arena code.
- return tagged_ptr_.UnsafeGet() == default_value;
- }
+ // Returns true if this instances holds an immutable default value.
+ inline bool IsDefault() const { return tagged_ptr_.IsDefault(); }
private:
- TaggedPtr<TProtoStringType> tagged_ptr_;
+ template <typename... Args>
+ inline TProtoStringType* NewString(Arena* arena, Args&&... args) {
+ if (arena == nullptr) {
+ auto* s = new TProtoStringType(std::forward<Args>(args)...);
+ return tagged_ptr_.SetAllocated(s);
+ } else {
+ auto* s = Arena::Create<TProtoStringType>(arena, std::forward<Args>(args)...);
+ return tagged_ptr_.SetMutableArena(s);
+ }
+ }
+
+ TaggedStringPtr tagged_ptr_;
- bool IsDonatedString() const { return false; }
+ bool IsFixedSizeArena() const { return false; }
// Swaps tagged pointer without debug hardening. This is to allow python
// protobuf to maintain pointer stability even in DEBUG builds.
@@ -332,46 +369,81 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
}
friend class ::google::protobuf::internal::SwapFieldHelper;
+ friend class TcParser;
// Slow paths.
// MutableSlow requires that !IsString() || IsDefault
- // Variadic to support 0 args for EmptyDefault and 1 arg for LazyString.
+ // Variadic to support 0 args for empty default and 1 arg for LazyString.
template <typename... Lazy>
TProtoStringType* MutableSlow(::google::protobuf::Arena* arena, const Lazy&... lazy_default);
- // Sets value to a newly allocated string and returns it
- TProtoStringType* SetAndReturnNewString();
+ friend class EpsCopyInputStream;
+};
- // Destroys the non-default string value out-of-line
- void DestroyNoArenaSlowPath();
+inline void ArenaStringPtr::InitDefault() {
+ tagged_ptr_ = TaggedStringPtr(&fixed_address_empty_string);
+}
-};
+inline void ArenaStringPtr::InitExternal(const TProtoStringType* str) {
+ tagged_ptr_.SetDefault(str);
+}
+
+inline void ArenaStringPtr::InitAllocated(TProtoStringType* str, Arena* arena) {
+ if (arena != nullptr) {
+ tagged_ptr_.SetMutableArena(str);
+ arena->Own(str);
+ } else {
+ tagged_ptr_.SetAllocated(str);
+ }
+}
+
+inline void ArenaStringPtr::Set(const char* s, Arena* arena) {
+ Set(ConstStringParam{s}, arena);
+}
+
+inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) {
+ Set(ConstStringParam{s, n}, arena);
+}
+
+inline void ArenaStringPtr::SetBytes(ConstStringParam value, Arena* arena) {
+ Set(value, arena);
+}
+
+inline void ArenaStringPtr::SetBytes(TProtoStringType&& value, Arena* arena) {
+ Set(std::move(value), arena);
+}
+
+inline void ArenaStringPtr::SetBytes(const char* s, Arena* arena) {
+ Set(s, arena);
+}
-inline void ArenaStringPtr::UnsafeSetDefault(const TProtoStringType* value) {
- tagged_ptr_.Set(const_cast<TProtoStringType*>(value));
+inline void ArenaStringPtr::SetBytes(const void* p, size_t n, Arena* arena) {
+ Set(ConstStringParam{static_cast<const char*>(p), n}, arena);
}
// Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs.
inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( //
- const TProtoStringType* default_value, //
ArenaStringPtr* rhs, Arena* rhs_arena, //
ArenaStringPtr* lhs, Arena* lhs_arena) {
// Silence unused variable warnings in release buildls.
- (void)default_value;
(void)rhs_arena;
(void)lhs_arena;
std::swap(lhs->tagged_ptr_, rhs->tagged_ptr_);
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
- auto force_realloc = [default_value](ArenaStringPtr* p, Arena* arena) {
- if (p->IsDefault(default_value)) return;
+ auto force_realloc = [](ArenaStringPtr* p, Arena* arena) {
+ if (p->IsDefault()) return;
TProtoStringType* old_value = p->tagged_ptr_.Get();
TProtoStringType* new_value =
- p->IsDonatedString()
+ p->IsFixedSizeArena()
? Arena::Create<TProtoStringType>(arena, *old_value)
: Arena::Create<TProtoStringType>(arena, std::move(*old_value));
- if (arena == nullptr) delete old_value;
- p->tagged_ptr_.Set(new_value);
+ if (arena == nullptr) {
+ delete old_value;
+ p->tagged_ptr_.SetAllocated(new_value);
+ } else {
+ p->tagged_ptr_.SetMutableArena(new_value);
+ }
};
// Because, at this point, tagged_ptr_ has been swapped, arena should also be
// swapped.
@@ -385,29 +457,10 @@ inline void ArenaStringPtr::ClearNonDefaultToEmpty() {
tagged_ptr_.Get()->clear();
}
-inline TProtoStringType* ArenaStringPtr::MutableNoArenaNoDefault(
- const TProtoStringType* default_value) {
- // VERY IMPORTANT for performance and code size: this will reduce to a member
- // variable load, a pointer check (against |default_value|, in practice a
- // static global) and a branch to the slowpath (which calls operator new and
- // the ctor). DO NOT add any tagged-pointer operations here.
- if (IsDefault(default_value)) {
- return SetAndReturnNewString();
- } else {
- return UnsafeMutablePointer();
- }
-}
-
-inline void ArenaStringPtr::DestroyNoArena(const TProtoStringType* default_value) {
- if (!IsDefault(default_value)) {
- DestroyNoArenaSlowPath();
- }
-}
-
inline TProtoStringType* ArenaStringPtr::UnsafeMutablePointer() {
- GOOGLE_DCHECK(!tagged_ptr_.IsTagged());
- GOOGLE_DCHECK(tagged_ptr_.UnsafeGet() != nullptr);
- return tagged_ptr_.UnsafeGet();
+ GOOGLE_DCHECK(tagged_ptr_.IsMutable());
+ GOOGLE_DCHECK(tagged_ptr_.Get() != nullptr);
+ return tagged_ptr_.Get();
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc
new file mode 100644
index 0000000000..400ac04c30
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc
@@ -0,0 +1,177 @@
+// 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.
+
+#include <google/protobuf/arenaz_sampler.h>
+
+#include <atomic>
+#include <cstdint>
+#include <limits>
+
+
+// Must be included last.
+#include <google/protobuf/port_def.inc>
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+ThreadSafeArenazSampler& GlobalThreadSafeArenazSampler() {
+ static auto* sampler = new ThreadSafeArenazSampler();
+ return *sampler;
+}
+
+void UnsampleSlow(ThreadSafeArenaStats* info) {
+ GlobalThreadSafeArenazSampler().Unregister(info);
+}
+
+#if defined(PROTOBUF_ARENAZ_SAMPLE)
+namespace {
+
+PROTOBUF_CONSTINIT std::atomic<bool> g_arenaz_enabled{true};
+PROTOBUF_CONSTINIT std::atomic<arc_i32> g_arenaz_sample_parameter{1 << 20};
+PROTOBUF_THREAD_LOCAL absl::profiling_internal::ExponentialBiased
+ g_exponential_biased_generator;
+
+} // namespace
+
+PROTOBUF_THREAD_LOCAL arc_i64 global_next_sample = 1LL << 20;
+
+ThreadSafeArenaStats::ThreadSafeArenaStats() { PrepareForSampling(); }
+ThreadSafeArenaStats::~ThreadSafeArenaStats() = default;
+
+void ThreadSafeArenaStats::PrepareForSampling() {
+ num_allocations.store(0, std::memory_order_relaxed);
+ num_resets.store(0, std::memory_order_relaxed);
+ bytes_requested.store(0, std::memory_order_relaxed);
+ bytes_allocated.store(0, std::memory_order_relaxed);
+ bytes_wasted.store(0, std::memory_order_relaxed);
+ max_bytes_allocated.store(0, std::memory_order_relaxed);
+ thread_ids.store(0, std::memory_order_relaxed);
+ // The inliner makes hardcoded skip_count difficult (especially when combined
+ // with LTO). We use the ability to exclude stacks by regex when encoding
+ // instead.
+ depth = absl::GetStackTrace(stack, kMaxStackDepth, /* skip_count= */ 0);
+}
+
+void RecordResetSlow(ThreadSafeArenaStats* info) {
+ const size_t max_bytes =
+ info->max_bytes_allocated.load(std::memory_order_relaxed);
+ const size_t allocated_bytes =
+ info->bytes_allocated.load(std::memory_order_relaxed);
+ if (max_bytes < allocated_bytes) {
+ info->max_bytes_allocated.store(allocated_bytes);
+ }
+ info->bytes_requested.store(0, std::memory_order_relaxed);
+ info->bytes_allocated.store(0, std::memory_order_relaxed);
+ info->bytes_wasted.fetch_add(0, std::memory_order_relaxed);
+ info->num_allocations.fetch_add(0, std::memory_order_relaxed);
+ info->num_resets.fetch_add(1, std::memory_order_relaxed);
+}
+
+void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested,
+ size_t allocated, size_t wasted) {
+ info->bytes_requested.fetch_add(requested, std::memory_order_relaxed);
+ info->bytes_allocated.fetch_add(allocated, std::memory_order_relaxed);
+ info->bytes_wasted.fetch_add(wasted, std::memory_order_relaxed);
+ info->num_allocations.fetch_add(1, std::memory_order_relaxed);
+ const arc_ui64 tid = (1ULL << (GetCachedTID() % 63));
+ const arc_ui64 thread_ids = info->thread_ids.load(std::memory_order_relaxed);
+ if (!(thread_ids & tid)) {
+ info->thread_ids.store(thread_ids | tid, std::memory_order_relaxed);
+ }
+}
+
+ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample) {
+ bool first = *next_sample < 0;
+ *next_sample = g_exponential_biased_generator.GetStride(
+ g_arenaz_sample_parameter.load(std::memory_order_relaxed));
+ // Small values of interval are equivalent to just sampling next time.
+ ABSL_ASSERT(*next_sample >= 1);
+
+ // g_arenaz_enabled can be dynamically flipped, we need to set a threshold low
+ // enough that we will start sampling in a reasonable time, so we just use the
+ // default sampling rate.
+ if (!g_arenaz_enabled.load(std::memory_order_relaxed)) return nullptr;
+ // We will only be negative on our first count, so we should just retry in
+ // that case.
+ if (first) {
+ if (PROTOBUF_PREDICT_TRUE(--*next_sample > 0)) return nullptr;
+ return SampleSlow(next_sample);
+ }
+
+ return GlobalThreadSafeArenazSampler().Register();
+}
+
+void SetThreadSafeArenazEnabled(bool enabled) {
+ g_arenaz_enabled.store(enabled, std::memory_order_release);
+}
+
+void SetThreadSafeArenazSampleParameter(arc_i32 rate) {
+ if (rate > 0) {
+ g_arenaz_sample_parameter.store(rate, std::memory_order_release);
+ } else {
+ ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz sample rate: %lld",
+ static_cast<long long>(rate)); // NOLINT(runtime/int)
+ }
+}
+
+void SetThreadSafeArenazMaxSamples(arc_i32 max) {
+ if (max > 0) {
+ GlobalThreadSafeArenazSampler().SetMaxSamples(max);
+ } else {
+ ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz max samples: %lld",
+ static_cast<long long>(max)); // NOLINT(runtime/int)
+ }
+}
+
+void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample) {
+ if (next_sample >= 0) {
+ global_next_sample = next_sample;
+ } else {
+ ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz next sample: %lld",
+ static_cast<long long>(next_sample)); // NOLINT(runtime/int)
+ }
+}
+
+#else
+ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample) {
+ *next_sample = std::numeric_limits<arc_i64>::max();
+ return nullptr;
+}
+
+void SetThreadSafeArenazEnabled(bool enabled) {}
+void SetThreadSafeArenazSampleParameter(arc_i32 rate) {}
+void SetThreadSafeArenazMaxSamples(arc_i32 max) {}
+void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample) {}
+#endif // defined(PROTOBUF_ARENAZ_SAMPLE)
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h
new file mode 100644
index 0000000000..470b660e83
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h
@@ -0,0 +1,208 @@
+// 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.
+
+#ifndef GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__
+#define GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__
+
+#include <atomic>
+#include <cstddef>
+#include <cstdint>
+
+#include <google/protobuf/stubs/port.h>
+
+// Must be included last.
+#include <google/protobuf/port_def.inc>
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+#if defined(PROTOBUF_ARENAZ_SAMPLE)
+struct ThreadSafeArenaStats;
+void RecordResetSlow(ThreadSafeArenaStats* info);
+void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested,
+ size_t allocated, size_t wasted);
+// Stores information about a sampled thread safe arena. All mutations to this
+// *must* be made through `Record*` functions below. All reads from this *must*
+// only occur in the callback to `ThreadSafeArenazSampler::Iterate`.
+struct ThreadSafeArenaStats
+ : public absl::profiling_internal::Sample<ThreadSafeArenaStats> {
+ // Constructs the object but does not fill in any fields.
+ ThreadSafeArenaStats();
+ ~ThreadSafeArenaStats();
+
+ // Puts the object into a clean state, fills in the logically `const` members,
+ // blocking for any readers that are currently sampling the object.
+ void PrepareForSampling() ABSL_EXCLUSIVE_LOCKS_REQUIRED(init_mu);
+
+ // These fields are mutated by the various Record* APIs and need to be
+ // thread-safe.
+ std::atomic<int> num_allocations;
+ std::atomic<int> num_resets;
+ std::atomic<size_t> bytes_requested;
+ std::atomic<size_t> bytes_allocated;
+ std::atomic<size_t> bytes_wasted;
+ // Records the largest size an arena ever had. Maintained across resets.
+ std::atomic<size_t> max_bytes_allocated;
+ // Bit i when set to 1 indicates that a thread with tid % 63 = i accessed the
+ // underlying arena. The field is maintained across resets.
+ std::atomic<arc_ui64> thread_ids;
+
+ // All of the fields below are set by `PrepareForSampling`, they must not
+ // be mutated in `Record*` functions. They are logically `const` in that
+ // sense. These are guarded by init_mu, but that is not externalized to
+ // clients, who can only read them during
+ // `ThreadSafeArenazSampler::Iterate` which will hold the lock.
+ static constexpr int kMaxStackDepth = 64;
+ arc_i32 depth;
+ void* stack[kMaxStackDepth];
+ static void RecordAllocateStats(ThreadSafeArenaStats* info, size_t requested,
+ size_t allocated, size_t wasted) {
+ if (PROTOBUF_PREDICT_TRUE(info == nullptr)) return;
+ RecordAllocateSlow(info, requested, allocated, wasted);
+ }
+};
+
+ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample);
+void UnsampleSlow(ThreadSafeArenaStats* info);
+
+class ThreadSafeArenaStatsHandle {
+ public:
+ explicit ThreadSafeArenaStatsHandle() = default;
+ explicit ThreadSafeArenaStatsHandle(ThreadSafeArenaStats* info)
+ : info_(info) {}
+
+ ~ThreadSafeArenaStatsHandle() {
+ if (PROTOBUF_PREDICT_TRUE(info_ == nullptr)) return;
+ UnsampleSlow(info_);
+ }
+
+ ThreadSafeArenaStatsHandle(ThreadSafeArenaStatsHandle&& other) noexcept
+ : info_(absl::exchange(other.info_, nullptr)) {}
+
+ ThreadSafeArenaStatsHandle& operator=(
+ ThreadSafeArenaStatsHandle&& other) noexcept {
+ if (PROTOBUF_PREDICT_FALSE(info_ != nullptr)) {
+ UnsampleSlow(info_);
+ }
+ info_ = absl::exchange(other.info_, nullptr);
+ return *this;
+ }
+
+ void RecordReset() {
+ if (PROTOBUF_PREDICT_TRUE(info_ == nullptr)) return;
+ RecordResetSlow(info_);
+ }
+
+ ThreadSafeArenaStats* MutableStats() { return info_; }
+
+ friend void swap(ThreadSafeArenaStatsHandle& lhs,
+ ThreadSafeArenaStatsHandle& rhs) {
+ std::swap(lhs.info_, rhs.info_);
+ }
+
+ friend class ThreadSafeArenaStatsHandlePeer;
+
+ private:
+ ThreadSafeArenaStats* info_ = nullptr;
+};
+
+using ThreadSafeArenazSampler =
+ ::absl::profiling_internal::SampleRecorder<ThreadSafeArenaStats>;
+
+extern PROTOBUF_THREAD_LOCAL arc_i64 global_next_sample;
+
+// Returns an RAII sampling handle that manages registration and unregistation
+// with the global sampler.
+inline ThreadSafeArenaStatsHandle Sample() {
+ if (PROTOBUF_PREDICT_TRUE(--global_next_sample > 0)) {
+ return ThreadSafeArenaStatsHandle(nullptr);
+ }
+ return ThreadSafeArenaStatsHandle(SampleSlow(&global_next_sample));
+}
+
+#else
+struct ThreadSafeArenaStats {
+ static void RecordAllocateStats(ThreadSafeArenaStats*, size_t /*requested*/,
+ size_t /*allocated*/, size_t /*wasted*/) {}
+};
+
+ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample);
+void UnsampleSlow(ThreadSafeArenaStats* info);
+
+class ThreadSafeArenaStatsHandle {
+ public:
+ explicit ThreadSafeArenaStatsHandle() = default;
+ explicit ThreadSafeArenaStatsHandle(ThreadSafeArenaStats*) {}
+
+ void RecordReset() {}
+
+ ThreadSafeArenaStats* MutableStats() { return nullptr; }
+
+ friend void swap(ThreadSafeArenaStatsHandle&, ThreadSafeArenaStatsHandle&) {}
+
+ private:
+ friend class ThreadSafeArenaStatsHandlePeer;
+};
+
+class ThreadSafeArenazSampler {
+ public:
+ void Unregister(ThreadSafeArenaStats*) {}
+ void SetMaxSamples(arc_i32) {}
+};
+
+// Returns an RAII sampling handle that manages registration and unregistation
+// with the global sampler.
+inline ThreadSafeArenaStatsHandle Sample() {
+ return ThreadSafeArenaStatsHandle(nullptr);
+}
+#endif // defined(PROTOBUF_ARENAZ_SAMPLE)
+
+// Returns a global Sampler.
+ThreadSafeArenazSampler& GlobalThreadSafeArenazSampler();
+
+// Enables or disables sampling for thread safe arenas.
+void SetThreadSafeArenazEnabled(bool enabled);
+
+// Sets the rate at which thread safe arena will be sampled.
+void SetThreadSafeArenazSampleParameter(arc_i32 rate);
+
+// Sets a soft max for the number of samples that will be kept.
+void SetThreadSafeArenazMaxSamples(arc_i32 max);
+
+// Sets the current value for when arenas should be next sampled.
+void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample);
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+#endif // GOOGLE_PROTOBUF_SRC_PROTOBUF_ARENAZ_SAMPLER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.cc b/contrib/libs/protobuf/src/google/protobuf/descriptor.cc
index abf1bf02dd..5c784615e8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.cc
@@ -42,29 +42,30 @@
#include <memory>
#include <set>
#include <string>
+#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/once.h>
#include <google/protobuf/any.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/stubs/casts.h>
+#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/descriptor_database.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/io/strtod.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/io/strtod.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/stubs/hash.h>
@@ -72,11 +73,493 @@
#undef PACKAGE // autoheader #defines this. :(
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
+namespace {
+const int kPackageLimit = 100;
+
+// Note: I distrust ctype.h due to locales.
+char ToUpper(char ch) {
+ return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
+}
+
+char ToLower(char ch) {
+ return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
+}
+
+TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
+ bool capitalize_next = !lower_first;
+ TProtoStringType result;
+ result.reserve(input.size());
+
+ for (char character : input) {
+ if (character == '_') {
+ capitalize_next = true;
+ } else if (capitalize_next) {
+ result.push_back(ToUpper(character));
+ capitalize_next = false;
+ } else {
+ result.push_back(character);
+ }
+ }
+
+ // Lower-case the first letter.
+ if (lower_first && !result.empty()) {
+ result[0] = ToLower(result[0]);
+ }
+
+ return result;
+}
+
+TProtoStringType ToJsonName(const TProtoStringType& input) {
+ bool capitalize_next = false;
+ TProtoStringType result;
+ result.reserve(input.size());
+
+ for (char character : input) {
+ if (character == '_') {
+ capitalize_next = true;
+ } else if (capitalize_next) {
+ result.push_back(ToUpper(character));
+ capitalize_next = false;
+ } else {
+ result.push_back(character);
+ }
+ }
+
+ return result;
+}
+
+// Backport of fold expressions for the comma operator to C++11.
+// Usage: Fold({expr...});
+// Guaranteed to evaluate left-to-right
+struct ExpressionEater {
+ template <typename T>
+ ExpressionEater(T&&) {} // NOLINT
+};
+void Fold(std::initializer_list<ExpressionEater>) {}
+
+template <int R>
+constexpr size_t RoundUpTo(size_t n) {
+ static_assert((R & (R - 1)) == 0, "Must be power of two");
+ return (n + (R - 1)) & ~(R - 1);
+}
+
+constexpr size_t Max(size_t a, size_t b) { return a > b ? a : b; }
+template <typename T, typename... Ts>
+constexpr size_t Max(T a, Ts... b) {
+ return Max(a, Max(b...));
+}
+
+template <typename T>
+constexpr size_t EffectiveAlignof() {
+ // `char` is special in that it gets aligned to 8. It is where we drop the
+ // trivial structs.
+ return std::is_same<T, char>::value ? 8 : alignof(T);
+}
+
+template <int align, typename U, typename... T>
+using AppendIfAlign =
+ typename std::conditional<EffectiveAlignof<U>() == align, void (*)(T..., U),
+ void (*)(T...)>::type;
+
+// Metafunction to sort types in descending order of alignment.
+// Useful for the flat allocator to ensure proper alignment of all elements
+// without having to add padding.
+// Instead of implementing a proper sort metafunction we just do a
+// filter+merge, which is much simpler to write as a metafunction.
+// We have a fixed set of alignments we can filter on.
+// For simplicity we use a function pointer as a type list.
+template <typename In, typename T16, typename T8, typename T4, typename T2,
+ typename T1>
+struct TypeListSortImpl;
+
+template <typename... T16, typename... T8, typename... T4, typename... T2,
+ typename... T1>
+struct TypeListSortImpl<void (*)(), void (*)(T16...), void (*)(T8...),
+ void (*)(T4...), void (*)(T2...), void (*)(T1...)> {
+ using type = void (*)(T16..., T8..., T4..., T2..., T1...);
+};
+
+template <typename First, typename... Rest, typename... T16, typename... T8,
+ typename... T4, typename... T2, typename... T1>
+struct TypeListSortImpl<void (*)(First, Rest...), void (*)(T16...),
+ void (*)(T8...), void (*)(T4...), void (*)(T2...),
+ void (*)(T1...)> {
+ using type = typename TypeListSortImpl<
+ void (*)(Rest...), AppendIfAlign<16, First, T16...>,
+ AppendIfAlign<8, First, T8...>, AppendIfAlign<4, First, T4...>,
+ AppendIfAlign<2, First, T2...>, AppendIfAlign<1, First, T1...>>::type;
+};
+
+template <typename... T>
+using SortByAlignment =
+ typename TypeListSortImpl<void (*)(T...), void (*)(), void (*)(),
+ void (*)(), void (*)(), void (*)()>::type;
+
+template <template <typename...> class C, typename... T>
+auto ApplyTypeList(void (*)(T...)) -> C<T...>;
+
+template <typename T>
+constexpr int FindTypeIndex() {
+ return -1;
+}
+
+template <typename T, typename T1, typename... Ts>
+constexpr int FindTypeIndex() {
+ return std::is_same<T, T1>::value ? 0 : FindTypeIndex<T, Ts...>() + 1;
+}
+
+// A type to value map, where the possible keys as specified in `Keys...`.
+// The values for key `K` is `ValueT<K>`
+template <template <typename> class ValueT, typename... Keys>
+class TypeMap {
+ public:
+ template <typename K>
+ ValueT<K>& Get() {
+ return static_cast<Base<K>&>(payload_).value;
+ }
+
+ template <typename K>
+ const ValueT<K>& Get() const {
+ return static_cast<const Base<K>&>(payload_).value;
+ }
+
+ private:
+ template <typename K>
+ struct Base {
+ ValueT<K> value{};
+ };
+ struct Payload : Base<Keys>... {};
+ Payload payload_;
+};
+
+template <typename T>
+using IntT = int;
+template <typename T>
+using PointerT = T*;
+
+// Manages an allocation of sequential arrays of type `T...`.
+// It is more space efficient than storing N (ptr, size) pairs, by storing only
+// the pointer to the head and the boundaries between the arrays.
+template <typename... T>
+class FlatAllocation {
+ public:
+ static constexpr size_t kMaxAlign = Max(alignof(T)...);
+
+ FlatAllocation(const TypeMap<IntT, T...>& ends) : ends_(ends) {
+ // The arrays start just after FlatAllocation, so adjust the ends.
+ Fold({(ends_.template Get<T>() +=
+ RoundUpTo<kMaxAlign>(sizeof(FlatAllocation)))...});
+ Fold({Init<T>()...});
+ }
+
+ void Destroy() {
+ Fold({Destroy<T>()...});
+ internal::SizedDelete(this, total_bytes());
+ }
+
+ template <int I>
+ using type = typename std::tuple_element<I, std::tuple<T...>>::type;
+
+ // Gets a tuple of the head pointers for the arrays
+ TypeMap<PointerT, T...> Pointers() const {
+ TypeMap<PointerT, T...> out;
+ Fold({(out.template Get<T>() = Begin<T>())...});
+ return out;
+ }
+
+
+ private:
+ // Total number of bytes used by all arrays.
+ int total_bytes() const {
+ // Get the last end.
+ return ends_.template Get<typename std::tuple_element<
+ sizeof...(T) - 1, std::tuple<T...>>::type>();
+ }
+
+
+ template <typename U>
+ int BeginOffset() const {
+ constexpr int type_index = FindTypeIndex<U, T...>();
+ // Avoid a negative value here to keep it compiling when type_index == 0
+ constexpr int prev_type_index = type_index == 0 ? 0 : type_index - 1;
+ using PrevType =
+ typename std::tuple_element<prev_type_index, std::tuple<T...>>::type;
+ // Ensure the types are properly aligned.
+ static_assert(EffectiveAlignof<PrevType>() >= EffectiveAlignof<U>(), "");
+ return type_index == 0 ? RoundUpTo<kMaxAlign>(sizeof(FlatAllocation))
+ : ends_.template Get<PrevType>();
+ }
+
+ template <typename U>
+ int EndOffset() const {
+ return ends_.template Get<U>();
+ }
+
+ // Avoid the reinterpret_cast if the array is empty.
+ // Clang's Control Flow Integrity does not like the cast pointing to memory
+ // that is not yet initialized to be of that type.
+ // (from -fsanitize=cfi-unrelated-cast)
+ template <typename U>
+ U* Begin() const {
+ int begin = BeginOffset<U>(), end = EndOffset<U>();
+ if (begin == end) return nullptr;
+ return reinterpret_cast<U*>(data() + begin);
+ }
+
+ template <typename U>
+ U* End() const {
+ int begin = BeginOffset<U>(), end = EndOffset<U>();
+ if (begin == end) return nullptr;
+ return reinterpret_cast<U*>(data() + end);
+ }
+
+ template <typename U>
+ bool Init() {
+ // Skip for the `char` block. No need to zero initialize it.
+ if (std::is_same<U, char>::value) return true;
+ for (char *p = data() + BeginOffset<U>(), *end = data() + EndOffset<U>();
+ p != end; p += sizeof(U)) {
+ ::new (p) U{};
+ }
+ return true;
+ }
+
+ template <typename U>
+ bool Destroy() {
+ if (std::is_trivially_destructible<U>::value) return true;
+ for (U* it = Begin<U>(), *end = End<U>(); it != end; ++it) {
+ it->~U();
+ }
+ return true;
+ }
+
+ char* data() const {
+ return const_cast<char*>(reinterpret_cast<const char*>(this));
+ }
+
+ TypeMap<IntT, T...> ends_;
+};
+
+template <typename... T>
+TypeMap<IntT, T...> CalculateEnds(const TypeMap<IntT, T...>& sizes) {
+ int total = 0;
+ TypeMap<IntT, T...> out;
+ Fold({(out.template Get<T>() = total +=
+ sizeof(T) * sizes.template Get<T>())...});
+ return out;
+}
+
+// The implementation for FlatAllocator below.
+// This separate class template makes it easier to have methods that fold on
+// `T...`.
+template <typename... T>
+class FlatAllocatorImpl {
+ public:
+ using Allocation = FlatAllocation<T...>;
+
+ template <typename U>
+ void PlanArray(int array_size) {
+ // We can't call PlanArray after FinalizePlanning has been called.
+ GOOGLE_CHECK(!has_allocated());
+ if (std::is_trivially_destructible<U>::value) {
+ // Trivial types are aligned to 8 bytes.
+ static_assert(alignof(U) <= 8, "");
+ total_.template Get<char>() += RoundUpTo<8>(array_size * sizeof(U));
+ } else {
+ // Since we can't use `if constexpr`, just make the expression compile
+ // when this path is not taken.
+ using TypeToUse =
+ typename std::conditional<std::is_trivially_destructible<U>::value,
+ char, U>::type;
+ total_.template Get<TypeToUse>() += array_size;
+ }
+ }
+
+ template <typename U>
+ U* AllocateArray(int array_size) {
+ constexpr bool trivial = std::is_trivially_destructible<U>::value;
+ using TypeToUse = typename std::conditional<trivial, char, U>::type;
+
+ // We can only allocate after FinalizePlanning has been called.
+ GOOGLE_CHECK(has_allocated());
+
+ TypeToUse*& data = pointers_.template Get<TypeToUse>();
+ int& used = used_.template Get<TypeToUse>();
+ U* res = reinterpret_cast<U*>(data + used);
+ used += trivial ? RoundUpTo<8>(array_size * sizeof(U)) : array_size;
+ GOOGLE_CHECK_LE(used, total_.template Get<TypeToUse>());
+ return res;
+ }
+
+ template <typename... In>
+ const TProtoStringType* AllocateStrings(In&&... in) {
+ TProtoStringType* strings = AllocateArray<TProtoStringType>(sizeof...(in));
+ TProtoStringType* res = strings;
+ Fold({(*strings++ = TProtoStringType(std::forward<In>(in)))...});
+ return res;
+ }
+
+ // Allocate all 5 names of the field:
+ // name, full name, lowercase, camelcase and json.
+ // It will dedup the strings when possible.
+ // The resulting array contains `name` at index 0, `full_name` at index 1
+ // and the other 3 indices are specified in the result.
+ void PlanFieldNames(const TProtoStringType& name,
+ const TProtoStringType* opt_json_name) {
+ GOOGLE_CHECK(!has_allocated());
+
+ // Fast path for snake_case names, which follow the style guide.
+ if (opt_json_name == nullptr) {
+ switch (GetFieldNameCase(name)) {
+ case FieldNameCase::kAllLower:
+ // Case 1: they are all the same.
+ return PlanArray<TProtoStringType>(2);
+ case FieldNameCase::kSnakeCase:
+ // Case 2: name==lower, camel==json
+ return PlanArray<TProtoStringType>(3);
+ default:
+ break;
+ }
+ }
+
+ TProtoStringType lowercase_name = name;
+ LowerString(&lowercase_name);
+
+ TProtoStringType camelcase_name = ToCamelCase(name, /* lower_first = */ true);
+ TProtoStringType json_name =
+ opt_json_name != nullptr ? *opt_json_name : ToJsonName(name);
+
+ StringPiece all_names[] = {name, lowercase_name, camelcase_name,
+ json_name};
+ std::sort(all_names, all_names + 4);
+ int unique =
+ static_cast<int>(std::unique(all_names, all_names + 4) - all_names);
+
+ PlanArray<TProtoStringType>(unique + 1);
+ }
+
+ struct FieldNamesResult {
+ const TProtoStringType* array;
+ int lowercase_index;
+ int camelcase_index;
+ int json_index;
+ };
+ FieldNamesResult AllocateFieldNames(const TProtoStringType& name,
+ const TProtoStringType& scope,
+ const TProtoStringType* opt_json_name) {
+ GOOGLE_CHECK(has_allocated());
+
+ TProtoStringType full_name =
+ scope.empty() ? name : StrCat(scope, ".", name);
+
+ // Fast path for snake_case names, which follow the style guide.
+ if (opt_json_name == nullptr) {
+ switch (GetFieldNameCase(name)) {
+ case FieldNameCase::kAllLower:
+ // Case 1: they are all the same.
+ return {AllocateStrings(name, std::move(full_name)), 0, 0, 0};
+ case FieldNameCase::kSnakeCase:
+ // Case 2: name==lower, camel==json
+ return {AllocateStrings(name, std::move(full_name),
+ ToCamelCase(name, /* lower_first = */ true)),
+ 0, 2, 2};
+ default:
+ break;
+ }
+ }
+
+ std::vector<TProtoStringType> names;
+ names.push_back(name);
+ names.push_back(std::move(full_name));
+
+ const auto push_name = [&](TProtoStringType new_name) {
+ for (size_t i = 0; i < names.size(); ++i) {
+ // Do not compare the full_name. It is unlikely to match, except in
+ // custom json_name. We are not taking this into account in
+ // PlanFieldNames so better to not try it.
+ if (i == 1) continue;
+ if (names[i] == new_name) return i;
+ }
+ names.push_back(std::move(new_name));
+ return names.size() - 1;
+ };
+
+ FieldNamesResult result{nullptr, 0, 0, 0};
+
+ TProtoStringType lowercase_name = name;
+ LowerString(&lowercase_name);
+ result.lowercase_index = push_name(std::move(lowercase_name));
+ result.camelcase_index =
+ push_name(ToCamelCase(name, /* lower_first = */ true));
+ result.json_index =
+ push_name(opt_json_name != nullptr ? *opt_json_name : ToJsonName(name));
+
+ TProtoStringType* all_names = AllocateArray<TProtoStringType>(names.size());
+ result.array = all_names;
+ std::move(names.begin(), names.end(), all_names);
+
+ return result;
+ }
+
+ template <typename Alloc>
+ void FinalizePlanning(Alloc& alloc) {
+ GOOGLE_CHECK(!has_allocated());
+
+ pointers_ = alloc->CreateFlatAlloc(total_)->Pointers();
+
+ GOOGLE_CHECK(has_allocated());
+ }
+
+ void ExpectConsumed() const {
+ // We verify that we consumed all the memory requested if there was no
+ // error in processing.
+ Fold({ExpectConsumed<T>()...});
+ }
+
+ private:
+ bool has_allocated() const {
+ return pointers_.template Get<char>() != nullptr;
+ }
+
+ static bool IsLower(char c) { return 'a' <= c && c <= 'z'; }
+ static bool IsDigit(char c) { return '0' <= c && c <= '9'; }
+ static bool IsLowerOrDigit(char c) { return IsLower(c) || IsDigit(c); }
+
+ enum class FieldNameCase { kAllLower, kSnakeCase, kOther };
+ FieldNameCase GetFieldNameCase(const TProtoStringType& name) {
+ if (!IsLower(name[0])) return FieldNameCase::kOther;
+ FieldNameCase best = FieldNameCase::kAllLower;
+ for (char c : name) {
+ if (IsLowerOrDigit(c)) {
+ // nothing to do
+ } else if (c == '_') {
+ best = FieldNameCase::kSnakeCase;
+ } else {
+ return FieldNameCase::kOther;
+ }
+ }
+ return best;
+ }
+
+ template <typename U>
+ bool ExpectConsumed() const {
+ GOOGLE_CHECK_EQ(total_.template Get<U>(), used_.template Get<U>());
+ return true;
+ }
+
+ TypeMap<PointerT, T...> pointers_;
+ TypeMap<IntT, T...> total_;
+ TypeMap<IntT, T...> used_;
+};
+
+} // namespace
+
class Symbol {
public:
enum Type {
@@ -89,11 +572,17 @@ class Symbol {
ENUM_VALUE_OTHER_PARENT,
SERVICE,
METHOD,
- PACKAGE,
+ FULL_PACKAGE,
+ SUB_PACKAGE,
QUERY_KEY
};
- Symbol() : ptr_(nullptr) {}
+ Symbol() {
+ static constexpr internal::SymbolBase null_symbol{};
+ static_assert(null_symbol.symbol_type_ == NULL_SYMBOL, "");
+ // Initialize with a sentinel to make sure `ptr_` is never null.
+ ptr_ = &null_symbol;
+ }
// Every object we store derives from internal::SymbolBase, where we store the
// symbol type enum.
@@ -113,15 +602,16 @@ class Symbol {
DEFINE_MEMBERS(EnumDescriptor, ENUM, enum_descriptor)
DEFINE_MEMBERS(ServiceDescriptor, SERVICE, service_descriptor)
DEFINE_MEMBERS(MethodDescriptor, METHOD, method_descriptor)
+ DEFINE_MEMBERS(FileDescriptor, FULL_PACKAGE, file_descriptor)
- // We use a special node for FileDescriptor.
+ // We use a special node for subpackage FileDescriptor.
// It is potentially added to the table with multiple different names, so we
// need a separate place to put the name.
- struct Package : internal::SymbolBase {
- const TProtoStringType* name;
+ struct Subpackage : internal::SymbolBase {
+ int name_size;
const FileDescriptor* file;
};
- DEFINE_MEMBERS(Package, PACKAGE, package_file_descriptor)
+ DEFINE_MEMBERS(Subpackage, SUB_PACKAGE, sub_package_file_descriptor)
// Enum values have two different parents.
// We use two different identitied for the same object to determine the two
@@ -153,23 +643,42 @@ class Symbol {
// Not a real symbol.
// Only used for heterogeneous lookups and never actually inserted in the
// tables.
+ // TODO(b/215557658): If we templetize QueryKey on the expected object type we
+ // can skip the switches for the eq function altogether.
struct QueryKey : internal::SymbolBase {
StringPiece name;
const void* parent;
int field_number;
+
+ // Adaptor functions to look like a Symbol to the comparators.
+ StringPiece full_name() const { return name; }
+ std::pair<const void*, int> parent_number_key() const {
+ return {parent, field_number};
+ }
+ std::pair<const void*, StringPiece> parent_name_key() const {
+ return {parent, name};
+ }
};
- DEFINE_MEMBERS(QueryKey, QUERY_KEY, query_key);
+ // This constructor is implicit to allow for non-transparent lookups when
+ // necessary.
+ // For transparent lookup cases we query directly with the object without the
+ // type erasure layer.
+ Symbol(QueryKey& value) : ptr_(&value) { // NOLINT
+ value.symbol_type_ = QUERY_KEY;
+ }
+ const QueryKey* query_key() const {
+ return type() == QUERY_KEY ? static_cast<const QueryKey*>(ptr_) : nullptr;
+ }
#undef DEFINE_MEMBERS
- Type type() const {
- return ptr_ == nullptr ? NULL_SYMBOL
- : static_cast<Type>(ptr_->symbol_type_);
- }
+ Type type() const { return static_cast<Type>(ptr_->symbol_type_); }
bool IsNull() const { return type() == NULL_SYMBOL; }
bool IsType() const { return type() == MESSAGE || type() == ENUM; }
bool IsAggregate() const {
- return type() == MESSAGE || type() == PACKAGE || type() == ENUM ||
- type() == SERVICE;
+ return IsType() || IsPackage() || type() == SERVICE;
+ }
+ bool IsPackage() const {
+ return type() == FULL_PACKAGE || type() == SUB_PACKAGE;
}
const FileDescriptor* GetFile() const {
@@ -188,8 +697,10 @@ class Symbol {
return service_descriptor()->file();
case METHOD:
return method_descriptor()->service()->file();
- case PACKAGE:
- return package_file_descriptor()->file;
+ case FULL_PACKAGE:
+ return file_descriptor();
+ case SUB_PACKAGE:
+ return sub_package_file_descriptor()->file;
default:
return nullptr;
}
@@ -211,10 +722,13 @@ class Symbol {
return service_descriptor()->full_name();
case METHOD:
return method_descriptor()->full_name();
- case PACKAGE:
- return *package_file_descriptor()->name;
+ case FULL_PACKAGE:
+ return file_descriptor()->package();
+ case SUB_PACKAGE:
+ return StringPiece(sub_package_file_descriptor()->file->package())
+ .substr(0, sub_package_file_descriptor()->name_size);
case QUERY_KEY:
- return query_key()->name;
+ return query_key()->full_name();
default:
GOOGLE_CHECK(false);
}
@@ -249,7 +763,7 @@ class Symbol {
case METHOD:
return {method_descriptor()->service(), method_descriptor()->name()};
case QUERY_KEY:
- return {query_key()->parent, query_key()->name};
+ return query_key()->parent_name_key();
default:
GOOGLE_CHECK(false);
}
@@ -265,7 +779,7 @@ class Symbol {
return {enum_value_descriptor()->type(),
enum_value_descriptor()->number()};
case QUERY_KEY:
- return {query_key()->parent, query_key()->field_number};
+ return query_key()->parent_number_key();
default:
GOOGLE_CHECK(false);
}
@@ -369,58 +883,6 @@ const int FieldDescriptor::kLastReservedNumber;
namespace {
-// Note: I distrust ctype.h due to locales.
-char ToUpper(char ch) {
- return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
-}
-
-char ToLower(char ch) {
- return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
-}
-
-TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
- bool capitalize_next = !lower_first;
- TProtoStringType result;
- result.reserve(input.size());
-
- for (char character : input) {
- if (character == '_') {
- capitalize_next = true;
- } else if (capitalize_next) {
- result.push_back(ToUpper(character));
- capitalize_next = false;
- } else {
- result.push_back(character);
- }
- }
-
- // Lower-case the first letter.
- if (lower_first && !result.empty()) {
- result[0] = ToLower(result[0]);
- }
-
- return result;
-}
-
-TProtoStringType ToJsonName(const TProtoStringType& input) {
- bool capitalize_next = false;
- TProtoStringType result;
- result.reserve(input.size());
-
- for (char character : input) {
- if (character == '_') {
- capitalize_next = true;
- } else if (capitalize_next) {
- result.push_back(ToUpper(character));
- capitalize_next = false;
- } else {
- result.push_back(character);
- }
- }
-
- return result;
-}
-
TProtoStringType EnumValueToPascalCase(const TProtoStringType& input) {
bool next_upper = true;
TProtoStringType result;
@@ -561,12 +1023,18 @@ struct PointerStringPairHash {
struct SymbolByFullNameHash {
- size_t operator()(Symbol s) const {
+ using is_transparent = void;
+
+ template <typename T>
+ size_t operator()(const T& s) const {
return HASH_FXN<StringPiece>{}(s.full_name());
}
};
struct SymbolByFullNameEq {
- bool operator()(Symbol a, Symbol b) const {
+ using is_transparent = void;
+
+ template <typename T, typename U>
+ bool operator()(const T& a, const U& b) const {
return a.full_name() == b.full_name();
}
};
@@ -574,12 +1042,18 @@ using SymbolsByNameSet =
HASH_SET<Symbol, SymbolByFullNameHash, SymbolByFullNameEq>;
struct SymbolByParentHash {
- size_t operator()(Symbol s) const {
+ using is_transparent = void;
+
+ template <typename T>
+ size_t operator()(const T& s) const {
return PointerStringPairHash{}(s.parent_name_key());
}
};
struct SymbolByParentEq {
- bool operator()(Symbol a, Symbol b) const {
+ using is_transparent = void;
+
+ template <typename T, typename U>
+ bool operator()(const T& a, const U& b) const {
return a.parent_name_key() == b.parent_name_key();
}
};
@@ -595,13 +1069,19 @@ typedef HASH_MAP<PointerStringPair, const FieldDescriptor*,
FieldsByNameMap;
struct FieldsByNumberHash {
- size_t operator()(Symbol s) const {
+ using is_transparent = void;
+
+ template <typename T>
+ size_t operator()(const T& s) const {
return PointerIntegerPairHash<std::pair<const void*, int>>{}(
s.parent_number_key());
}
};
struct FieldsByNumberEq {
- bool operator()(Symbol a, Symbol b) const {
+ using is_transparent = void;
+
+ template <typename T, typename U>
+ bool operator()(const T& a, const U& b) const {
return a.parent_number_key() == b.parent_number_key();
}
};
@@ -646,405 +1126,125 @@ bool AllowedExtendeeInProto3(const TProtoStringType& name) {
return allowed_proto3_extendees->find(name) !=
allowed_proto3_extendees->end();
}
+} // anonymous namespace
-// This bump allocator arena is optimized for the use case of this file. It is
-// mostly optimized for memory usage, since these objects are expected to live
-// for the entirety of the program.
-//
-// Some differences from other arenas:
-// - It has a fixed number of non-trivial types it can hold. This allows
-// tracking the allocations with a single byte. In contrast, google::protobuf::Arena
-// uses 16 bytes per non-trivial object created.
-// - It has some extra metadata for rollbacks. This is necessary for
-// implementing the API below. This metadata is flushed at the end and would
-// not cause persistent memory usage.
-// - It tries to squeeze every byte of out the blocks. If an allocation is too
-// large for the current block we move the block to a secondary area where we
-// can still use it for smaller objects. This complicates rollback logic but
-// makes it much more memory efficient.
-//
-// The allocation strategy is as follows:
-// - Memory is allocated from the front, with a forced 8 byte alignment.
-// - Metadata is allocated from the back, one byte per element.
-// - The metadata encodes one of two things:
-// * For types we want to track, the index into KnownTypes.
-// * For raw memory blocks, the size of the block (in 8 byte increments
-// to allow for a larger limit).
-// - When the raw data is too large to represent in the metadata byte, we
-// allocate this memory separately in the heap and store an OutOfLineAlloc
-// object instead. These come from large array allocations and alike.
-//
-// Blocks are kept in 3 areas:
-// - `current_` is the one we are currently allocating from. When we need to
-// allocate a block that doesn't fit there, we make a new block and move the
-// old `current_` to one of the areas below.
-// - Blocks that have no more usable space left (ie less than 9 bytes) are
-// stored in `full_blocks_`.
-// - Blocks that have some usable space are categorized in
-// `small_size_blocks_` depending on how much space they have left.
-// See `kSmallSizes` to see which sizes we track.
+// Contains tables specific to a particular file. These tables are not
+// modified once the file has been constructed, so they need not be
+// protected by a mutex. This makes operations that depend only on the
+// contents of a single file -- e.g. Descriptor::FindFieldByName() --
+// lock-free.
//
-class TableArena {
+// For historical reasons, the definitions of the methods of
+// FileDescriptorTables and DescriptorPool::Tables are interleaved below.
+// These used to be a single class.
+class FileDescriptorTables {
public:
- // Allocate a block on `n` bytes, with no destructor information saved.
- void* AllocateMemory(arc_ui32 n) {
- arc_ui32 tag = SizeToRawTag(n) + kFirstRawTag;
- if (tag > 255) {
- // We can't fit the size, use an OutOfLineAlloc.
- return Create<OutOfLineAlloc>(OutOfLineAlloc{::operator new(n), n})->ptr;
- }
-
- return AllocRawInternal(n, static_cast<Tag>(tag));
- }
-
- // Allocate and construct an element of type `T` as if by
- // `T(std::forward<Args>(args...))`.
- // The object is registered for destruction, if its destructor is not trivial.
- template <typename T, typename... Args>
- T* Create(Args&&... args) {
- static_assert(alignof(T) <= 8, "");
- return ::new (AllocRawInternal(sizeof(T), TypeTag<T>(KnownTypes{})))
- T(std::forward<Args>(args)...);
- }
-
- TableArena() {}
-
- TableArena(const TableArena&) = delete;
- TableArena& operator=(const TableArena&) = delete;
-
- ~TableArena() {
- // Uncomment this to debug usage statistics of the arena blocks.
- // PrintUsageInfo();
-
- for (Block* list : GetLists()) {
- while (list != nullptr) {
- Block* b = list;
- list = list->next;
- b->VisitBlock(DestroyVisitor{});
- b->Destroy();
- }
- }
- }
-
+ FileDescriptorTables();
+ ~FileDescriptorTables();
- // This function exists for debugging only.
- // It can be called from the destructor to dump some info in the tests to
- // inspect the usage of the arena.
- void PrintUsageInfo() const {
- const auto print_histogram = [](Block* b, int size) {
- std::map<arc_ui32, arc_ui32> unused_space_count;
- int count = 0;
- for (; b != nullptr; b = b->next) {
- ++unused_space_count[b->space_left()];
- ++count;
- }
- if (size > 0) {
- fprintf(stderr, " Blocks `At least %d`", size);
- } else {
- fprintf(stderr, " Blocks `full`");
- }
- fprintf(stderr, ": %d blocks.\n", count);
- for (auto p : unused_space_count) {
- fprintf(stderr, " space=%4u, count=%3u\n", p.first, p.second);
- }
- };
+ // Empty table, used with placeholder files.
+ inline static const FileDescriptorTables& GetEmptyInstance();
- fprintf(stderr, "TableArena unused space histogram:\n");
- fprintf(stderr, " Current: %u\n",
- current_ != nullptr ? current_->space_left() : 0);
- print_histogram(full_blocks_, 0);
- for (size_t i = 0; i < kSmallSizes.size(); ++i) {
- print_histogram(small_size_blocks_[i], kSmallSizes[i]);
- }
- }
+ // -----------------------------------------------------------------
+ // Finding items.
- // Current allocation count.
- // This can be used for checkpointing.
- size_t num_allocations() const { return num_allocations_; }
+ // Returns a null Symbol (symbol.IsNull() is true) if not found.
+ inline Symbol FindNestedSymbol(const void* parent,
+ StringPiece name) const;
- // Rollback the latest allocations until we reach back to `checkpoint`
- // num_allocations.
- void RollbackTo(size_t checkpoint) {
- while (num_allocations_ > checkpoint) {
- GOOGLE_DCHECK(!rollback_info_.empty());
- auto& info = rollback_info_.back();
- Block* b = info.block;
+ // These return nullptr if not found.
+ inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent,
+ int number) const;
+ inline const FieldDescriptor* FindFieldByLowercaseName(
+ const void* parent, StringPiece lowercase_name) const;
+ inline const FieldDescriptor* FindFieldByCamelcaseName(
+ const void* parent, StringPiece camelcase_name) const;
+ inline const EnumValueDescriptor* FindEnumValueByNumber(
+ const EnumDescriptor* parent, int number) const;
+ // This creates a new EnumValueDescriptor if not found, in a thread-safe way.
+ inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown(
+ const EnumDescriptor* parent, int number) const;
- VisitAlloc(b->data(), &b->start_offset, &b->end_offset, DestroyVisitor{},
- KnownTypes{});
- if (--info.count == 0) {
- rollback_info_.pop_back();
- }
- --num_allocations_;
- }
+ // -----------------------------------------------------------------
+ // Adding items.
- // Reconstruct the lists and destroy empty blocks.
- auto lists = GetLists();
- current_ = full_blocks_ = nullptr;
- small_size_blocks_.fill(nullptr);
+ // These add items to the corresponding tables. They return false if
+ // the key already exists in the table.
+ bool AddAliasUnderParent(const void* parent, const TProtoStringType& name,
+ Symbol symbol);
+ bool AddFieldByNumber(FieldDescriptor* field);
+ bool AddEnumValueByNumber(EnumValueDescriptor* value);
- for (Block* list : lists) {
- while (list != nullptr) {
- Block* b = list;
- list = list->next;
+ // Populates p->first->locations_by_path_ from p->second.
+ // Unusual signature dictated by internal::call_once.
+ static void BuildLocationsByPath(
+ std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
- if (b->start_offset == 0) {
- // This is empty, free it.
- b->Destroy();
- } else {
- RelocateToUsedList(b);
- }
- }
- }
- }
+ // Returns the location denoted by the specified path through info,
+ // or nullptr if not found.
+ // The value of info must be that of the corresponding FileDescriptor.
+ // (Conceptually a pure function, but stateful as an optimisation.)
+ const SourceCodeInfo_Location* GetSourceLocation(
+ const std::vector<int>& path, const SourceCodeInfo* info) const;
- // Clear all rollback information. Reduces memory usage.
- // Trying to rollback past num_allocations() is now impossible.
- void ClearRollbackData() {
- rollback_info_.clear();
- rollback_info_.shrink_to_fit();
- }
+ // Must be called after BuildFileImpl(), even if the build failed and
+ // we are going to roll back to the last checkpoint.
+ void FinalizeTables();
private:
- static constexpr size_t RoundUp(size_t n) { return (n + 7) & ~7; }
-
- using Tag = unsigned char;
-
- void* AllocRawInternal(arc_ui32 size, Tag tag) {
- GOOGLE_DCHECK_GT(size, 0);
- size = RoundUp(size);
-
- Block* to_relocate = nullptr;
- Block* to_use = nullptr;
-
- for (size_t i = 0; i < kSmallSizes.size(); ++i) {
- if (small_size_blocks_[i] != nullptr && size <= kSmallSizes[i]) {
- to_use = to_relocate = PopBlock(small_size_blocks_[i]);
- break;
- }
- }
-
- if (to_relocate != nullptr) {
- // We found one in the loop.
- } else if (current_ != nullptr && size + 1 <= current_->space_left()) {
- to_use = current_;
- } else {
- // No space left anywhere, make a new block.
- to_relocate = current_;
- // For now we hardcode the size to one page. Note that the maximum we can
- // allocate in the block according to the limits of Tag is less than 2k,
- // so this can fit anything that Tag can represent.
- constexpr size_t kBlockSize = 4096;
- to_use = current_ = ::new (::operator new(kBlockSize)) Block(kBlockSize);
- GOOGLE_DCHECK_GE(current_->space_left(), size + 1);
- }
-
- ++num_allocations_;
- if (!rollback_info_.empty() && rollback_info_.back().block == to_use) {
- ++rollback_info_.back().count;
- } else {
- rollback_info_.push_back({to_use, 1});
- }
-
- void* p = to_use->Allocate(size, tag);
- if (to_relocate != nullptr) {
- RelocateToUsedList(to_relocate);
- }
- return p;
- }
-
- static void OperatorDelete(void* p, size_t s) {
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
- ::operator delete(p, s);
-#else
- ::operator delete(p);
-#endif
- }
-
- struct OutOfLineAlloc {
- void* ptr;
- arc_ui32 size;
- };
-
- template <typename... T>
- struct TypeList {
- static constexpr Tag kSize = static_cast<Tag>(sizeof...(T));
- };
-
- template <typename T, typename Visitor>
- static void RunVisitor(char* p, uint16_t* start, Visitor visit) {
- *start -= RoundUp(sizeof(T));
- visit(reinterpret_cast<T*>(p + *start));
- }
-
- // Visit the allocation at the passed location.
- // It updates start/end to be after the visited object.
- // This allows visiting a whole block by calling the function in a loop.
- template <typename Visitor, typename... T>
- static void VisitAlloc(char* p, uint16_t* start, uint16_t* end, Visitor visit,
- TypeList<T...>) {
- const Tag tag = static_cast<Tag>(p[*end]);
- if (tag >= kFirstRawTag) {
- // Raw memory. Skip it.
- *start -= TagToSize(tag);
- } else {
- using F = void (*)(char*, uint16_t*, Visitor);
- static constexpr F kFuncs[] = {&RunVisitor<T, Visitor>...};
- kFuncs[tag](p, start, visit);
- }
- ++*end;
- }
-
- template <typename U, typename... Ts>
- static constexpr Tag TypeTag(TypeList<U, Ts...>) {
- return 0;
- }
-
- template <
- typename U, typename T, typename... Ts,
- typename = typename std::enable_if<!std::is_same<U, T>::value>::type>
- static constexpr Tag TypeTag(TypeList<T, Ts...>) {
- return 1 + TypeTag<U>(TypeList<Ts...>{});
- }
-
- template <typename U>
- static constexpr Tag TypeTag(TypeList<>) {
- static_assert(std::is_trivially_destructible<U>::value, "");
- return SizeToRawTag(sizeof(U));
- }
-
- using KnownTypes =
- TypeList<OutOfLineAlloc, TProtoStringType,
- // For name arrays
- std::array<TProtoStringType, 2>, std::array<TProtoStringType, 3>,
- std::array<TProtoStringType, 4>, std::array<TProtoStringType, 5>,
- FileDescriptorTables, SourceCodeInfo, FileOptions,
- MessageOptions, FieldOptions, ExtensionRangeOptions,
- OneofOptions, EnumOptions, EnumValueOptions, ServiceOptions,
- MethodOptions>;
- static constexpr Tag kFirstRawTag = KnownTypes::kSize;
-
-
- struct DestroyVisitor {
- template <typename T>
- void operator()(T* p) {
- p->~T();
- }
- void operator()(OutOfLineAlloc* p) { OperatorDelete(p->ptr, p->size); }
- };
-
- static arc_ui32 SizeToRawTag(size_t n) { return (RoundUp(n) / 8) - 1; }
-
- static arc_ui32 TagToSize(Tag tag) {
- GOOGLE_DCHECK_GE(tag, kFirstRawTag);
- return static_cast<arc_ui32>(tag - kFirstRawTag + 1) * 8;
- }
-
- struct Block {
- uint16_t start_offset;
- uint16_t end_offset;
- uint16_t capacity;
- Block* next;
-
- // `allocated_size` is the total size of the memory block allocated.
- // The `Block` structure is constructed at the start and the rest of the
- // memory is used as the payload of the `Block`.
- explicit Block(arc_ui32 allocated_size) {
- start_offset = 0;
- end_offset = capacity =
- reinterpret_cast<char*>(this) + allocated_size - data();
- next = nullptr;
- }
-
- char* data() {
- return reinterpret_cast<char*>(this) + RoundUp(sizeof(Block));
- }
-
- arc_ui32 memory_used() {
- return data() + capacity - reinterpret_cast<char*>(this);
- }
- arc_ui32 space_left() const { return end_offset - start_offset; }
-
- void* Allocate(arc_ui32 n, Tag tag) {
- GOOGLE_DCHECK_LE(n + 1, space_left());
- void* p = data() + start_offset;
- start_offset += n;
- data()[--end_offset] = tag;
- return p;
- }
-
- void Destroy() { OperatorDelete(this, memory_used()); }
-
- void PrependTo(Block*& list) {
- next = list;
- list = this;
- }
-
- template <typename Visitor>
- void VisitBlock(Visitor visit) {
- for (uint16_t s = start_offset, e = end_offset; s != 0;) {
- VisitAlloc(data(), &s, &e, visit, KnownTypes{});
- }
- }
- };
-
- Block* PopBlock(Block*& list) {
- Block* res = list;
- list = list->next;
- return res;
- }
-
- void RelocateToUsedList(Block* to_relocate) {
- if (current_ == nullptr) {
- current_ = to_relocate;
- current_->next = nullptr;
- return;
- } else if (current_->space_left() < to_relocate->space_left()) {
- std::swap(current_, to_relocate);
- current_->next = nullptr;
- }
-
- for (int i = kSmallSizes.size(); --i >= 0;) {
- if (to_relocate->space_left() >= 1 + kSmallSizes[i]) {
- to_relocate->PrependTo(small_size_blocks_[i]);
- return;
- }
- }
-
- to_relocate->PrependTo(full_blocks_);
- }
-
- static constexpr std::array<uint8_t, 6> kSmallSizes = {
- {// Sizes for pointer arrays.
- 8, 16, 24, 32,
- // Sizes for string arrays (for descriptor names).
- // The most common array sizes are 2 and 3.
- 2 * sizeof(TProtoStringType), 3 * sizeof(TProtoStringType)}};
+ const void* FindParentForFieldsByMap(const FieldDescriptor* field) const;
+ static void FieldsByLowercaseNamesLazyInitStatic(
+ const FileDescriptorTables* tables);
+ void FieldsByLowercaseNamesLazyInitInternal() const;
+ static void FieldsByCamelcaseNamesLazyInitStatic(
+ const FileDescriptorTables* tables);
+ void FieldsByCamelcaseNamesLazyInitInternal() const;
- // Helper function to iterate all lists.
- std::array<Block*, 2 + kSmallSizes.size()> GetLists() const {
- std::array<Block*, 2 + kSmallSizes.size()> res;
- res[0] = current_;
- res[1] = full_blocks_;
- std::copy(small_size_blocks_.begin(), small_size_blocks_.end(), &res[2]);
- return res;
- }
+ SymbolsByParentSet symbols_by_parent_;
+ mutable internal::once_flag fields_by_lowercase_name_once_;
+ mutable internal::once_flag fields_by_camelcase_name_once_;
+ // Make these fields atomic to avoid race conditions with
+ // GetEstimatedOwnedMemoryBytesSize. Once the pointer is set the map won't
+ // change anymore.
+ mutable std::atomic<const FieldsByNameMap*> fields_by_lowercase_name_{};
+ mutable std::atomic<const FieldsByNameMap*> fields_by_camelcase_name_{};
+ FieldsByNumberSet fields_by_number_; // Not including extensions.
+ EnumValuesByNumberSet enum_values_by_number_;
+ mutable EnumValuesByNumberSet unknown_enum_values_by_number_
+ PROTOBUF_GUARDED_BY(unknown_enum_values_mu_);
- Block* current_ = nullptr;
- std::array<Block*, kSmallSizes.size()> small_size_blocks_ = {{}};
- Block* full_blocks_ = nullptr;
+ // Populated on first request to save space, hence constness games.
+ mutable internal::once_flag locations_by_path_once_;
+ mutable LocationsByPathMap locations_by_path_;
- size_t num_allocations_ = 0;
- struct RollbackInfo {
- Block* block;
- size_t count;
- };
- std::vector<RollbackInfo> rollback_info_;
+ // Mutex to protect the unknown-enum-value map due to dynamic
+ // EnumValueDescriptor creation on unknown values.
+ mutable internal::WrappedMutex unknown_enum_values_mu_;
};
-constexpr std::array<uint8_t, 6> TableArena::kSmallSizes;
+namespace internal {
-} // anonymous namespace
+// Small sequential allocator to be used within a single file.
+// Most of the memory for a single FileDescriptor and everything under it is
+// allocated in a single block of memory, with the FlatAllocator giving it out
+// in parts later.
+// The code first plans the total number of bytes needed by calling PlanArray
+// with all the allocations that will happen afterwards, then calls
+// FinalizePlanning passing the underlying allocator (the DescriptorPool::Tables
+// instance), and then proceeds to get the memory via
+// `AllocateArray`/`AllocateString` calls. The calls to PlanArray and
+// The calls have to match between planning and allocating, though not
+// necessarily in the same order.
+class FlatAllocator
+ : public decltype(ApplyTypeList<FlatAllocatorImpl>(
+ SortByAlignment<char, TProtoStringType, SourceCodeInfo,
+ FileDescriptorTables,
+ // Option types
+ MessageOptions, FieldOptions, EnumOptions,
+ EnumValueOptions, ExtensionRangeOptions, OneofOptions,
+ ServiceOptions, MethodOptions, FileOptions>())) {};
+
+} // namespace internal
// ===================================================================
// DescriptorPool::Tables
@@ -1160,59 +1360,36 @@ class DescriptorPool::Tables {
template <typename Type>
Type* Allocate();
- // Allocate an array of objects which will be reclaimed when the
- // pool in destroyed. Again, destructors are never called.
- template <typename Type>
- Type* AllocateArray(int count);
-
- // Allocate a string which will be destroyed when the pool is destroyed.
- // The string is initialized to the given value for convenience.
- const TProtoStringType* AllocateString(StringPiece value);
-
- // Copy the input into a NUL terminated string whose lifetime is managed by
- // the pool.
- const char* Strdup(StringPiece value);
-
- // Allocates an array of strings which will be destroyed when the pool is
- // destroyed. The array is initialized with the input values.
- template <typename... In>
- const TProtoStringType* AllocateStringArray(In&&... values);
-
- struct FieldNamesResult {
- TProtoStringType* array;
- int lowercase_index;
- int camelcase_index;
- int json_index;
- };
- // Allocate all 5 names of the field:
- // name, full name, lowercase, camelcase and json.
- // This function will dedup the strings when possible.
- // The resulting array contains `name` at index 0, `full_name` at index 1 and
- // the other 3 indices are specified in the result.
- FieldNamesResult AllocateFieldNames(const TProtoStringType& name,
- const TProtoStringType& scope,
- const TProtoStringType* opt_json_name);
-
- // Create an object that will be deleted when the pool is destroyed.
- // The object is value initialized, and its destructor will be called if
- // non-trivial.
- template <typename Type>
- Type* Create();
+ // Allocate some bytes which will be reclaimed when the pool is
+ // destroyed. Memory is aligned to 8 bytes.
+ void* AllocateBytes(int size);
- // Allocate a protocol message object. Some older versions of GCC have
- // trouble understanding explicit template instantiations in some cases, so
- // in those cases we have to pass a dummy pointer of the right type as the
- // parameter instead of specifying the type explicitly.
- template <typename Type>
- Type* AllocateMessage(Type* dummy = nullptr);
+ // Create a FlatAllocation for the corresponding sizes.
+ // All objects within it will be default constructed.
+ // The whole allocation, including the non-trivial objects within, will be
+ // destroyed with the pool.
+ template <typename... T>
+ internal::FlatAllocator::Allocation* CreateFlatAlloc(
+ const TypeMap<IntT, T...>& sizes);
- // Allocate a FileDescriptorTables object.
- FileDescriptorTables* AllocateFileTables();
private:
- // All other memory allocated in the pool. Must be first as other objects can
+ // All memory allocated in the pool. Must be first as other objects can
// point into these.
- TableArena arena_;
+ struct MiscDeleter {
+ void operator()(int* p) const { internal::SizedDelete(p, *p + 8); }
+ };
+ // Miscellaneous allocations are length prefixed. The paylaod is 8 bytes after
+ // the `int` that contains the size. This keeps the payload aligned.
+ std::vector<std::unique_ptr<int, MiscDeleter>> misc_allocs_;
+ struct FlatAllocDeleter {
+ void operator()(internal::FlatAllocator::Allocation* p) const {
+ p->Destroy();
+ }
+ };
+ std::vector<
+ std::unique_ptr<internal::FlatAllocator::Allocation, FlatAllocDeleter>>
+ flat_allocs_;
SymbolsByNameSet symbols_by_name_;
FilesByNameMap files_by_name_;
@@ -1220,125 +1397,26 @@ class DescriptorPool::Tables {
struct CheckPoint {
explicit CheckPoint(const Tables* tables)
- : arena_before_checkpoint(tables->arena_.num_allocations()),
+ : flat_allocations_before_checkpoint(
+ static_cast<int>(tables->flat_allocs_.size())),
+ misc_allocations_before_checkpoint(
+ static_cast<int>(tables->misc_allocs_.size())),
pending_symbols_before_checkpoint(
tables->symbols_after_checkpoint_.size()),
pending_files_before_checkpoint(
tables->files_after_checkpoint_.size()),
pending_extensions_before_checkpoint(
tables->extensions_after_checkpoint_.size()) {}
- int arena_before_checkpoint;
+ int flat_allocations_before_checkpoint;
+ int misc_allocations_before_checkpoint;
int pending_symbols_before_checkpoint;
int pending_files_before_checkpoint;
int pending_extensions_before_checkpoint;
};
std::vector<CheckPoint> checkpoints_;
- std::vector<const char*> symbols_after_checkpoint_;
- std::vector<const char*> files_after_checkpoint_;
+ std::vector<Symbol> symbols_after_checkpoint_;
+ std::vector<const FileDescriptor*> files_after_checkpoint_;
std::vector<DescriptorIntPair> extensions_after_checkpoint_;
-
- // Allocate some bytes which will be reclaimed when the pool is
- // destroyed.
- void* AllocateBytes(int size);
-};
-
-// Contains tables specific to a particular file. These tables are not
-// modified once the file has been constructed, so they need not be
-// protected by a mutex. This makes operations that depend only on the
-// contents of a single file -- e.g. Descriptor::FindFieldByName() --
-// lock-free.
-//
-// For historical reasons, the definitions of the methods of
-// FileDescriptorTables and DescriptorPool::Tables are interleaved below.
-// These used to be a single class.
-class FileDescriptorTables {
- public:
- FileDescriptorTables();
- ~FileDescriptorTables();
-
- // Empty table, used with placeholder files.
- inline static const FileDescriptorTables& GetEmptyInstance();
-
- // -----------------------------------------------------------------
- // Finding items.
-
- // Returns a null Symbol (symbol.IsNull() is true) if not found.
- inline Symbol FindNestedSymbol(const void* parent,
- StringPiece name) const;
-
- // These return nullptr if not found.
- inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent,
- int number) const;
- inline const FieldDescriptor* FindFieldByLowercaseName(
- const void* parent, StringPiece lowercase_name) const;
- inline const FieldDescriptor* FindFieldByCamelcaseName(
- const void* parent, StringPiece camelcase_name) const;
- inline const EnumValueDescriptor* FindEnumValueByNumber(
- const EnumDescriptor* parent, int number) const;
- // This creates a new EnumValueDescriptor if not found, in a thread-safe way.
- inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown(
- const EnumDescriptor* parent, int number) const;
-
- // -----------------------------------------------------------------
- // Adding items.
-
- // These add items to the corresponding tables. They return false if
- // the key already exists in the table. For AddAliasUnderParent(), the
- // string passed in must be one that was constructed using AllocateString(),
- // as it will be used as a key in the symbols_by_parent_ map without copying.
- bool AddAliasUnderParent(const void* parent, const TProtoStringType& name,
- Symbol symbol);
- bool AddFieldByNumber(FieldDescriptor* field);
- bool AddEnumValueByNumber(EnumValueDescriptor* value);
-
- // Adds the field to the lowercase_name and camelcase_name maps. Never
- // fails because we allow duplicates; the first field by the name wins.
- void AddFieldByStylizedNames(const FieldDescriptor* field);
-
- // Populates p->first->locations_by_path_ from p->second.
- // Unusual signature dictated by internal::call_once.
- static void BuildLocationsByPath(
- std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
-
- // Returns the location denoted by the specified path through info,
- // or nullptr if not found.
- // The value of info must be that of the corresponding FileDescriptor.
- // (Conceptually a pure function, but stateful as an optimisation.)
- const SourceCodeInfo_Location* GetSourceLocation(
- const std::vector<int>& path, const SourceCodeInfo* info) const;
-
- // Must be called after BuildFileImpl(), even if the build failed and
- // we are going to roll back to the last checkpoint.
- void FinalizeTables();
-
- private:
- const void* FindParentForFieldsByMap(const FieldDescriptor* field) const;
- static void FieldsByLowercaseNamesLazyInitStatic(
- const FileDescriptorTables* tables);
- void FieldsByLowercaseNamesLazyInitInternal() const;
- static void FieldsByCamelcaseNamesLazyInitStatic(
- const FileDescriptorTables* tables);
- void FieldsByCamelcaseNamesLazyInitInternal() const;
-
- SymbolsByParentSet symbols_by_parent_;
- mutable FieldsByNameMap fields_by_lowercase_name_;
- std::unique_ptr<FieldsByNameMap> fields_by_lowercase_name_tmp_;
- mutable internal::once_flag fields_by_lowercase_name_once_;
- mutable FieldsByNameMap fields_by_camelcase_name_;
- std::unique_ptr<FieldsByNameMap> fields_by_camelcase_name_tmp_;
- mutable internal::once_flag fields_by_camelcase_name_once_;
- FieldsByNumberSet fields_by_number_; // Not including extensions.
- EnumValuesByNumberSet enum_values_by_number_;
- mutable EnumValuesByNumberSet unknown_enum_values_by_number_
- PROTOBUF_GUARDED_BY(unknown_enum_values_mu_);
-
- // Populated on first request to save space, hence constness games.
- mutable internal::once_flag locations_by_path_once_;
- mutable LocationsByPathMap locations_by_path_;
-
- // Mutex to protect the unknown-enum-value map due to dynamic
- // EnumValueDescriptor creation on unknown values.
- mutable internal::WrappedMutex unknown_enum_values_mu_;
};
DescriptorPool::Tables::Tables() {
@@ -1364,11 +1442,12 @@ DescriptorPool::Tables::Tables() {
DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); }
-FileDescriptorTables::FileDescriptorTables()
- : fields_by_lowercase_name_tmp_(new FieldsByNameMap()),
- fields_by_camelcase_name_tmp_(new FieldsByNameMap()) {}
+FileDescriptorTables::FileDescriptorTables() {}
-FileDescriptorTables::~FileDescriptorTables() {}
+FileDescriptorTables::~FileDescriptorTables() {
+ delete fields_by_lowercase_name_.load(std::memory_order_acquire);
+ delete fields_by_camelcase_name_.load(std::memory_order_acquire);
+}
inline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() {
static auto file_descriptor_tables =
@@ -1389,7 +1468,6 @@ void DescriptorPool::Tables::ClearLastCheckpoint() {
symbols_after_checkpoint_.clear();
files_after_checkpoint_.clear();
extensions_after_checkpoint_.clear();
- arena_.ClearRollbackData();
}
}
@@ -1399,13 +1477,11 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() {
for (size_t i = checkpoint.pending_symbols_before_checkpoint;
i < symbols_after_checkpoint_.size(); i++) {
- Symbol::QueryKey name;
- name.name = symbols_after_checkpoint_[i];
- symbols_by_name_.erase(Symbol(&name));
+ symbols_by_name_.erase(symbols_after_checkpoint_[i]);
}
for (size_t i = checkpoint.pending_files_before_checkpoint;
i < files_after_checkpoint_.size(); i++) {
- files_by_name_.erase(files_after_checkpoint_[i]);
+ files_by_name_.erase(files_after_checkpoint_[i]->name());
}
for (size_t i = checkpoint.pending_extensions_before_checkpoint;
i < extensions_after_checkpoint_.size(); i++) {
@@ -1418,7 +1494,8 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() {
extensions_after_checkpoint_.resize(
checkpoint.pending_extensions_before_checkpoint);
- arena_.RollbackTo(checkpoint.arena_before_checkpoint);
+ flat_allocs_.resize(checkpoint.flat_allocations_before_checkpoint);
+ misc_allocs_.resize(checkpoint.misc_allocations_before_checkpoint);
checkpoints_.pop_back();
}
@@ -1427,7 +1504,7 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() {
inline Symbol DescriptorPool::Tables::FindSymbol(StringPiece key) const {
Symbol::QueryKey name;
name.name = key;
- auto it = symbols_by_name_.find(Symbol(&name));
+ auto it = symbols_by_name_.find(name);
return it == symbols_by_name_.end() ? Symbol() : *it;
}
@@ -1436,7 +1513,7 @@ inline Symbol FileDescriptorTables::FindNestedSymbol(
Symbol::QueryKey query;
query.name = name;
query.parent = parent;
- auto it = symbols_by_parent_.find(Symbol(&query));
+ auto it = symbols_by_parent_.find(query);
return it == symbols_by_parent_.end() ? Symbol() : *it;
}
@@ -1490,7 +1567,7 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber(
query.parent = parent;
query.field_number = number;
- auto it = fields_by_number_.find(Symbol(&query));
+ auto it = fields_by_number_.find(query);
return it == fields_by_number_.end() ? nullptr : it->field_descriptor();
}
@@ -1513,13 +1590,14 @@ void FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic(
}
void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const {
+ auto* map = new FieldsByNameMap;
for (Symbol symbol : symbols_by_parent_) {
const FieldDescriptor* field = symbol.field_descriptor();
if (!field) continue;
- PointerStringPair lowercase_key(FindParentForFieldsByMap(field),
- field->lowercase_name().c_str());
- InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, field);
+ (*map)[{FindParentForFieldsByMap(field), field->lowercase_name().c_str()}] =
+ field;
}
+ fields_by_lowercase_name_.store(map, std::memory_order_release);
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(
@@ -1527,8 +1605,9 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(
internal::call_once(
fields_by_lowercase_name_once_,
&FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this);
- return FindPtrOrNull(fields_by_lowercase_name_,
- PointerStringPair(parent, lowercase_name));
+ return FindPtrOrNull(
+ *fields_by_lowercase_name_.load(std::memory_order_acquire),
+ PointerStringPair(parent, lowercase_name));
}
void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic(
@@ -1537,13 +1616,14 @@ void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic(
}
void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const {
+ auto* map = new FieldsByNameMap;
for (Symbol symbol : symbols_by_parent_) {
const FieldDescriptor* field = symbol.field_descriptor();
if (!field) continue;
- PointerStringPair camelcase_key(FindParentForFieldsByMap(field),
- field->camelcase_name().c_str());
- InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, field);
+ (*map)[{FindParentForFieldsByMap(field), field->camelcase_name().c_str()}] =
+ field;
}
+ fields_by_camelcase_name_.store(map, std::memory_order_release);
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(
@@ -1551,8 +1631,9 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(
internal::call_once(
fields_by_camelcase_name_once_,
FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this);
- return FindPtrOrNull(fields_by_camelcase_name_,
- PointerStringPair(parent, camelcase_name));
+ return FindPtrOrNull(
+ *fields_by_camelcase_name_.load(std::memory_order_acquire),
+ PointerStringPair(parent, camelcase_name));
}
inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(
@@ -1569,7 +1650,7 @@ inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(
query.parent = parent;
query.field_number = number;
- auto it = enum_values_by_number_.find(Symbol(&query));
+ auto it = enum_values_by_number_.find(query);
return it == enum_values_by_number_.end() ? nullptr
: it->enum_value_descriptor();
}
@@ -1592,7 +1673,7 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(
// Second try, with reader lock held on unknown enum values: common case.
{
ReaderMutexLock l(&unknown_enum_values_mu_);
- auto it = unknown_enum_values_by_number_.find(Symbol(&query));
+ auto it = unknown_enum_values_by_number_.find(query);
if (it != unknown_enum_values_by_number_.end() &&
it->enum_value_descriptor() != nullptr) {
return it->enum_value_descriptor();
@@ -1602,7 +1683,7 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(
// necessary.
{
WriterMutexLock l(&unknown_enum_values_mu_);
- auto it = unknown_enum_values_by_number_.find(Symbol(&query));
+ auto it = unknown_enum_values_by_number_.find(query);
if (it != unknown_enum_values_by_number_.end() &&
it->enum_value_descriptor() != nullptr) {
return it->enum_value_descriptor();
@@ -1612,19 +1693,23 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(
// EnumDescriptor (it's not a part of the enum as originally defined), but
// we do insert it into the table so that we can return the same pointer
// later.
- TProtoStringType enum_value_name = StringPrintf("UNKNOWN_ENUM_VALUE_%s_%d",
- parent->name().c_str(), number);
+ TProtoStringType enum_value_name = StringPrintf(
+ "UNKNOWN_ENUM_VALUE_%s_%d", parent->name().c_str(), number);
auto* pool = DescriptorPool::generated_pool();
auto* tables = const_cast<DescriptorPool::Tables*>(pool->tables_.get());
- EnumValueDescriptor* result;
+ internal::FlatAllocator alloc;
+ alloc.PlanArray<EnumValueDescriptor>(1);
+ alloc.PlanArray<TProtoStringType>(2);
+
{
// Must lock the pool because we will do allocations in the shared arena.
MutexLockMaybe l2(pool->mutex_);
- result = tables->Allocate<EnumValueDescriptor>();
- result->all_names_ = tables->AllocateStringArray(
- enum_value_name,
- StrCat(parent->full_name(), ".", enum_value_name));
+ alloc.FinalizePlanning(tables);
}
+ EnumValueDescriptor* result = alloc.AllocateArray<EnumValueDescriptor>(1);
+ result->all_names_ = alloc.AllocateStrings(
+ enum_value_name,
+ StrCat(parent->full_name(), ".", enum_value_name));
result->number_ = number;
result->type_ = parent;
result->options_ = &EnumValueOptions::default_instance();
@@ -1654,7 +1739,7 @@ bool DescriptorPool::Tables::AddSymbol(const TProtoStringType& full_name,
Symbol symbol) {
GOOGLE_DCHECK_EQ(full_name, symbol.full_name());
if (symbols_by_name_.insert(symbol).second) {
- symbols_after_checkpoint_.push_back(full_name.c_str());
+ symbols_after_checkpoint_.push_back(symbol);
return true;
} else {
return false;
@@ -1671,46 +1756,14 @@ bool FileDescriptorTables::AddAliasUnderParent(const void* parent,
bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {
if (InsertIfNotPresent(&files_by_name_, file->name(), file)) {
- files_after_checkpoint_.push_back(file->name().c_str());
+ files_after_checkpoint_.push_back(file);
return true;
} else {
return false;
}
}
-void FileDescriptorTables::FinalizeTables() {
- // Clean up the temporary maps used by AddFieldByStylizedNames().
- fields_by_lowercase_name_tmp_ = nullptr;
- fields_by_camelcase_name_tmp_ = nullptr;
-}
-
-void FileDescriptorTables::AddFieldByStylizedNames(
- const FieldDescriptor* field) {
- const void* parent = FindParentForFieldsByMap(field);
-
- // We want fields_by_{lower,camel}case_name_ to be lazily built, but
- // cross-link order determines which entry will be present in the case of a
- // conflict. So we use the temporary maps that get destroyed after
- // BuildFileImpl() to detect the conflicts, and only store the conflicts in
- // the map that will persist. We will then lazily populate the rest of the
- // entries from fields_by_number_.
-
- PointerStringPair lowercase_key(parent, field->lowercase_name().c_str());
- if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_.get(),
- lowercase_key, field)) {
- InsertIfNotPresent(
- &fields_by_lowercase_name_, lowercase_key,
- FindPtrOrNull(*fields_by_lowercase_name_tmp_, lowercase_key));
- }
-
- PointerStringPair camelcase_key(parent, field->camelcase_name().c_str());
- if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_.get(),
- camelcase_key, field)) {
- InsertIfNotPresent(
- &fields_by_camelcase_name_, camelcase_key,
- FindPtrOrNull(*fields_by_camelcase_name_tmp_, camelcase_key));
- }
-}
+void FileDescriptorTables::FinalizeTables() {}
bool FileDescriptorTables::AddFieldByNumber(FieldDescriptor* field) {
// Skip fields that are at the start of the sequence.
@@ -1752,123 +1805,35 @@ bool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) {
template <typename Type>
Type* DescriptorPool::Tables::Allocate() {
- return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type)));
-}
-
-template <typename Type>
-Type* DescriptorPool::Tables::AllocateArray(int count) {
- return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type) * count));
-}
-
-const TProtoStringType* DescriptorPool::Tables::AllocateString(
- StringPiece value) {
- return arena_.Create<TProtoStringType>(value);
-}
-
-const char* DescriptorPool::Tables::Strdup(StringPiece value) {
- char* p = AllocateArray<char>(static_cast<int>(value.size() + 1));
- memcpy(p, value.data(), value.size());
- p[value.size()] = 0;
- return p;
-}
-
-template <typename... In>
-const TProtoStringType* DescriptorPool::Tables::AllocateStringArray(In&&... values) {
- auto& array = *arena_.Create<std::array<TProtoStringType, sizeof...(In)>>();
- array = {{TProtoStringType(std::forward<In>(values))...}};
- return array.data();
+ static_assert(std::is_trivially_destructible<Type>::value, "");
+ static_assert(alignof(Type) <= 8, "");
+ return ::new (AllocateBytes(sizeof(Type))) Type{};
}
-DescriptorPool::Tables::FieldNamesResult
-DescriptorPool::Tables::AllocateFieldNames(const TProtoStringType& name,
- const TProtoStringType& scope,
- const TProtoStringType* opt_json_name) {
- TProtoStringType lowercase_name = name;
- LowerString(&lowercase_name);
-
- TProtoStringType camelcase_name = ToCamelCase(name, /* lower_first = */ true);
- TProtoStringType json_name;
- if (opt_json_name != nullptr) {
- json_name = *opt_json_name;
- } else {
- json_name = ToJsonName(name);
- }
-
- const bool lower_eq_name = lowercase_name == name;
- const bool camel_eq_name = camelcase_name == name;
- const bool json_eq_name = json_name == name;
- const bool json_eq_camel = json_name == camelcase_name;
-
- const int total_count = 2 + (lower_eq_name ? 0 : 1) +
- (camel_eq_name ? 0 : 1) +
- (json_eq_name || json_eq_camel ? 0 : 1);
- FieldNamesResult result{nullptr, 0, 0, 0};
- // We use std::array to allow handling of the destruction of the strings.
- switch (total_count) {
- case 2:
- result.array = arena_.Create<std::array<TProtoStringType, 2>>()->data();
- break;
- case 3:
- result.array = arena_.Create<std::array<TProtoStringType, 3>>()->data();
- break;
- case 4:
- result.array = arena_.Create<std::array<TProtoStringType, 4>>()->data();
- break;
- case 5:
- result.array = arena_.Create<std::array<TProtoStringType, 5>>()->data();
- break;
- }
-
- result.array[0] = name;
- if (scope.empty()) {
- result.array[1] = name;
- } else {
- result.array[1] = StrCat(scope, ".", name);
- }
- int index = 2;
- if (lower_eq_name) {
- result.lowercase_index = 0;
- } else {
- result.lowercase_index = index;
- result.array[index++] = std::move(lowercase_name);
- }
-
- if (camel_eq_name) {
- result.camelcase_index = 0;
- } else {
- result.camelcase_index = index;
- result.array[index++] = std::move(camelcase_name);
- }
-
- if (json_eq_name) {
- result.json_index = 0;
- } else if (json_eq_camel) {
- result.json_index = result.camelcase_index;
- } else {
- result.json_index = index;
- result.array[index] = std::move(json_name);
- }
-
- return result;
+void* DescriptorPool::Tables::AllocateBytes(int size) {
+ if (size == 0) return nullptr;
+ void* p = ::operator new(size + RoundUpTo<8>(sizeof(int)));
+ int* sizep = static_cast<int*>(p);
+ misc_allocs_.emplace_back(sizep);
+ *sizep = size;
+ return static_cast<char*>(p) + RoundUpTo<8>(sizeof(int));
}
-template <typename Type>
-Type* DescriptorPool::Tables::Create() {
- return arena_.Create<Type>();
-}
+template <typename... T>
+internal::FlatAllocator::Allocation* DescriptorPool::Tables::CreateFlatAlloc(
+ const TypeMap<IntT, T...>& sizes) {
+ auto ends = CalculateEnds(sizes);
+ using FlatAlloc = internal::FlatAllocator::Allocation;
-template <typename Type>
-Type* DescriptorPool::Tables::AllocateMessage(Type* /* dummy */) {
- return arena_.Create<Type>();
-}
+ int last_end = ends.template Get<
+ typename std::tuple_element<sizeof...(T) - 1, std::tuple<T...>>::type>();
+ size_t total_size =
+ last_end + RoundUpTo<FlatAlloc::kMaxAlign>(sizeof(FlatAlloc));
+ char* data = static_cast<char*>(::operator new(total_size));
+ auto* res = ::new (data) FlatAlloc(ends);
+ flat_allocs_.emplace_back(res);
-FileDescriptorTables* DescriptorPool::Tables::AllocateFileTables() {
- return arena_.Create<FileDescriptorTables>();
-}
-
-void* DescriptorPool::Tables::AllocateBytes(int size) {
- if (size == 0) return nullptr;
- return arena_.AllocateMemory(size);
+ return res;
}
void FileDescriptorTables::BuildLocationsByPath(
@@ -2467,7 +2432,7 @@ bool DescriptorPool::IsSubSymbolOfBuiltType(StringPiece name) const {
Symbol symbol = tables_->FindSymbol(prefix);
// If the symbol type is anything other than PACKAGE, then its complete
// definition is already known.
- if (!symbol.IsNull() && symbol.type() != Symbol::PACKAGE) {
+ if (!symbol.IsNull() && !symbol.IsPackage()) {
return true;
}
}
@@ -3530,7 +3495,6 @@ void MethodDescriptor::DebugString(
comment_printer.AddPostComment(contents);
}
-
// Location methods ===============================================
bool FileDescriptor::GetSourceLocation(const std::vector<int>& path,
@@ -3716,7 +3680,8 @@ class DescriptorBuilder {
friend class OptionInterpreter;
// Non-recursive part of BuildFile functionality.
- FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto);
+ FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto,
+ internal::FlatAllocator& alloc);
const DescriptorPool* pool_;
DescriptorPool::Tables* tables_; // for convenience
@@ -3752,6 +3717,13 @@ class DescriptorBuilder {
// to report a more useful error message.
TProtoStringType undefine_resolved_name_;
+ // Tracker for current recursion depth to implement recursion protection.
+ //
+ // Counts down to 0 when there is no depth remaining.
+ //
+ // Maximum recursion depth corresponds to 32 nested message declarations.
+ int recursion_depth_ = 32;
+
void AddError(const TProtoStringType& element_name, const Message& descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location,
const TProtoStringType& error);
@@ -3845,13 +3817,6 @@ class DescriptorBuilder {
void ValidateSymbolName(const TProtoStringType& name, const TProtoStringType& full_name,
const Message& proto);
- // Used by BUILD_ARRAY macro (below) to avoid having to have the type
- // specified as a macro parameter.
- template <typename Type>
- inline void AllocateArray(int size, Type** output) {
- *output = tables_->AllocateArray<Type>(size);
- }
-
// Allocates a copy of orig_options in tables_ and stores it in the
// descriptor. Remembers its uninterpreted options, to be interpreted
// later. DescriptorT must be one of the Descriptor messages from
@@ -3859,10 +3824,12 @@ class DescriptorBuilder {
template <class DescriptorT>
void AllocateOptions(const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, int options_field_tag,
- const TProtoStringType& option_name);
+ const TProtoStringType& option_name,
+ internal::FlatAllocator& alloc);
// Specialization for FileOptions.
void AllocateOptions(const FileOptions& orig_options,
- FileDescriptor* descriptor);
+ FileDescriptor* descriptor,
+ internal::FlatAllocator& alloc);
// Implementation for AllocateOptions(). Don't call this directly.
template <class DescriptorT>
@@ -3870,52 +3837,57 @@ class DescriptorBuilder {
const TProtoStringType& name_scope, const TProtoStringType& element_name,
const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, const std::vector<int>& options_path,
- const TProtoStringType& option_name);
+ const TProtoStringType& option_name, internal::FlatAllocator& alloc);
// Allocates an array of two strings, the first one is a copy of `proto_name`,
// and the second one is the full name.
// Full proto name is "scope.proto_name" if scope is non-empty and
// "proto_name" otherwise.
const TProtoStringType* AllocateNameStrings(const TProtoStringType& scope,
- const TProtoStringType& proto_name);
+ const TProtoStringType& proto_name,
+ internal::FlatAllocator& alloc);
// These methods all have the same signature for the sake of the BUILD_ARRAY
// macro, below.
void BuildMessage(const DescriptorProto& proto, const Descriptor* parent,
- Descriptor* result);
+ Descriptor* result, internal::FlatAllocator& alloc);
void BuildFieldOrExtension(const FieldDescriptorProto& proto,
Descriptor* parent, FieldDescriptor* result,
- bool is_extension);
+ bool is_extension, internal::FlatAllocator& alloc);
void BuildField(const FieldDescriptorProto& proto, Descriptor* parent,
- FieldDescriptor* result) {
- BuildFieldOrExtension(proto, parent, result, false);
+ FieldDescriptor* result, internal::FlatAllocator& alloc) {
+ BuildFieldOrExtension(proto, parent, result, false, alloc);
}
void BuildExtension(const FieldDescriptorProto& proto, Descriptor* parent,
- FieldDescriptor* result) {
- BuildFieldOrExtension(proto, parent, result, true);
+ FieldDescriptor* result, internal::FlatAllocator& alloc) {
+ BuildFieldOrExtension(proto, parent, result, true, alloc);
}
void BuildExtensionRange(const DescriptorProto::ExtensionRange& proto,
const Descriptor* parent,
- Descriptor::ExtensionRange* result);
+ Descriptor::ExtensionRange* result,
+ internal::FlatAllocator& alloc);
void BuildReservedRange(const DescriptorProto::ReservedRange& proto,
const Descriptor* parent,
- Descriptor::ReservedRange* result);
+ Descriptor::ReservedRange* result,
+ internal::FlatAllocator& alloc);
void BuildReservedRange(const EnumDescriptorProto::EnumReservedRange& proto,
const EnumDescriptor* parent,
- EnumDescriptor::ReservedRange* result);
+ EnumDescriptor::ReservedRange* result,
+ internal::FlatAllocator& alloc);
void BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent,
- OneofDescriptor* result);
+ OneofDescriptor* result, internal::FlatAllocator& alloc);
void CheckEnumValueUniqueness(const EnumDescriptorProto& proto,
const EnumDescriptor* result);
void BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent,
- EnumDescriptor* result);
+ EnumDescriptor* result, internal::FlatAllocator& alloc);
void BuildEnumValue(const EnumValueDescriptorProto& proto,
- const EnumDescriptor* parent,
- EnumValueDescriptor* result);
+ const EnumDescriptor* parent, EnumValueDescriptor* result,
+ internal::FlatAllocator& alloc);
void BuildService(const ServiceDescriptorProto& proto, const void* dummy,
- ServiceDescriptor* result);
+ ServiceDescriptor* result, internal::FlatAllocator& alloc);
void BuildMethod(const MethodDescriptorProto& proto,
- const ServiceDescriptor* parent, MethodDescriptor* result);
+ const ServiceDescriptor* parent, MethodDescriptor* result,
+ internal::FlatAllocator& alloc);
void LogUnusedDependency(const FileDescriptorProto& proto,
const FileDescriptor* result);
@@ -4329,7 +4301,7 @@ Symbol DescriptorBuilder::FindSymbol(const TProtoStringType& name, bool build_it
return result;
}
- if (result.type() == Symbol::PACKAGE) {
+ if (result.IsPackage()) {
// Arg, this is overcomplicated. The symbol is a package name. It could
// be that the package was defined in multiple files. result.GetFile()
// returns the first file we saw that used this package. We've determined
@@ -4484,30 +4456,47 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
placeholder_full_name = name;
}
- TProtoStringType::size_type dotpos = placeholder_full_name.find_last_of('.');
+ // Create the placeholders.
+ internal::FlatAllocator alloc;
+ alloc.PlanArray<FileDescriptor>(1);
+ alloc.PlanArray<TProtoStringType>(2);
+ if (placeholder_type == PLACEHOLDER_ENUM) {
+ alloc.PlanArray<EnumDescriptor>(1);
+ alloc.PlanArray<EnumValueDescriptor>(1);
+ alloc.PlanArray<TProtoStringType>(2); // names for the descriptor.
+ alloc.PlanArray<TProtoStringType>(2); // names for the value.
+ } else {
+ alloc.PlanArray<Descriptor>(1);
+ alloc.PlanArray<TProtoStringType>(2); // names for the descriptor.
+ if (placeholder_type == PLACEHOLDER_EXTENDABLE_MESSAGE) {
+ alloc.PlanArray<Descriptor::ExtensionRange>(1);
+ }
+ }
+ alloc.FinalizePlanning(tables_);
+
+ const TProtoStringType::size_type dotpos = placeholder_full_name.find_last_of('.');
if (dotpos != TProtoStringType::npos) {
placeholder_package =
- tables_->AllocateString(placeholder_full_name.substr(0, dotpos));
+ alloc.AllocateStrings(placeholder_full_name.substr(0, dotpos));
placeholder_name = placeholder_full_name.substr(dotpos + 1);
} else {
- placeholder_package = &internal::GetEmptyString();
+ placeholder_package = alloc.AllocateStrings("");
placeholder_name = placeholder_full_name;
}
- // Create the placeholders.
FileDescriptor* placeholder_file = NewPlaceholderFileWithMutexHeld(
- StrCat(placeholder_full_name, ".placeholder.proto"));
+ StrCat(placeholder_full_name, ".placeholder.proto"), alloc);
placeholder_file->package_ = placeholder_package;
if (placeholder_type == PLACEHOLDER_ENUM) {
placeholder_file->enum_type_count_ = 1;
- placeholder_file->enum_types_ = tables_->AllocateArray<EnumDescriptor>(1);
+ placeholder_file->enum_types_ = alloc.AllocateArray<EnumDescriptor>(1);
EnumDescriptor* placeholder_enum = &placeholder_file->enum_types_[0];
memset(static_cast<void*>(placeholder_enum), 0, sizeof(*placeholder_enum));
placeholder_enum->all_names_ =
- tables_->AllocateStringArray(placeholder_name, placeholder_full_name);
+ alloc.AllocateStrings(placeholder_name, placeholder_full_name);
placeholder_enum->file_ = placeholder_file;
placeholder_enum->options_ = &EnumOptions::default_instance();
placeholder_enum->is_placeholder_ = true;
@@ -4515,7 +4504,7 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
// Enums must have at least one value.
placeholder_enum->value_count_ = 1;
- placeholder_enum->values_ = tables_->AllocateArray<EnumValueDescriptor>(1);
+ placeholder_enum->values_ = alloc.AllocateArray<EnumValueDescriptor>(1);
// Disable fast-path lookup for this enum.
placeholder_enum->sequential_value_limit_ = -1;
@@ -4524,7 +4513,7 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
sizeof(*placeholder_value));
// Note that enum value names are siblings of their type, not children.
- placeholder_value->all_names_ = tables_->AllocateStringArray(
+ placeholder_value->all_names_ = alloc.AllocateStrings(
"PLACEHOLDER_VALUE", placeholder_package->empty()
? "PLACEHOLDER_VALUE"
: *placeholder_package + ".PLACEHOLDER_VALUE");
@@ -4536,14 +4525,14 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
return Symbol(placeholder_enum);
} else {
placeholder_file->message_type_count_ = 1;
- placeholder_file->message_types_ = tables_->AllocateArray<Descriptor>(1);
+ placeholder_file->message_types_ = alloc.AllocateArray<Descriptor>(1);
Descriptor* placeholder_message = &placeholder_file->message_types_[0];
memset(static_cast<void*>(placeholder_message), 0,
sizeof(*placeholder_message));
placeholder_message->all_names_ =
- tables_->AllocateStringArray(placeholder_name, placeholder_full_name);
+ alloc.AllocateStrings(placeholder_name, placeholder_full_name);
placeholder_message->file_ = placeholder_file;
placeholder_message->options_ = &MessageOptions::default_instance();
placeholder_message->is_placeholder_ = true;
@@ -4552,12 +4541,12 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
if (placeholder_type == PLACEHOLDER_EXTENDABLE_MESSAGE) {
placeholder_message->extension_range_count_ = 1;
placeholder_message->extension_ranges_ =
- tables_->AllocateArray<Descriptor::ExtensionRange>(1);
- placeholder_message->extension_ranges_->start = 1;
+ alloc.AllocateArray<Descriptor::ExtensionRange>(1);
+ placeholder_message->extension_ranges_[0].start = 1;
// kMaxNumber + 1 because ExtensionRange::end is exclusive.
- placeholder_message->extension_ranges_->end =
+ placeholder_message->extension_ranges_[0].end =
FieldDescriptor::kMaxNumber + 1;
- placeholder_message->extension_ranges_->options_ = nullptr;
+ placeholder_message->extension_ranges_[0].options_ = nullptr;
}
return Symbol(placeholder_message);
@@ -4567,18 +4556,23 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
FileDescriptor* DescriptorPool::NewPlaceholderFile(
StringPiece name) const {
MutexLockMaybe lock(mutex_);
- return NewPlaceholderFileWithMutexHeld(name);
+ internal::FlatAllocator alloc;
+ alloc.PlanArray<FileDescriptor>(1);
+ alloc.PlanArray<TProtoStringType>(1);
+ alloc.FinalizePlanning(tables_);
+
+ return NewPlaceholderFileWithMutexHeld(name, alloc);
}
FileDescriptor* DescriptorPool::NewPlaceholderFileWithMutexHeld(
- StringPiece name) const {
+ StringPiece name, internal::FlatAllocator& alloc) const {
if (mutex_) {
mutex_->AssertHeld();
}
- FileDescriptor* placeholder = tables_->Allocate<FileDescriptor>();
+ FileDescriptor* placeholder = alloc.AllocateArray<FileDescriptor>(1);
memset(static_cast<void*>(placeholder), 0, sizeof(*placeholder));
- placeholder->name_ = tables_->AllocateString(name);
+ placeholder->name_ = alloc.AllocateStrings(name);
placeholder->package_ = &internal::GetEmptyString();
placeholder->pool_ = this;
placeholder->options_ = &FileOptions::default_instance();
@@ -4652,13 +4646,17 @@ void DescriptorBuilder::AddPackage(const TProtoStringType& name,
Symbol existing_symbol = tables_->FindSymbol(name);
// It's OK to redefine a package.
if (existing_symbol.IsNull()) {
- auto* package = tables_->AllocateArray<Symbol::Package>(1);
- // If the name is the package name, then it is already in the arena.
- // If not, copy it there. It came from the call to AddPackage below.
- package->name =
- &name == &file->package() ? &name : tables_->AllocateString(name);
- package->file = file;
- tables_->AddSymbol(*package->name, Symbol(package));
+ if (&name == &file->package()) {
+ // It is the toplevel package name, so insert the descriptor directly.
+ tables_->AddSymbol(file->package(), Symbol(file));
+ } else {
+ auto* package = tables_->Allocate<Symbol::Subpackage>();
+ // If the name is the package name, then it is already in the arena.
+ // If not, copy it there. It came from the call to AddPackage below.
+ package->name_size = static_cast<int>(name.size());
+ package->file = file;
+ tables_->AddSymbol(name, Symbol(package));
+ }
// Also add parent package, if any.
TProtoStringType::size_type dot_pos = name.find_last_of('.');
if (dot_pos == TProtoStringType::npos) {
@@ -4669,13 +4667,14 @@ void DescriptorBuilder::AddPackage(const TProtoStringType& name,
AddPackage(name.substr(0, dot_pos), proto, file);
ValidateSymbolName(name.substr(dot_pos + 1), name, proto);
}
- } else if (existing_symbol.type() != Symbol::PACKAGE) {
+ } else if (!existing_symbol.IsPackage()) {
// Symbol seems to have been defined in a different file.
+ const FileDescriptor* other_file = existing_symbol.GetFile();
AddError(name, proto, DescriptorPool::ErrorCollector::NAME,
"\"" + name +
"\" is already defined (as something other than "
"a package) in file \"" +
- existing_symbol.GetFile()->name() + "\".");
+ (other_file == nullptr ? "null" : other_file->name()) + "\".");
}
}
@@ -4693,6 +4692,7 @@ void DescriptorBuilder::ValidateSymbolName(const TProtoStringType& name,
(character < '0' || '9' < character) && (character != '_')) {
AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
"\"" + name + "\" is not a valid identifier.");
+ return;
}
}
}
@@ -4706,23 +4706,25 @@ template <class DescriptorT>
void DescriptorBuilder::AllocateOptions(
const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, int options_field_tag,
- const TProtoStringType& option_name) {
+ const TProtoStringType& option_name, internal::FlatAllocator& alloc) {
std::vector<int> options_path;
descriptor->GetLocationPath(&options_path);
options_path.push_back(options_field_tag);
AllocateOptionsImpl(descriptor->full_name(), descriptor->full_name(),
- orig_options, descriptor, options_path, option_name);
+ orig_options, descriptor, options_path, option_name,
+ alloc);
}
// We specialize for FileDescriptor.
void DescriptorBuilder::AllocateOptions(const FileOptions& orig_options,
- FileDescriptor* descriptor) {
+ FileDescriptor* descriptor,
+ internal::FlatAllocator& alloc) {
std::vector<int> options_path;
options_path.push_back(FileDescriptorProto::kOptionsFieldNumber);
// We add the dummy token so that LookupSymbol does the right thing.
AllocateOptionsImpl(descriptor->package() + ".dummy", descriptor->name(),
orig_options, descriptor, options_path,
- "google.protobuf.FileOptions");
+ "google.protobuf.FileOptions", alloc);
}
template <class DescriptorT>
@@ -4730,13 +4732,8 @@ void DescriptorBuilder::AllocateOptionsImpl(
const TProtoStringType& name_scope, const TProtoStringType& element_name,
const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, const std::vector<int>& options_path,
- const TProtoStringType& option_name) {
- // We need to use a dummy pointer to work around a bug in older versions of
- // GCC. Otherwise, the following two lines could be replaced with:
- // typename DescriptorT::OptionsType* options =
- // tables_->AllocateMessage<typename DescriptorT::OptionsType>();
- typename DescriptorT::OptionsType* const dummy = nullptr;
- typename DescriptorT::OptionsType* options = tables_->AllocateMessage(dummy);
+ const TProtoStringType& option_name, internal::FlatAllocator& alloc) {
+ auto* options = alloc.AllocateArray<typename DescriptorT::OptionsType>(1);
if (!orig_options.IsInitialized()) {
AddError(name_scope + "." + element_name, orig_options,
@@ -4786,11 +4783,13 @@ void DescriptorBuilder::AllocateOptionsImpl(
// A common pattern: We want to convert a repeated field in the descriptor
// to an array of values, calling some method to build each value.
-#define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \
- OUTPUT->NAME##_count_ = INPUT.NAME##_size(); \
- AllocateArray(INPUT.NAME##_size(), &OUTPUT->NAME##s_); \
- for (int i = 0; i < INPUT.NAME##_size(); i++) { \
- METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i); \
+#define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \
+ OUTPUT->NAME##_count_ = INPUT.NAME##_size(); \
+ OUTPUT->NAME##s_ = alloc.AllocateArray< \
+ typename std::remove_pointer<decltype(OUTPUT->NAME##s_)>::type>( \
+ INPUT.NAME##_size()); \
+ for (int i = 0; i < INPUT.NAME##_size(); i++) { \
+ METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i, alloc); \
}
void DescriptorBuilder::AddRecursiveImportError(
@@ -4846,6 +4845,130 @@ static bool ExistingFileMatchesProto(const FileDescriptor* existing_file,
return existing_proto.SerializeAsString() == proto.SerializeAsString();
}
+// These PlanAllocationSize functions will gather into the FlatAllocator all the
+// necessary memory allocations that BuildXXX functions below will do on the
+// Tables object.
+// They *must* be kept in sync. If we miss some PlanArray call we won't have
+// enough memory and will GOOGLE_CHECK-fail.
+static void PlanAllocationSize(
+ const RepeatedPtrField<EnumValueDescriptorProto>& values,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<EnumValueDescriptor>(values.size());
+ alloc.PlanArray<TProtoStringType>(2 * values.size()); // name + full_name
+ for (const auto& v : values) {
+ if (v.has_options()) alloc.PlanArray<EnumValueOptions>(1);
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<EnumDescriptorProto>& enums,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<EnumDescriptor>(enums.size());
+ alloc.PlanArray<TProtoStringType>(2 * enums.size()); // name + full_name
+ for (const auto& e : enums) {
+ if (e.has_options()) alloc.PlanArray<EnumOptions>(1);
+ PlanAllocationSize(e.value(), alloc);
+ alloc.PlanArray<EnumDescriptor::ReservedRange>(e.reserved_range_size());
+ alloc.PlanArray<const TProtoStringType*>(e.reserved_name_size());
+ alloc.PlanArray<TProtoStringType>(e.reserved_name_size());
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<OneofDescriptorProto>& oneofs,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<OneofDescriptor>(oneofs.size());
+ alloc.PlanArray<TProtoStringType>(2 * oneofs.size()); // name + full_name
+ for (const auto& oneof : oneofs) {
+ if (oneof.has_options()) alloc.PlanArray<OneofOptions>(1);
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<FieldDescriptorProto>& fields,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<FieldDescriptor>(fields.size());
+ for (const auto& field : fields) {
+ if (field.has_options()) alloc.PlanArray<FieldOptions>(1);
+ alloc.PlanFieldNames(field.name(),
+ field.has_json_name() ? &field.json_name() : nullptr);
+ if (field.has_default_value() && field.has_type() &&
+ (field.type() == FieldDescriptorProto::TYPE_STRING ||
+ field.type() == FieldDescriptorProto::TYPE_BYTES)) {
+ // For the default string value.
+ alloc.PlanArray<TProtoStringType>(1);
+ }
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<DescriptorProto::ExtensionRange>& ranges,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<Descriptor::ExtensionRange>(ranges.size());
+ for (const auto& r : ranges) {
+ if (r.has_options()) alloc.PlanArray<ExtensionRangeOptions>(1);
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<DescriptorProto>& messages,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<Descriptor>(messages.size());
+ alloc.PlanArray<TProtoStringType>(2 * messages.size()); // name + full_name
+
+ for (const auto& message : messages) {
+ if (message.has_options()) alloc.PlanArray<MessageOptions>(1);
+ PlanAllocationSize(message.nested_type(), alloc);
+ PlanAllocationSize(message.field(), alloc);
+ PlanAllocationSize(message.extension(), alloc);
+ PlanAllocationSize(message.extension_range(), alloc);
+ alloc.PlanArray<Descriptor::ReservedRange>(message.reserved_range_size());
+ alloc.PlanArray<const TProtoStringType*>(message.reserved_name_size());
+ alloc.PlanArray<TProtoStringType>(message.reserved_name_size());
+ PlanAllocationSize(message.enum_type(), alloc);
+ PlanAllocationSize(message.oneof_decl(), alloc);
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<MethodDescriptorProto>& methods,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<MethodDescriptor>(methods.size());
+ alloc.PlanArray<TProtoStringType>(2 * methods.size()); // name + full_name
+ for (const auto& m : methods) {
+ if (m.has_options()) alloc.PlanArray<MethodOptions>(1);
+ }
+}
+
+static void PlanAllocationSize(
+ const RepeatedPtrField<ServiceDescriptorProto>& services,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<ServiceDescriptor>(services.size());
+ alloc.PlanArray<TProtoStringType>(2 * services.size()); // name + full_name
+ for (const auto& service : services) {
+ if (service.has_options()) alloc.PlanArray<ServiceOptions>(1);
+ PlanAllocationSize(service.method(), alloc);
+ }
+}
+
+static void PlanAllocationSize(const FileDescriptorProto& proto,
+ internal::FlatAllocator& alloc) {
+ alloc.PlanArray<FileDescriptor>(1);
+ alloc.PlanArray<FileDescriptorTables>(1);
+ alloc.PlanArray<TProtoStringType>(2); // name + package
+ if (proto.has_options()) alloc.PlanArray<FileOptions>(1);
+ if (proto.has_source_code_info()) alloc.PlanArray<SourceCodeInfo>(1);
+
+ PlanAllocationSize(proto.service(), alloc);
+ PlanAllocationSize(proto.message_type(), alloc);
+ PlanAllocationSize(proto.enum_type(), alloc);
+ PlanAllocationSize(proto.extension(), alloc);
+
+ alloc.PlanArray<int>(proto.weak_dependency_size());
+ alloc.PlanArray<int>(proto.public_dependency_size());
+ alloc.PlanArray<const FileDescriptor*>(proto.dependency_size());
+}
+
const FileDescriptor* DescriptorBuilder::BuildFile(
const FileDescriptorProto& proto) {
filename_ = proto.name();
@@ -4904,12 +5027,16 @@ const FileDescriptor* DescriptorBuilder::BuildFile(
// Checkpoint the tables so that we can roll back if something goes wrong.
tables_->AddCheckpoint();
- FileDescriptor* result = BuildFileImpl(proto);
+ internal::FlatAllocator alloc;
+ PlanAllocationSize(proto, alloc);
+ alloc.FinalizePlanning(tables_);
+ FileDescriptor* result = BuildFileImpl(proto, alloc);
file_tables_->FinalizeTables();
if (result) {
tables_->ClearLastCheckpoint();
result->finished_building_ = true;
+ alloc.ExpectConsumed();
} else {
tables_->RollbackToLastCheckpoint();
}
@@ -4918,22 +5045,22 @@ const FileDescriptor* DescriptorBuilder::BuildFile(
}
FileDescriptor* DescriptorBuilder::BuildFileImpl(
- const FileDescriptorProto& proto) {
- FileDescriptor* result = tables_->Allocate<FileDescriptor>();
+ const FileDescriptorProto& proto, internal::FlatAllocator& alloc) {
+ FileDescriptor* result = alloc.AllocateArray<FileDescriptor>(1);
file_ = result;
result->is_placeholder_ = false;
result->finished_building_ = false;
SourceCodeInfo* info = nullptr;
if (proto.has_source_code_info()) {
- info = tables_->AllocateMessage<SourceCodeInfo>();
+ info = alloc.AllocateArray<SourceCodeInfo>(1);
info->CopyFrom(proto.source_code_info());
result->source_code_info_ = info;
} else {
result->source_code_info_ = &SourceCodeInfo::default_instance();
}
- file_tables_ = tables_->AllocateFileTables();
+ file_tables_ = alloc.AllocateArray<FileDescriptorTables>(1);
file_->tables_ = file_tables_;
if (!proto.has_name()) {
@@ -4953,15 +5080,15 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
"Unrecognized syntax: " + proto.syntax());
}
- result->name_ = tables_->AllocateString(proto.name());
+ result->name_ = alloc.AllocateStrings(proto.name());
if (proto.has_package()) {
- result->package_ = tables_->AllocateString(proto.package());
+ result->package_ = alloc.AllocateStrings(proto.package());
} else {
// We cannot rely on proto.package() returning a valid string if
// proto.has_package() is false, because we might be running at static
// initialization time, in which case default values have not yet been
// initialized.
- result->package_ = tables_->AllocateString("");
+ result->package_ = alloc.AllocateStrings("");
}
result->pool_ = pool_;
@@ -4980,6 +5107,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
return nullptr;
}
if (!result->package().empty()) {
+ if (std::count(result->package().begin(), result->package().end(), '.') >
+ kPackageLimit) {
+ AddError(result->package(), proto, DescriptorPool::ErrorCollector::NAME,
+ "Exceeds Maximum Package Depth");
+ return nullptr;
+ }
AddPackage(result->package(), proto, result);
}
@@ -4987,13 +5120,15 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
std::set<TProtoStringType> seen_dependencies;
result->dependency_count_ = proto.dependency_size();
result->dependencies_ =
- tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size());
+ alloc.AllocateArray<const FileDescriptor*>(proto.dependency_size());
result->dependencies_once_ = nullptr;
unused_dependency_.clear();
std::set<int> weak_deps;
for (int i = 0; i < proto.weak_dependency_size(); ++i) {
weak_deps.insert(proto.weak_dependency(i));
}
+
+ bool need_lazy_deps = false;
for (int i = 0; i < proto.dependency_size(); i++) {
if (!seen_dependencies.insert(proto.dependency(i)).second) {
AddTwiceListedError(proto, i);
@@ -5015,8 +5150,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
if (!pool_->lazily_build_dependencies_) {
if (pool_->allow_unknown_ ||
(!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) {
- dependency =
- pool_->NewPlaceholderFileWithMutexHeld(proto.dependency(i));
+ internal::FlatAllocator lazy_dep_alloc;
+ lazy_dep_alloc.PlanArray<FileDescriptor>(1);
+ lazy_dep_alloc.PlanArray<TProtoStringType>(1);
+ lazy_dep_alloc.FinalizePlanning(tables_);
+ dependency = pool_->NewPlaceholderFileWithMutexHeld(
+ proto.dependency(i), lazy_dep_alloc);
} else {
AddImportError(proto, i);
}
@@ -5034,26 +5173,37 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
result->dependencies_[i] = dependency;
if (pool_->lazily_build_dependencies_ && !dependency) {
- if (result->dependencies_once_ == nullptr) {
- result->dependencies_once_ =
- tables_->Create<FileDescriptor::LazyInitData>();
- result->dependencies_once_->dependencies_names =
- tables_->AllocateArray<const char*>(proto.dependency_size());
- if (proto.dependency_size() > 0) {
- std::fill_n(result->dependencies_once_->dependencies_names,
- proto.dependency_size(), nullptr);
- }
+ need_lazy_deps = true;
+ }
+ }
+ if (need_lazy_deps) {
+ int total_char_size = 0;
+ for (int i = 0; i < proto.dependency_size(); i++) {
+ if (result->dependencies_[i] == nullptr) {
+ total_char_size += static_cast<int>(proto.dependency(i).size());
}
+ ++total_char_size; // For NUL char
+ }
- result->dependencies_once_->dependencies_names[i] =
- tables_->Strdup(proto.dependency(i));
+ void* data = tables_->AllocateBytes(
+ static_cast<int>(sizeof(internal::once_flag) + total_char_size));
+ result->dependencies_once_ = ::new (data) internal::once_flag{};
+ char* name_data = reinterpret_cast<char*>(result->dependencies_once_ + 1);
+
+ for (int i = 0; i < proto.dependency_size(); i++) {
+ if (result->dependencies_[i] == nullptr) {
+ memcpy(name_data, proto.dependency(i).c_str(),
+ proto.dependency(i).size());
+ name_data += proto.dependency(i).size();
+ }
+ *name_data++ = '\0';
}
}
// Check public dependencies.
int public_dependency_count = 0;
result->public_dependencies_ =
- tables_->AllocateArray<int>(proto.public_dependency_size());
+ alloc.AllocateArray<int>(proto.public_dependency_size());
for (int i = 0; i < proto.public_dependency_size(); i++) {
// Only put valid public dependency indexes.
int index = proto.public_dependency(i);
@@ -5087,7 +5237,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
// Check weak dependencies.
int weak_dependency_count = 0;
result->weak_dependencies_ =
- tables_->AllocateArray<int>(proto.weak_dependency_size());
+ alloc.AllocateArray<int>(proto.weak_dependency_size());
for (int i = 0; i < proto.weak_dependency_size(); i++) {
int index = proto.weak_dependency(i);
if (index >= 0 && index < proto.dependency_size()) {
@@ -5108,7 +5258,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
// Copy options.
result->options_ = nullptr; // Set to default_instance later if necessary.
if (proto.has_options()) {
- AllocateOptions(proto.options(), result);
+ AllocateOptions(proto.options(), result, alloc);
}
// Note that the following steps must occur in exactly the specified order.
@@ -5164,21 +5314,33 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
const TProtoStringType* DescriptorBuilder::AllocateNameStrings(
- const TProtoStringType& scope, const TProtoStringType& proto_name) {
+ const TProtoStringType& scope, const TProtoStringType& proto_name,
+ internal::FlatAllocator& alloc) {
if (scope.empty()) {
- return tables_->AllocateStringArray(proto_name, proto_name);
+ return alloc.AllocateStrings(proto_name, proto_name);
} else {
- return tables_->AllocateStringArray(proto_name,
- StrCat(scope, ".", proto_name));
+ return alloc.AllocateStrings(proto_name,
+ StrCat(scope, ".", proto_name));
}
}
+namespace {
+
+// Helper for BuildMessage below.
+struct IncrementWhenDestroyed {
+ ~IncrementWhenDestroyed() { ++to_increment; }
+ int& to_increment;
+};
+
+} // namespace
+
void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
const Descriptor* parent,
- Descriptor* result) {
+ Descriptor* result,
+ internal::FlatAllocator& alloc) {
const TProtoStringType& scope =
(parent == nullptr) ? file_->package() : parent->full_name();
- result->all_names_ = AllocateNameStrings(scope, proto.name());
+ result->all_names_ = AllocateNameStrings(scope, proto.name(), alloc);
ValidateSymbolName(proto.name(), result->full_name(), proto);
result->file_ = file_;
@@ -5186,6 +5348,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
result->is_placeholder_ = false;
result->is_unqualified_placeholder_ = false;
result->well_known_type_ = Descriptor::WELLKNOWNTYPE_UNSPECIFIED;
+ result->options_ = nullptr; // Set to default_instance later if necessary.
auto it = pool_->tables_->well_known_types_.find(result->full_name());
if (it != pool_->tables_->well_known_types_.end()) {
@@ -5208,28 +5371,38 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
// Build oneofs first so that fields and extension ranges can refer to them.
BUILD_ARRAY(proto, result, oneof_decl, BuildOneof, result);
BUILD_ARRAY(proto, result, field, BuildField, result);
- BUILD_ARRAY(proto, result, nested_type, BuildMessage, result);
BUILD_ARRAY(proto, result, enum_type, BuildEnum, result);
BUILD_ARRAY(proto, result, extension_range, BuildExtensionRange, result);
BUILD_ARRAY(proto, result, extension, BuildExtension, result);
BUILD_ARRAY(proto, result, reserved_range, BuildReservedRange, result);
+ // Before building submessages, check recursion limit.
+ --recursion_depth_;
+ IncrementWhenDestroyed revert{recursion_depth_};
+ if (recursion_depth_ <= 0) {
+ AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::OTHER,
+ "Reached maximum recursion limit for nested messages.");
+ result->nested_types_ = nullptr;
+ result->nested_type_count_ = 0;
+ return;
+ }
+ BUILD_ARRAY(proto, result, nested_type, BuildMessage, result);
+
// Copy reserved names.
int reserved_name_count = proto.reserved_name_size();
result->reserved_name_count_ = reserved_name_count;
result->reserved_names_ =
- tables_->AllocateArray<const TProtoStringType*>(reserved_name_count);
+ alloc.AllocateArray<const TProtoStringType*>(reserved_name_count);
for (int i = 0; i < reserved_name_count; ++i) {
result->reserved_names_[i] =
- tables_->AllocateString(proto.reserved_name(i));
+ alloc.AllocateStrings(proto.reserved_name(i));
}
// Copy options.
- result->options_ = nullptr; // Set to default_instance later if necessary.
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
DescriptorProto::kOptionsFieldNumber,
- "google.protobuf.MessageOptions");
+ "google.protobuf.MessageOptions", alloc);
}
AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result));
@@ -5325,13 +5498,14 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
Descriptor* parent,
FieldDescriptor* result,
- bool is_extension) {
+ bool is_extension,
+ internal::FlatAllocator& alloc) {
const TProtoStringType& scope =
(parent == nullptr) ? file_->package() : parent->full_name();
// We allocate all names in a single array, and dedup them.
// We remember the indices for the potentially deduped values.
- auto all_names = tables_->AllocateFieldNames(
+ auto all_names = alloc.AllocateFieldNames(
proto.name(), scope,
proto.has_json_name() ? &proto.json_name() : nullptr);
result->all_names_ = all_names.array;
@@ -5457,11 +5631,11 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
break;
case FieldDescriptor::CPPTYPE_STRING:
if (result->type() == FieldDescriptor::TYPE_BYTES) {
- result->default_value_string_ = tables_->AllocateString(
+ result->default_value_string_ = alloc.AllocateStrings(
UnescapeCEscapeString(proto.default_value()));
} else {
result->default_value_string_ =
- tables_->AllocateString(proto.default_value());
+ alloc.AllocateStrings(proto.default_value());
}
break;
case FieldDescriptor::CPPTYPE_MESSAGE:
@@ -5591,16 +5765,15 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
FieldDescriptorProto::kOptionsFieldNumber,
- "google.protobuf.FieldOptions");
+ "google.protobuf.FieldOptions", alloc);
}
-
AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result));
}
void DescriptorBuilder::BuildExtensionRange(
const DescriptorProto::ExtensionRange& proto, const Descriptor* parent,
- Descriptor::ExtensionRange* result) {
+ Descriptor::ExtensionRange* result, internal::FlatAllocator& alloc) {
result->start = proto.start();
result->end = proto.end();
if (result->start <= 0) {
@@ -5631,13 +5804,13 @@ void DescriptorBuilder::BuildExtensionRange(
options_path.push_back(DescriptorProto_ExtensionRange::kOptionsFieldNumber);
AllocateOptionsImpl(parent->full_name(), parent->full_name(),
proto.options(), result, options_path,
- "google.protobuf.ExtensionRangeOptions");
+ "google.protobuf.ExtensionRangeOptions", alloc);
}
}
void DescriptorBuilder::BuildReservedRange(
const DescriptorProto::ReservedRange& proto, const Descriptor* parent,
- Descriptor::ReservedRange* result) {
+ Descriptor::ReservedRange* result, internal::FlatAllocator&) {
result->start = proto.start();
result->end = proto.end();
if (result->start <= 0) {
@@ -5648,7 +5821,8 @@ void DescriptorBuilder::BuildReservedRange(
void DescriptorBuilder::BuildReservedRange(
const EnumDescriptorProto::EnumReservedRange& proto,
- const EnumDescriptor* parent, EnumDescriptor::ReservedRange* result) {
+ const EnumDescriptor* parent, EnumDescriptor::ReservedRange* result,
+ internal::FlatAllocator&) {
result->start = proto.start();
result->end = proto.end();
@@ -5659,9 +5833,10 @@ void DescriptorBuilder::BuildReservedRange(
}
void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto,
- Descriptor* parent,
- OneofDescriptor* result) {
- result->all_names_ = AllocateNameStrings(parent->full_name(), proto.name());
+ Descriptor* parent, OneofDescriptor* result,
+ internal::FlatAllocator& alloc) {
+ result->all_names_ =
+ AllocateNameStrings(parent->full_name(), proto.name(), alloc);
ValidateSymbolName(proto.name(), result->full_name(), proto);
result->containing_type_ = parent;
@@ -5675,7 +5850,7 @@ void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto,
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
OneofDescriptorProto::kOptionsFieldNumber,
- "google.protobuf.OneofOptions");
+ "google.protobuf.OneofOptions", alloc);
}
AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result));
@@ -5749,11 +5924,12 @@ void DescriptorBuilder::CheckEnumValueUniqueness(
void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
const Descriptor* parent,
- EnumDescriptor* result) {
+ EnumDescriptor* result,
+ internal::FlatAllocator& alloc) {
const TProtoStringType& scope =
(parent == nullptr) ? file_->package() : parent->full_name();
- result->all_names_ = AllocateNameStrings(scope, proto.name());
+ result->all_names_ = AllocateNameStrings(scope, proto.name(), alloc);
ValidateSymbolName(proto.name(), result->full_name(), proto);
result->file_ = file_;
result->containing_type_ = parent;
@@ -5789,10 +5965,10 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
int reserved_name_count = proto.reserved_name_size();
result->reserved_name_count_ = reserved_name_count;
result->reserved_names_ =
- tables_->AllocateArray<const TProtoStringType*>(reserved_name_count);
+ alloc.AllocateArray<const TProtoStringType*>(reserved_name_count);
for (int i = 0; i < reserved_name_count; ++i) {
result->reserved_names_[i] =
- tables_->AllocateString(proto.reserved_name(i));
+ alloc.AllocateStrings(proto.reserved_name(i));
}
CheckEnumValueUniqueness(proto, result);
@@ -5802,7 +5978,7 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
EnumDescriptorProto::kOptionsFieldNumber,
- "google.protobuf.EnumOptions");
+ "google.protobuf.EnumOptions", alloc);
}
AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result));
@@ -5858,7 +6034,8 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto,
const EnumDescriptor* parent,
- EnumValueDescriptor* result) {
+ EnumValueDescriptor* result,
+ internal::FlatAllocator& alloc) {
// Note: full_name for enum values is a sibling to the parent's name, not a
// child of it.
TProtoStringType full_name;
@@ -5868,7 +6045,7 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto,
full_name.append(proto.name());
result->all_names_ =
- tables_->AllocateStringArray(proto.name(), std::move(full_name));
+ alloc.AllocateStrings(proto.name(), std::move(full_name));
result->number_ = proto.number();
result->type_ = parent;
@@ -5879,7 +6056,7 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto,
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
EnumValueDescriptorProto::kOptionsFieldNumber,
- "google.protobuf.EnumValueOptions");
+ "google.protobuf.EnumValueOptions", alloc);
}
// Again, enum values are weird because we makes them appear as siblings
@@ -5929,8 +6106,10 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto,
void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto,
const void* /* dummy */,
- ServiceDescriptor* result) {
- result->all_names_ = AllocateNameStrings(file_->package(), proto.name());
+ ServiceDescriptor* result,
+ internal::FlatAllocator& alloc) {
+ result->all_names_ =
+ AllocateNameStrings(file_->package(), proto.name(), alloc);
result->file_ = file_;
ValidateSymbolName(proto.name(), result->full_name(), proto);
@@ -5941,7 +6120,7 @@ void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto,
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
ServiceDescriptorProto::kOptionsFieldNumber,
- "google.protobuf.ServiceOptions");
+ "google.protobuf.ServiceOptions", alloc);
}
AddSymbol(result->full_name(), nullptr, result->name(), proto,
@@ -5950,9 +6129,11 @@ void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto,
void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto,
const ServiceDescriptor* parent,
- MethodDescriptor* result) {
+ MethodDescriptor* result,
+ internal::FlatAllocator& alloc) {
result->service_ = parent;
- result->all_names_ = AllocateNameStrings(parent->full_name(), proto.name());
+ result->all_names_ =
+ AllocateNameStrings(parent->full_name(), proto.name(), alloc);
ValidateSymbolName(proto.name(), result->full_name(), proto);
@@ -5965,7 +6146,7 @@ void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto,
if (proto.has_options()) {
AllocateOptions(proto.options(), result,
MethodDescriptorProto::kOptionsFieldNumber,
- "google.protobuf.MethodOptions");
+ "google.protobuf.MethodOptions", alloc);
}
result->client_streaming_ = proto.client_streaming();
@@ -6134,9 +6315,6 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
field->options_ = &FieldOptions::default_instance();
}
- // Add the field to the lowercase-name and camelcase-name tables.
- file_tables_->AddFieldByStylizedNames(field);
-
if (proto.has_extendee()) {
Symbol extendee =
LookupSymbol(proto.extendee(), field->full_name(),
@@ -6212,12 +6390,18 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
if (is_lazy) {
// Save the symbol names for later for lookup, and allocate the once
// object needed for the accessors.
- TProtoStringType name = proto.type_name();
- field->type_once_ = tables_->Create<internal::once_flag>();
- field->type_descriptor_.lazy_type_name = tables_->Strdup(name);
- field->lazy_default_value_enum_name_ =
- proto.has_default_value() ? tables_->Strdup(proto.default_value())
- : nullptr;
+ const TProtoStringType& name = proto.type_name();
+
+ int name_sizes = static_cast<int>(name.size() + 1 +
+ proto.default_value().size() + 1);
+
+ field->type_once_ = ::new (tables_->AllocateBytes(static_cast<int>(
+ sizeof(internal::once_flag) + name_sizes))) internal::once_flag{};
+ char* names = reinterpret_cast<char*>(field->type_once_ + 1);
+
+ memcpy(names, name.c_str(), name.size() + 1);
+ memcpy(names + name.size() + 1, proto.default_value().c_str(),
+ proto.default_value().size() + 1);
// AddFieldByNumber and AddExtension are done later in this function,
// and can/must be done if the field type was not found. The related
@@ -6464,7 +6648,6 @@ void DescriptorBuilder::CrossLinkMethod(MethodDescriptor* method,
method->output_type_.Set(output_type.descriptor());
}
}
-
// -------------------------------------------------------------------
#define VALIDATE_OPTIONS_FROM_ARRAY(descriptor, array_name, type) \
@@ -6658,7 +6841,7 @@ void DescriptorBuilder::ValidateFieldOptions(
return;
}
// Only message type fields may be lazy.
- if (field->options().lazy()) {
+ if (field->options().lazy() || field->options().unverified_lazy()) {
if (field->type() != FieldDescriptor::TYPE_MESSAGE) {
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
"[lazy = true] can only be specified for submessage fields.");
@@ -6875,6 +7058,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
DescriptorPool::ErrorCollector::NAME,
"Expanded map entry type " + nested->name() +
" conflicts with an existing nested message type.");
+ break;
}
}
// Recursively test on the nested types.
@@ -7216,11 +7400,9 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
new UnknownFieldSet());
switch ((*iter)->type()) {
case FieldDescriptor::TYPE_MESSAGE: {
- io::StringOutputStream outstr(
- parent_unknown_fields->AddLengthDelimited((*iter)->number()));
- io::CodedOutputStream out(&outstr);
- internal::WireFormat::SerializeUnknownFields(*unknown_fields, &out);
- GOOGLE_CHECK(!out.HadError())
+ TProtoStringType* outstr =
+ parent_unknown_fields->AddLengthDelimited((*iter)->number());
+ GOOGLE_CHECK(unknown_fields->SerializeToString(outstr))
<< "Unexpected failure while serializing option submessage "
<< debug_msg_name << "\".";
break;
@@ -7878,8 +8060,11 @@ Symbol DescriptorPool::CrossLinkOnDemandHelper(StringPiece name,
void FieldDescriptor::InternalTypeOnceInit() const {
GOOGLE_CHECK(file()->finished_building_ == true);
const EnumDescriptor* enum_type = nullptr;
+ const char* lazy_type_name = reinterpret_cast<const char*>(type_once_ + 1);
+ const char* lazy_default_value_enum_name =
+ lazy_type_name + strlen(lazy_type_name) + 1;
Symbol result = file()->pool()->CrossLinkOnDemandHelper(
- type_descriptor_.lazy_type_name, type_ == FieldDescriptor::TYPE_ENUM);
+ lazy_type_name, type_ == FieldDescriptor::TYPE_ENUM);
if (result.type() == Symbol::MESSAGE) {
type_ = FieldDescriptor::TYPE_MESSAGE;
type_descriptor_.message_type = result.descriptor();
@@ -7889,16 +8074,16 @@ void FieldDescriptor::InternalTypeOnceInit() const {
}
if (enum_type) {
- if (lazy_default_value_enum_name_) {
+ if (lazy_default_value_enum_name[0] != '\0') {
// Have to build the full name now instead of at CrossLink time,
// because enum_type may not be known at the time.
TProtoStringType name = enum_type->full_name();
// Enum values reside in the same scope as the enum type.
TProtoStringType::size_type last_dot = name.find_last_of('.');
if (last_dot != TProtoStringType::npos) {
- name = name.substr(0, last_dot) + "." + lazy_default_value_enum_name_;
+ name = name.substr(0, last_dot) + "." + lazy_default_value_enum_name;
} else {
- name = lazy_default_value_enum_name_;
+ name = lazy_default_value_enum_name;
}
Symbol result = file()->pool()->CrossLinkOnDemandHelper(name, true);
default_value_enum_ = result.enum_value_descriptor();
@@ -7955,10 +8140,12 @@ const TProtoStringType& FieldDescriptor::PrintableNameForExtension() const {
void FileDescriptor::InternalDependenciesOnceInit() const {
GOOGLE_CHECK(finished_building_ == true);
- auto* names = dependencies_once_->dependencies_names;
+ const char* names_ptr = reinterpret_cast<const char*>(dependencies_once_ + 1);
for (int i = 0; i < dependency_count(); i++) {
- if (names[i]) {
- dependencies_[i] = pool_->FindFileByName(names[i]);
+ const char* name = names_ptr;
+ names_ptr += strlen(name) + 1;
+ if (name[0] != '\0') {
+ dependencies_[i] = pool_->FindFileByName(name);
}
}
}
@@ -7971,7 +8158,7 @@ const FileDescriptor* FileDescriptor::dependency(int index) const {
if (dependencies_once_) {
// Do once init for all indices, as it's unlikely only a single index would
// be called, and saves on internal::call_once allocations.
- internal::call_once(dependencies_once_->once,
+ internal::call_once(*dependencies_once_,
FileDescriptor::DependenciesOnceInit, this);
}
return dependencies_[index];
@@ -7985,7 +8172,6 @@ const Descriptor* MethodDescriptor::output_type() const {
return output_type_.Get(service());
}
-
namespace internal {
void LazyDescriptor::Set(const Descriptor* descriptor) {
GOOGLE_CHECK(!once_);
@@ -8000,8 +8186,11 @@ void LazyDescriptor::SetLazy(StringPiece name,
GOOGLE_CHECK(file && file->pool_);
GOOGLE_CHECK(file->pool_->lazily_build_dependencies_);
GOOGLE_CHECK(!file->finished_building_);
- once_ = file->pool_->tables_->Create<internal::once_flag>();
- lazy_name_ = file->pool_->tables_->Strdup(name);
+ once_ = ::new (file->pool_->tables_->AllocateBytes(static_cast<int>(
+ sizeof(internal::once_flag) + name.size() + 1))) internal::once_flag{};
+ char* lazy_name = reinterpret_cast<char*>(once_ + 1);
+ memcpy(lazy_name, name.data(), name.size());
+ lazy_name[name.size()] = 0;
}
void LazyDescriptor::Once(const ServiceDescriptor* service) {
@@ -8009,8 +8198,9 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) {
internal::call_once(*once_, [&] {
auto* file = service->file();
GOOGLE_CHECK(file->finished_building_);
+ const char* lazy_name = reinterpret_cast<const char*>(once_ + 1);
descriptor_ =
- file->pool_->CrossLinkOnDemandHelper(lazy_name_, false).descriptor();
+ file->pool_->CrossLinkOnDemandHelper(lazy_name, false).descriptor();
});
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.h b/contrib/libs/protobuf/src/google/protobuf/descriptor.h
index 10dcc1eab0..57af37c6c1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.h
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.h
@@ -54,6 +54,7 @@
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__
#define GOOGLE_PROTOBUF_DESCRIPTOR_H__
+
#include <atomic>
#include <map>
#include <memory>
@@ -66,6 +67,8 @@
#include <google/protobuf/stubs/mutex.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/port.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
@@ -184,6 +187,19 @@ struct DebugStringOptions {
// Must be instantiated as mutable in a descriptor.
namespace internal {
+// The classes in this file represent a significant memory footprint for the
+// library. We make sure we are not accidentally making them larger by
+// hardcoding the struct size for a specific platform. Use as:
+//
+// PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(type, expected_size_in_x84-64);
+//
+
+#if !defined(PROTOBUF_INTERNAL_CHECK_CLASS_SIZE)
+#define PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(t, expected)
+#endif
+
+class FlatAllocator;
+
class PROTOBUF_EXPORT LazyDescriptor {
public:
// Init function to be called at init time of a descriptor containing
@@ -217,10 +233,8 @@ class PROTOBUF_EXPORT LazyDescriptor {
private:
void Once(const ServiceDescriptor* service);
- union {
- const Descriptor* descriptor_;
- const char* lazy_name_;
- };
+ const Descriptor* descriptor_;
+ // The once_ flag is followed by a NUL terminated string for the type name.
internal::once_flag* once_;
};
@@ -598,6 +612,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136);
// Describes a single field of a message. To get the descriptor for a given
// field, first get the Descriptor for the message in which it is defined,
@@ -924,6 +939,8 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
const TProtoStringType* all_names_;
const FileDescriptor* file_;
+ // The once_flag is followed by a NUL terminated string for the type name and
+ // enum default value (or empty string if no default enum).
internal::once_flag* type_once_;
static void TypeOnceInit(const FieldDescriptor* to_init);
void InternalTypeOnceInit() const;
@@ -935,7 +952,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
union {
mutable const Descriptor* message_type;
mutable const EnumDescriptor* enum_type;
- const char* lazy_type_name;
} type_descriptor_;
const FieldOptions* options_;
// IMPORTANT: If you add a new field, make sure to search for all instances
@@ -952,7 +968,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
bool default_value_bool_;
mutable const EnumValueDescriptor* default_value_enum_;
- const char* lazy_default_value_enum_name_;
const TProtoStringType* default_value_string_;
mutable std::atomic<const Message*> default_generated_instance_;
};
@@ -974,6 +989,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72);
// Describes a oneof defined in a message type.
class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
@@ -1054,6 +1070,8 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40);
+
// Describes an enum type defined in a .proto file. To get the EnumDescriptor
// for a generated enum type, call TypeName_descriptor(). Use DescriptorPool
// to construct your own descriptors.
@@ -1223,6 +1241,8 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72);
+
// Describes an individual enum constant of a particular type. To get the
// EnumValueDescriptor for a given enum value, first get the EnumDescriptor
// for its type, then use EnumDescriptor::FindValueByName() or
@@ -1306,6 +1326,8 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>,
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32);
+
// Describes an RPC service. Use DescriptorPool to construct your own
// descriptors.
class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
@@ -1336,6 +1358,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
// Look up a MethodDescriptor by name.
const MethodDescriptor* FindMethodByName(ConstStringParam name) const;
+
// See Descriptor::CopyTo().
void CopyTo(ServiceDescriptorProto* proto) const;
@@ -1386,6 +1409,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48);
// Describes an individual service method. To obtain a MethodDescriptor given
// a service, first get its ServiceDescriptor, then call
@@ -1474,11 +1498,12 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64);
// Describes a whole .proto file. To get the FileDescriptor for a compiled-in
// file, get the descriptor for something defined in that file and call
// descriptor->file(). Use DescriptorPool to construct your own descriptors.
-class PROTOBUF_EXPORT FileDescriptor {
+class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
public:
typedef FileDescriptorProto Proto;
@@ -1615,21 +1640,27 @@ class PROTOBUF_EXPORT FileDescriptor {
SourceLocation* out_location) const;
private:
+ friend class Symbol;
typedef FileOptions OptionsType;
+ bool is_placeholder_;
+ // Indicates the FileDescriptor is completed building. Used to verify
+ // that type accessor functions that can possibly build a dependent file
+ // aren't called during the process of building the file.
+ bool finished_building_;
+ // Actually a `Syntax` but stored as uint8_t to save space.
+ uint8_t syntax_;
+ // This one is here to fill the padding.
+ int extension_count_;
+
const TProtoStringType* name_;
const TProtoStringType* package_;
const DescriptorPool* pool_;
- // Data required to do lazy initialization.
- struct PROTOBUF_EXPORT LazyInitData {
-#ifndef SWIG
- internal::once_flag once;
-#endif
- const char** dependencies_names;
- };
-
- LazyInitData* dependencies_once_;
+ // dependencies_once_ contain a once_flag followed by N NUL terminated
+ // strings. Dependencies that do not need to be loaded will be empty. ie just
+ // {'\0'}
+ internal::once_flag* dependencies_once_;
static void DependenciesOnceInit(const FileDescriptor* to_init);
void InternalDependenciesOnceInit() const;
@@ -1641,16 +1672,6 @@ class PROTOBUF_EXPORT FileDescriptor {
int enum_type_count_;
int service_count_;
- bool is_placeholder_;
- // Indicates the FileDescriptor is completed building. Used to verify
- // that type accessor functions that can possibly build a dependent file
- // aren't called during the process of building the file.
- bool finished_building_;
- // Actually a `Syntax` but stored as uint8_t to save space.
- uint8_t syntax_;
- // This one is here to fill the padding.
- int extension_count_;
-
mutable const FileDescriptor** dependencies_;
int* public_dependencies_;
int* weak_dependencies_;
@@ -1681,6 +1702,7 @@ class PROTOBUF_EXPORT FileDescriptor {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor);
};
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 144);
// ===================================================================
@@ -1973,7 +1995,6 @@ class PROTOBUF_EXPORT DescriptorPool {
friend class ServiceDescriptor;
friend class MethodDescriptor;
friend class FileDescriptor;
- friend class StreamDescriptor;
friend class DescriptorBuilder;
friend class FileDescriptorTables;
@@ -2013,7 +2034,8 @@ class PROTOBUF_EXPORT DescriptorPool {
// Create a placeholder FileDescriptor of the specified name
FileDescriptor* NewPlaceholderFile(StringPiece name) const;
- FileDescriptor* NewPlaceholderFileWithMutexHeld(StringPiece name) const;
+ FileDescriptor* NewPlaceholderFileWithMutexHeld(
+ StringPiece name, internal::FlatAllocator& alloc) const;
enum PlaceholderType {
PLACEHOLDER_MESSAGE,
@@ -2412,6 +2434,7 @@ inline FileDescriptor::Syntax FileDescriptor::syntax() const {
} // namespace protobuf
} // namespace google
+#undef PROTOBUF_INTERNAL_CHECK_CLASS_SIZE
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_DESCRIPTOR_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc
index 928223de68..2f93b32da1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc
@@ -16,21 +16,25 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr FileDescriptorSet::FileDescriptorSet(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR FileDescriptorSet::FileDescriptorSet(
+ ::_pbi::ConstantInitialized)
: file_(){}
struct FileDescriptorSetDefaultTypeInternal {
- constexpr FileDescriptorSetDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FileDescriptorSetDefaultTypeInternal() {}
union {
FileDescriptorSet _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
-constexpr FileDescriptorProto::FileDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
+PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto(
+ ::_pbi::ConstantInitialized)
: dependency_()
, message_type_()
, enum_type_()
@@ -38,49 +42,49 @@ constexpr FileDescriptorProto::FileDescriptorProto(
, extension_()
, public_dependency_()
, weak_dependency_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , syntax_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , syntax_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr)
, source_code_info_(nullptr){}
struct FileDescriptorProtoDefaultTypeInternal {
- constexpr FileDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FileDescriptorProtoDefaultTypeInternal() {}
union {
FileDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
-constexpr DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(
+ ::_pbi::ConstantInitialized)
: options_(nullptr)
, start_(0)
, end_(0){}
struct DescriptorProto_ExtensionRangeDefaultTypeInternal {
- constexpr DescriptorProto_ExtensionRangeDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProto_ExtensionRangeDefaultTypeInternal() {}
union {
DescriptorProto_ExtensionRange _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
-constexpr DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
+PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(
+ ::_pbi::ConstantInitialized)
: start_(0)
, end_(0){}
struct DescriptorProto_ReservedRangeDefaultTypeInternal {
- constexpr DescriptorProto_ReservedRangeDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProto_ReservedRangeDefaultTypeInternal() {}
union {
DescriptorProto_ReservedRange _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
-constexpr DescriptorProto::DescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
+PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto(
+ ::_pbi::ConstantInitialized)
: field_()
, nested_type_()
, enum_type_()
@@ -89,36 +93,36 @@ constexpr DescriptorProto::DescriptorProto(
, oneof_decl_()
, reserved_range_()
, reserved_name_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct DescriptorProtoDefaultTypeInternal {
- constexpr DescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProtoDefaultTypeInternal() {}
union {
DescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
-constexpr ExtensionRangeOptions::ExtensionRangeOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR ExtensionRangeOptions::ExtensionRangeOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_(){}
struct ExtensionRangeOptionsDefaultTypeInternal {
- constexpr ExtensionRangeOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~ExtensionRangeOptionsDefaultTypeInternal() {}
union {
ExtensionRangeOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
-constexpr FieldDescriptorProto::FieldDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , extendee_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , type_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , default_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , json_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
+PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , extendee_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , type_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , default_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , json_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr)
, number_(0)
, oneof_index_(0)
@@ -128,114 +132,114 @@ constexpr FieldDescriptorProto::FieldDescriptorProto(
, type_(1)
{}
struct FieldDescriptorProtoDefaultTypeInternal {
- constexpr FieldDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FieldDescriptorProtoDefaultTypeInternal() {}
union {
FieldDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
-constexpr OneofDescriptorProto::OneofDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct OneofDescriptorProtoDefaultTypeInternal {
- constexpr OneofDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~OneofDescriptorProtoDefaultTypeInternal() {}
union {
OneofDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
-constexpr EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(
+ ::_pbi::ConstantInitialized)
: start_(0)
, end_(0){}
struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal {
- constexpr EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {}
union {
EnumDescriptorProto_EnumReservedRange _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
-constexpr EnumDescriptorProto::EnumDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
+PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto(
+ ::_pbi::ConstantInitialized)
: value_()
, reserved_range_()
, reserved_name_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct EnumDescriptorProtoDefaultTypeInternal {
- constexpr EnumDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumDescriptorProtoDefaultTypeInternal() {}
union {
EnumDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
-constexpr EnumValueDescriptorProto::EnumValueDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr)
, number_(0){}
struct EnumValueDescriptorProtoDefaultTypeInternal {
- constexpr EnumValueDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueDescriptorProtoDefaultTypeInternal() {}
union {
EnumValueDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
-constexpr ServiceDescriptorProto::ServiceDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto(
+ ::_pbi::ConstantInitialized)
: method_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct ServiceDescriptorProtoDefaultTypeInternal {
- constexpr ServiceDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~ServiceDescriptorProtoDefaultTypeInternal() {}
union {
ServiceDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
-constexpr MethodDescriptorProto::MethodDescriptorProto(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , input_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , output_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , input_type_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , output_type_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr)
, client_streaming_(false)
, server_streaming_(false){}
struct MethodDescriptorProtoDefaultTypeInternal {
- constexpr MethodDescriptorProtoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~MethodDescriptorProtoDefaultTypeInternal() {}
union {
MethodDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
-constexpr FileOptions::FileOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
+PROTOBUF_CONSTEXPR FileOptions::FileOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
- , java_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , java_outer_classname_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , go_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , objc_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , csharp_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , swift_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , php_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , php_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , php_metadata_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , ruby_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , java_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , java_outer_classname_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , go_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , objc_class_prefix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , csharp_namespace_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , swift_prefix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , php_class_prefix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , php_namespace_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , php_metadata_namespace_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , ruby_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, java_multiple_files_(false)
, java_generate_equals_and_hash_(false)
, java_string_check_utf8_(false)
@@ -248,210 +252,211 @@ constexpr FileOptions::FileOptions(
, cc_enable_arenas_(true){}
struct FileOptionsDefaultTypeInternal {
- constexpr FileOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FileOptionsDefaultTypeInternal() {}
union {
FileOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
-constexpr MessageOptions::MessageOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
+PROTOBUF_CONSTEXPR MessageOptions::MessageOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
, message_set_wire_format_(false)
, no_standard_descriptor_accessor_(false)
, deprecated_(false)
, map_entry_(false){}
struct MessageOptionsDefaultTypeInternal {
- constexpr MessageOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~MessageOptionsDefaultTypeInternal() {}
union {
MessageOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
-constexpr FieldOptions::FieldOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
+PROTOBUF_CONSTEXPR FieldOptions::FieldOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
, ctype_(0)
+ , jstype_(0)
+
, packed_(false)
, lazy_(false)
+ , unverified_lazy_(false)
, deprecated_(false)
- , weak_(false)
- , jstype_(0)
-{}
+ , weak_(false){}
struct FieldOptionsDefaultTypeInternal {
- constexpr FieldOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FieldOptionsDefaultTypeInternal() {}
union {
FieldOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
-constexpr OneofOptions::OneofOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
+PROTOBUF_CONSTEXPR OneofOptions::OneofOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_(){}
struct OneofOptionsDefaultTypeInternal {
- constexpr OneofOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~OneofOptionsDefaultTypeInternal() {}
union {
OneofOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
-constexpr EnumOptions::EnumOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
+PROTOBUF_CONSTEXPR EnumOptions::EnumOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
, allow_alias_(false)
, deprecated_(false){}
struct EnumOptionsDefaultTypeInternal {
- constexpr EnumOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumOptionsDefaultTypeInternal() {}
union {
EnumOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
-constexpr EnumValueOptions::EnumValueOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
+PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
, deprecated_(false){}
struct EnumValueOptionsDefaultTypeInternal {
- constexpr EnumValueOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueOptionsDefaultTypeInternal() {}
union {
EnumValueOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
-constexpr ServiceOptions::ServiceOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
+PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
, deprecated_(false){}
struct ServiceOptionsDefaultTypeInternal {
- constexpr ServiceOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~ServiceOptionsDefaultTypeInternal() {}
union {
ServiceOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
-constexpr MethodOptions::MethodOptions(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
+PROTOBUF_CONSTEXPR MethodOptions::MethodOptions(
+ ::_pbi::ConstantInitialized)
: uninterpreted_option_()
, deprecated_(false)
, idempotency_level_(0)
{}
struct MethodOptionsDefaultTypeInternal {
- constexpr MethodOptionsDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~MethodOptionsDefaultTypeInternal() {}
union {
MethodOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
-constexpr UninterpretedOption_NamePart::UninterpretedOption_NamePart(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_part_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
+PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart(
+ ::_pbi::ConstantInitialized)
+ : name_part_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, is_extension_(false){}
struct UninterpretedOption_NamePartDefaultTypeInternal {
- constexpr UninterpretedOption_NamePartDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~UninterpretedOption_NamePartDefaultTypeInternal() {}
union {
UninterpretedOption_NamePart _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
-constexpr UninterpretedOption::UninterpretedOption(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
+PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption(
+ ::_pbi::ConstantInitialized)
: name_()
- , identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , string_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , aggregate_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , identifier_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , string_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , aggregate_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, positive_int_value_(arc_ui64{0u})
, negative_int_value_(arc_i64{0})
, double_value_(0){}
struct UninterpretedOptionDefaultTypeInternal {
- constexpr UninterpretedOptionDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~UninterpretedOptionDefaultTypeInternal() {}
union {
UninterpretedOption _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
-constexpr SourceCodeInfo_Location::SourceCodeInfo_Location(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
+PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location(
+ ::_pbi::ConstantInitialized)
: path_()
, _path_cached_byte_size_(0)
, span_()
, _span_cached_byte_size_(0)
, leading_detached_comments_()
- , leading_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , trailing_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
+ , leading_comments_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , trailing_comments_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct SourceCodeInfo_LocationDefaultTypeInternal {
- constexpr SourceCodeInfo_LocationDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~SourceCodeInfo_LocationDefaultTypeInternal() {}
union {
SourceCodeInfo_Location _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
-constexpr SourceCodeInfo::SourceCodeInfo(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
+PROTOBUF_CONSTEXPR SourceCodeInfo::SourceCodeInfo(
+ ::_pbi::ConstantInitialized)
: location_(){}
struct SourceCodeInfoDefaultTypeInternal {
- constexpr SourceCodeInfoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~SourceCodeInfoDefaultTypeInternal() {}
union {
SourceCodeInfo _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
-constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
+PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(
+ ::_pbi::ConstantInitialized)
: path_()
, _path_cached_byte_size_(0)
- , source_file_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , source_file_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, begin_(0)
, end_(0){}
struct GeneratedCodeInfo_AnnotationDefaultTypeInternal {
- constexpr GeneratedCodeInfo_AnnotationDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {}
union {
GeneratedCodeInfo_Annotation _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
-constexpr GeneratedCodeInfo::GeneratedCodeInfo(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
+PROTOBUF_CONSTEXPR GeneratedCodeInfo::GeneratedCodeInfo(
+ ::_pbi::ConstantInitialized)
: annotation_(){}
struct GeneratedCodeInfoDefaultTypeInternal {
- constexpr GeneratedCodeInfoDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~GeneratedCodeInfoDefaultTypeInternal() {}
union {
GeneratedCodeInfo _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27];
-static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6];
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27];
+static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6];
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -726,15 +731,17 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, packed_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, jstype_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, lazy_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, unverified_lazy_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, deprecated_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, weak_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, uninterpreted_option_),
0,
- 1,
- 5,
2,
+ 1,
3,
4,
+ 5,
+ 6,
~0u,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_),
@@ -862,7 +869,7 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, annotation_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)},
{ 7, 25, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)},
{ 37, 46, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)},
@@ -878,48 +885,48 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB
{ 180, 192, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)},
{ 198, 225, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)},
{ 246, 257, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)},
- { 262, 275, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)},
- { 282, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)},
- { 289, 298, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)},
- { 301, 309, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)},
- { 311, 319, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)},
- { 321, 330, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)},
- { 333, 341, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)},
- { 343, 356, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)},
- { 363, 374, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)},
- { 379, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)},
- { 386, 396, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)},
- { 400, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)},
+ { 262, 276, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)},
+ { 284, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)},
+ { 291, 300, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)},
+ { 303, 311, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)},
+ { 313, 321, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)},
+ { 323, 332, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)},
+ { 335, 343, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)},
+ { 345, 358, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)},
+ { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)},
+ { 381, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)},
+ { 388, 398, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)},
+ { 402, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -1023,72 +1030,74 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR
"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\004\020\005"
- "J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOption"
+ "J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020\n\"\276\003\n\014FieldOption"
"s\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.Field"
"Options.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n"
"\006jstype\030\006 \001(\0162$.google.protobuf.FieldOpt"
"ions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005fa"
- "lse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n"
+ "lse\022\036\n\017unverified_lazy\030\017 \001(\010:\005false\022\031\n\nd"
+ "eprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005fa"
+ "lse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo"
+ "gle.protobuf.UninterpretedOption\"/\n\005CTyp"
+ "e\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_STRING\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\014One"
+ "ofOptions\022C\n\024uninterpreted_option\030\347\007 \003(\013"
+ "2$.google.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\ndeprecated\030\003 \001(\010:\005false\022C\n\024uni"
+ "nterpreted_option\030\347\007 \003(\0132$.google.protob"
+ "uf.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.UninterpretedOption*\t\010\350\007"
+ "\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030!"
" \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003"
"(\0132$.google.protobuf.UninterpretedOption"
- "\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRIN"
- "G_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS"
- "_STRING\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_optio"
- "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted"
- "Option*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013all"
- "ow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \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"
- "\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\ndeprecate"
- "d\030\001 \001(\010:\005false\022C\n\024uninterpreted_option\030\347"
- "\007 \003(\0132$.google.protobuf.UninterpretedOpt"
- "ion*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndepr"
- "ecated\030! \001(\010:\005false\022C\n\024uninterpreted_opt"
- "ion\030\347\007 \003(\0132$.google.protobuf.Uninterpret"
- "edOption*\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/.google.protobuf.MethodOpti"
- "ons.IdempotencyLevel:\023IDEMPOTENCY_UNKNOW"
- "N\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl"
- "e.protobuf.UninterpretedOption\"P\n\020Idempo"
- "tencyLevel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017N"
- "O_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."
- "NamePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022po"
- "sitive_int_value\030\004 \001(\004\022\032\n\022negative_int_v"
- "alue\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014stri"
- "ng_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\032"
- "3\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_ext"
- "ension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010locat"
- "ion\030\001 \003(\0132(.google.protobuf.SourceCodeIn"
- "fo.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\031lea"
- "ding_detached_comments\030\006 \003(\t\"\247\001\n\021Generat"
- "edCodeInfo\022A\n\nannotation\030\001 \003(\0132-.google."
- "protobuf.GeneratedCodeInfo.Annotation\032O\n"
- "\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_"
- "file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B~"
- "\n\023com.google.protobufB\020DescriptorProtosH"
- "\001Z-google.golang.org/protobuf/types/desc"
- "riptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Refl"
- "ection"
+ "*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndepreca"
+ "ted\030! \001(\010:\005false\022_\n\021idempotency_level\030\" "
+ "\001(\0162/.google.protobuf.MethodOptions.Idem"
+ "potencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024uni"
+ "nterpreted_option\030\347\007 \003(\0132$.google.protob"
+ "uf.UninterpretedOption\"P\n\020IdempotencyLev"
+ "el\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_E"
+ "FFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023"
+ "UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goog"
+ "le.protobuf.UninterpretedOption.NamePart"
+ "\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_i"
+ "nt_value\030\004 \001(\004\022\032\n\022negative_int_value\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\010NameP"
+ "art\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002"
+ " \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003("
+ "\0132(.google.protobuf.SourceCodeInfo.Locat"
+ "ion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004sp"
+ "an\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_det"
+ "ached_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeIn"
+ "fo\022A\n\nannotation\030\001 \003(\0132-.google.protobuf"
+ ".GeneratedCodeInfo.Annotation\032O\n\nAnnotat"
+ "ion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001"
+ "(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B~\n\023com.go"
+ "ogle.protobufB\020DescriptorProtosH\001Z-googl"
+ "e.golang.org/protobuf/types/descriptorpb"
+ "\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Reflection"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = {
- false, false, 6046, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto",
- &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = {
+ false, false, 6078, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto,
+ "google/protobuf/descriptor.proto",
+ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
PROTOBUF_NAMESPACE_OPEN
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Type_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
@@ -1270,9 +1279,6 @@ FileDescriptorSet::FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
file_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorSet)
}
FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)
@@ -1287,21 +1293,17 @@ inline void FileDescriptorSet::SharedCtor() {
FileDescriptorSet::~FileDescriptorSet() {
// @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorSet)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FileDescriptorSet::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void FileDescriptorSet::ArenaDtor(void* object) {
- FileDescriptorSet* _this = reinterpret_cast< FileDescriptorSet* >(object);
- (void)_this;
-}
-void FileDescriptorSet::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FileDescriptorSet::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1316,11 +1318,11 @@ void FileDescriptorSet::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FileDescriptorSet::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FileDescriptorSet::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.FileDescriptorProto file = 1;
case 1:
@@ -1365,15 +1367,15 @@ uint8_t* FileDescriptorSet::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.FileDescriptorProto file = 1;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_file_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_file_size()); i < n; i++) {
+ const auto& repfield = this->_internal_file(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(1, this->_internal_file(i), target, stream);
+ InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1441,7 +1443,7 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]);
}
@@ -1489,9 +1491,6 @@ FileDescriptorProto::FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
public_dependency_(arena),
weak_dependency_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorProto)
}
FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
@@ -1505,28 +1504,28 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
public_dependency_(from.public_dependency_),
weak_dependency_(from.weak_dependency_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_package()) {
- package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_package(),
+ package_.Set(from._internal_package(),
GetArenaForAllocation());
}
- syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ syntax_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ syntax_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_syntax()) {
- syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_syntax(),
+ syntax_.Set(from._internal_syntax(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -1543,17 +1542,17 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
}
inline void FileDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+syntax_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ syntax_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@@ -1563,26 +1562,22 @@ syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlrea
FileDescriptorProto::~FileDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FileDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- syntax_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ package_.Destroy();
+ syntax_.Destroy();
if (this != internal_default_instance()) delete options_;
if (this != internal_default_instance()) delete source_code_info_;
}
-void FileDescriptorProto::ArenaDtor(void* object) {
- FileDescriptorProto* _this = reinterpret_cast< FileDescriptorProto* >(object);
- (void)_this;
-}
-void FileDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FileDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1624,22 +1619,22 @@ void FileDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1647,11 +1642,11 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_package();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.package");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.package");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1662,11 +1657,11 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME
do {
ptr += 1;
auto str = _internal_add_dependency();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.dependency");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.dependency");
#endif // !NDEBUG
- CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
} else
@@ -1776,11 +1771,11 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME
case 12:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 98)) {
auto str = _internal_mutable_syntax();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.syntax");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.syntax");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1846,63 +1841,61 @@ uint8_t* FileDescriptorProto::_InternalSerialize(
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_message_type_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_message_type_size()); i < n; i++) {
+ const auto& repfield = this->_internal_message_type(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(4, this->_internal_message_type(i), target, stream);
+ InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_enum_type_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_enum_type_size()); i < n; i++) {
+ const auto& repfield = this->_internal_enum_type(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(5, this->_internal_enum_type(i), target, stream);
+ InternalWriteMessage(5, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_service_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_service_size()); i < n; i++) {
+ const auto& repfield = this->_internal_service(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(6, this->_internal_service(i), target, stream);
+ InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_extension_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_extension_size()); i < n; i++) {
+ const auto& repfield = this->_internal_extension(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(7, this->_internal_extension(i), target, stream);
+ InternalWriteMessage(7, repfield, repfield.GetCachedSize(), target, stream);
}
// optional .google.protobuf.FileOptions options = 8;
if (cached_has_bits & 0x00000008u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 8, _Internal::options(this), target, stream);
+ InternalWriteMessage(8, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (cached_has_bits & 0x00000010u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 9, _Internal::source_code_info(this), target, stream);
+ InternalWriteMessage(9, _Internal::source_code_info(this),
+ _Internal::source_code_info(this).GetCachedSize(), target, stream);
}
// repeated int32 public_dependency = 10;
for (int i = 0, n = this->_internal_public_dependency_size(); i < n; i++) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(10, this->_internal_public_dependency(i), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(10, this->_internal_public_dependency(i), target);
}
// repeated int32 weak_dependency = 11;
for (int i = 0, n = this->_internal_weak_dependency_size(); i < n; i++) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(11, this->_internal_weak_dependency(i), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(11, this->_internal_weak_dependency(i), target);
}
// optional string syntax = 12;
@@ -1916,7 +1909,7 @@ uint8_t* FileDescriptorProto::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1969,19 +1962,19 @@ size_t FileDescriptorProto::ByteSizeLong() const {
// repeated int32 public_dependency = 10;
{
- size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
+ size_t data_size = ::_pbi::WireFormatLite::
Int32Size(this->public_dependency_);
total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_public_dependency_size());
+ ::_pbi::FromIntSize(this->_internal_public_dependency_size());
total_size += data_size;
}
// repeated int32 weak_dependency = 11;
{
- size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
+ size_t data_size = ::_pbi::WireFormatLite::
Int32Size(this->weak_dependency_);
total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_weak_dependency_size());
+ ::_pbi::FromIntSize(this->_internal_weak_dependency_size());
total_size += data_size;
}
@@ -2109,17 +2102,14 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
public_dependency_.InternalSwap(&other->public_dependency_);
weak_dependency_.InternalSwap(&other->weak_dependency_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&package_, lhs_arena,
&other->package_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&syntax_, lhs_arena,
&other->syntax_, rhs_arena
);
@@ -2132,7 +2122,7 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]);
}
@@ -2162,9 +2152,6 @@ DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(::PROTOBUF_NAMESP
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from)
@@ -2191,9 +2178,11 @@ inline void DescriptorProto_ExtensionRange::SharedCtor() {
DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() {
// @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ExtensionRange)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void DescriptorProto_ExtensionRange::SharedDtor() {
@@ -2201,12 +2190,6 @@ inline void DescriptorProto_ExtensionRange::SharedDtor() {
if (this != internal_default_instance()) delete options_;
}
-void DescriptorProto_ExtensionRange::ArenaDtor(void* object) {
- DescriptorProto_ExtensionRange* _this = reinterpret_cast< DescriptorProto_ExtensionRange* >(object);
- (void)_this;
-}
-void DescriptorProto_ExtensionRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void DescriptorProto_ExtensionRange::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -2231,12 +2214,12 @@ void DescriptorProto_ExtensionRange::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 start = 1;
case 1:
@@ -2298,25 +2281,24 @@ uint8_t* DescriptorProto_ExtensionRange::_InternalSerialize(
// optional int32 start = 1;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
}
// optional .google.protobuf.ExtensionRangeOptions options = 3;
if (cached_has_bits & 0x00000001u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 3, _Internal::options(this), target, stream);
+ InternalWriteMessage(3, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -2342,12 +2324,12 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
// optional int32 start = 1;
if (cached_has_bits & 0x00000002u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_start());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start());
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
}
}
@@ -2416,7 +2398,7 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange
}
::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]);
}
@@ -2438,9 +2420,6 @@ DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(::PROTOBUF_NAMESPAC
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ReservedRange)
}
DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from)
@@ -2462,21 +2441,17 @@ inline void DescriptorProto_ReservedRange::SharedCtor() {
DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() {
// @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ReservedRange)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void DescriptorProto_ReservedRange::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void DescriptorProto_ReservedRange::ArenaDtor(void* object) {
- DescriptorProto_ReservedRange* _this = reinterpret_cast< DescriptorProto_ReservedRange* >(object);
- (void)_this;
-}
-void DescriptorProto_ReservedRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void DescriptorProto_ReservedRange::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -2497,12 +2472,12 @@ void DescriptorProto_ReservedRange::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 start = 1;
case 1:
@@ -2556,17 +2531,17 @@ uint8_t* DescriptorProto_ReservedRange::_InternalSerialize(
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -2585,12 +2560,12 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_start());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start());
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
}
}
@@ -2653,7 +2628,7 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange*
}
::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]);
}
@@ -2688,9 +2663,6 @@ DescriptorProto::DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
reserved_range_(arena),
reserved_name_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto)
}
DescriptorProto::DescriptorProto(const DescriptorProto& from)
@@ -2705,12 +2677,12 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
reserved_range_(from.reserved_range_),
reserved_name_(from.reserved_name_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -2722,32 +2694,28 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
}
inline void DescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr;
}
DescriptorProto::~DescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void DescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void DescriptorProto::ArenaDtor(void* object) {
- DescriptorProto* _this = reinterpret_cast< DescriptorProto* >(object);
- (void)_this;
-}
-void DescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void DescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -2780,22 +2748,22 @@ void DescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.DescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.DescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -2905,11 +2873,11 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC
do {
ptr += 1;
auto str = _internal_add_reserved_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.DescriptorProto.reserved_name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.DescriptorProto.reserved_name");
#endif // !NDEBUG
- CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr));
} else
@@ -2957,67 +2925,66 @@ uint8_t* DescriptorProto::_InternalSerialize(
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_field_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_field_size()); i < n; i++) {
+ const auto& repfield = this->_internal_field(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_field(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_nested_type_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_nested_type_size()); i < n; i++) {
+ const auto& repfield = this->_internal_nested_type(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(3, this->_internal_nested_type(i), target, stream);
+ InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_enum_type_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_enum_type_size()); i < n; i++) {
+ const auto& repfield = this->_internal_enum_type(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(4, this->_internal_enum_type(i), target, stream);
+ InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_extension_range_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_extension_range_size()); i < n; i++) {
+ const auto& repfield = this->_internal_extension_range(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(5, this->_internal_extension_range(i), target, stream);
+ InternalWriteMessage(5, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_extension_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_extension_size()); i < n; i++) {
+ const auto& repfield = this->_internal_extension(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(6, this->_internal_extension(i), target, stream);
+ InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream);
}
// optional .google.protobuf.MessageOptions options = 7;
if (cached_has_bits & 0x00000002u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 7, _Internal::options(this), target, stream);
+ InternalWriteMessage(7, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_oneof_decl_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_oneof_decl_size()); i < n; i++) {
+ const auto& repfield = this->_internal_oneof_decl(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(8, this->_internal_oneof_decl(i), target, stream);
+ InternalWriteMessage(8, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_reserved_range_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_reserved_range_size()); i < n; i++) {
+ const auto& repfield = this->_internal_reserved_range(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(9, this->_internal_reserved_range(i), target, stream);
+ InternalWriteMessage(9, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated string reserved_name = 10;
@@ -3031,7 +2998,7 @@ uint8_t* DescriptorProto::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -3203,7 +3170,6 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -3211,7 +3177,7 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]);
}
@@ -3228,9 +3194,6 @@ ExtensionRangeOptions::ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* are
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.ExtensionRangeOptions)
}
ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from)
@@ -3246,21 +3209,17 @@ inline void ExtensionRangeOptions::SharedCtor() {
ExtensionRangeOptions::~ExtensionRangeOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.ExtensionRangeOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ExtensionRangeOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void ExtensionRangeOptions::ArenaDtor(void* object) {
- ExtensionRangeOptions* _this = reinterpret_cast< ExtensionRangeOptions* >(object);
- (void)_this;
-}
-void ExtensionRangeOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void ExtensionRangeOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -3276,11 +3235,11 @@ void ExtensionRangeOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
@@ -3330,11 +3289,11 @@ uint8_t* ExtensionRangeOptions::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -3342,7 +3301,7 @@ uint8_t* ExtensionRangeOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -3418,7 +3377,7 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]);
}
@@ -3472,53 +3431,50 @@ FieldDescriptorProto::FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FieldDescriptorProto)
}
FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ extendee_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ extendee_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_extendee()) {
- extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_extendee(),
+ extendee_.Set(from._internal_extendee(),
GetArenaForAllocation());
}
- type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ type_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ type_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_type_name()) {
- type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_name(),
+ type_name_.Set(from._internal_type_name(),
GetArenaForAllocation());
}
- default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_default_value()) {
- default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(),
+ default_value_.Set(from._internal_default_value(),
GetArenaForAllocation());
}
- json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_json_name()) {
- json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(),
+ json_name_.Set(from._internal_json_name(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -3533,25 +3489,25 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
}
inline void FieldDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+extendee_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ extendee_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+type_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ type_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@@ -3563,27 +3519,23 @@ type_ = 1;
FieldDescriptorProto::~FieldDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.FieldDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FieldDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- type_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- default_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ extendee_.Destroy();
+ type_name_.Destroy();
+ default_value_.Destroy();
+ json_name_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void FieldDescriptorProto::ArenaDtor(void* object) {
- FieldDescriptorProto* _this = reinterpret_cast< FieldDescriptorProto* >(object);
- (void)_this;
-}
-void FieldDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FieldDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -3630,22 +3582,22 @@ void FieldDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -3653,11 +3605,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_extendee();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.extendee");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.extendee");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -3700,11 +3652,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
auto str = _internal_mutable_type_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.type_name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.type_name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -3712,11 +3664,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
auto str = _internal_mutable_default_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.default_value");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.default_value");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -3741,11 +3693,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 10:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) {
auto str = _internal_mutable_json_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.json_name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.json_name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -3812,20 +3764,20 @@ uint8_t* FieldDescriptorProto::_InternalSerialize(
// optional int32 number = 3;
if (cached_has_bits & 0x00000040u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target);
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
if (cached_has_bits & 0x00000200u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
4, this->_internal_label(), target);
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
if (cached_has_bits & 0x00000400u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
5, this->_internal_type(), target);
}
@@ -3851,16 +3803,15 @@ uint8_t* FieldDescriptorProto::_InternalSerialize(
// optional .google.protobuf.FieldOptions options = 8;
if (cached_has_bits & 0x00000020u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 8, _Internal::options(this), target, stream);
+ InternalWriteMessage(8, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
// optional int32 oneof_index = 9;
if (cached_has_bits & 0x00000080u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(9, this->_internal_oneof_index(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(9, this->_internal_oneof_index(), target);
}
// optional string json_name = 10;
@@ -3876,11 +3827,11 @@ uint8_t* FieldDescriptorProto::_InternalSerialize(
// 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);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(17, this->_internal_proto3_optional(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -3941,12 +3892,12 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
// optional int32 number = 3;
if (cached_has_bits & 0x00000040u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number());
}
// optional int32 oneof_index = 9;
if (cached_has_bits & 0x00000080u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index());
}
}
@@ -3959,13 +3910,13 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
if (cached_has_bits & 0x00000200u) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_label());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_label());
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
if (cached_has_bits & 0x00000400u) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_type());
}
}
@@ -4055,27 +4006,22 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&extendee_, lhs_arena,
&other->extendee_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&type_name_, lhs_arena,
&other->type_name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&default_value_, lhs_arena,
&other->default_value_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&json_name_, lhs_arena,
&other->json_name_, rhs_arena
);
@@ -4090,7 +4036,7 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]);
}
@@ -4117,21 +4063,18 @@ OneofDescriptorProto::OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.OneofDescriptorProto)
}
OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -4143,32 +4086,28 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
}
inline void OneofDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr;
}
OneofDescriptorProto::~OneofDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.OneofDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void OneofDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void OneofDescriptorProto::ArenaDtor(void* object) {
- OneofDescriptorProto* _this = reinterpret_cast< OneofDescriptorProto* >(object);
- (void)_this;
-}
-void OneofDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void OneofDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -4193,22 +4132,22 @@ void OneofDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.OneofDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.OneofDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -4263,14 +4202,13 @@ uint8_t* OneofDescriptorProto::_InternalSerialize(
// optional .google.protobuf.OneofOptions options = 2;
if (cached_has_bits & 0x00000002u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 2, _Internal::options(this), target, stream);
+ InternalWriteMessage(2, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -4357,7 +4295,6 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -4365,7 +4302,7 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata OneofDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]);
}
@@ -4387,9 +4324,6 @@ EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(::P
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange)
}
EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from)
@@ -4411,21 +4345,17 @@ inline void EnumDescriptorProto_EnumReservedRange::SharedCtor() {
EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto.EnumReservedRange)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void EnumDescriptorProto_EnumReservedRange::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) {
- EnumDescriptorProto_EnumReservedRange* _this = reinterpret_cast< EnumDescriptorProto_EnumReservedRange* >(object);
- (void)_this;
-}
-void EnumDescriptorProto_EnumReservedRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -4446,12 +4376,12 @@ void EnumDescriptorProto_EnumReservedRange::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 start = 1;
case 1:
@@ -4505,17 +4435,17 @@ uint8_t* EnumDescriptorProto_EnumReservedRange::_InternalSerialize(
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -4534,12 +4464,12 @@ size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_start());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start());
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
}
}
@@ -4602,7 +4532,7 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]);
}
@@ -4632,9 +4562,6 @@ EnumDescriptorProto::EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
reserved_range_(arena),
reserved_name_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto)
}
EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
@@ -4644,12 +4571,12 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
reserved_range_(from.reserved_range_),
reserved_name_(from.reserved_name_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -4661,32 +4588,28 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
}
inline void EnumDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr;
}
EnumDescriptorProto::~EnumDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void EnumDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void EnumDescriptorProto::ArenaDtor(void* object) {
- EnumDescriptorProto* _this = reinterpret_cast< EnumDescriptorProto* >(object);
- (void)_this;
-}
-void EnumDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void EnumDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -4714,22 +4637,22 @@ void EnumDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -4774,11 +4697,11 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME
do {
ptr += 1;
auto str = _internal_add_reserved_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.reserved_name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.reserved_name");
#endif // !NDEBUG
- CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr));
} else
@@ -4826,27 +4749,26 @@ uint8_t* EnumDescriptorProto::_InternalSerialize(
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_value_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_value_size()); i < n; i++) {
+ const auto& repfield = this->_internal_value(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_value(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
// optional .google.protobuf.EnumOptions options = 3;
if (cached_has_bits & 0x00000002u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 3, _Internal::options(this), target, stream);
+ InternalWriteMessage(3, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_reserved_range_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_reserved_range_size()); i < n; i++) {
+ const auto& repfield = this->_internal_reserved_range(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(4, this->_internal_reserved_range(i), target, stream);
+ InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated string reserved_name = 5;
@@ -4860,7 +4782,7 @@ uint8_t* EnumDescriptorProto::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -4977,7 +4899,6 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -4985,7 +4906,7 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]);
}
@@ -5015,21 +4936,18 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Aren
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueDescriptorProto)
}
EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -5042,9 +4960,9 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt
}
inline void EnumValueDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@@ -5054,23 +4972,19 @@ name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlready
EnumValueDescriptorProto::~EnumValueDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumValueDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void EnumValueDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void EnumValueDescriptorProto::ArenaDtor(void* object) {
- EnumValueDescriptorProto* _this = reinterpret_cast< EnumValueDescriptorProto* >(object);
- (void)_this;
-}
-void EnumValueDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void EnumValueDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -5096,22 +5010,22 @@ void EnumValueDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumValueDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.EnumValueDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -5176,19 +5090,18 @@ uint8_t* EnumValueDescriptorProto::_InternalSerialize(
// optional int32 number = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target);
}
// optional .google.protobuf.EnumValueOptions options = 3;
if (cached_has_bits & 0x00000002u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 3, _Internal::options(this), target, stream);
+ InternalWriteMessage(3, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -5221,7 +5134,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
// optional int32 number = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number());
}
}
@@ -5284,7 +5197,6 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -5297,7 +5209,7 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]);
}
@@ -5325,9 +5237,6 @@ ServiceDescriptorProto::ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* a
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
method_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceDescriptorProto)
}
ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from)
@@ -5335,12 +5244,12 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
_has_bits_(from._has_bits_),
method_(from.method_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -5352,32 +5261,28 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
}
inline void ServiceDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr;
}
ServiceDescriptorProto::~ServiceDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.ServiceDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ServiceDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void ServiceDescriptorProto::ArenaDtor(void* object) {
- ServiceDescriptorProto* _this = reinterpret_cast< ServiceDescriptorProto* >(object);
- (void)_this;
-}
-void ServiceDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void ServiceDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -5403,22 +5308,22 @@ void ServiceDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.ServiceDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.ServiceDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -5485,23 +5390,22 @@ uint8_t* ServiceDescriptorProto::_InternalSerialize(
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_method_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_method_size()); i < n; i++) {
+ const auto& repfield = this->_internal_method(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_method(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
// optional .google.protobuf.ServiceOptions options = 3;
if (cached_has_bits & 0x00000002u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 3, _Internal::options(this), target, stream);
+ InternalWriteMessage(3, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -5599,7 +5503,6 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
swap(_has_bits_[0], other->_has_bits_[0]);
method_.InternalSwap(&other->method_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -5607,7 +5510,7 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ServiceDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]);
}
@@ -5646,37 +5549,34 @@ MethodDescriptorProto::MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* are
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.MethodDescriptorProto)
}
MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ input_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ input_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_input_type()) {
- input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_input_type(),
+ input_type_.Set(from._internal_input_type(),
GetArenaForAllocation());
}
- output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ output_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ output_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_output_type()) {
- output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_output_type(),
+ output_type_.Set(from._internal_output_type(),
GetArenaForAllocation());
}
if (from._internal_has_options()) {
@@ -5691,17 +5591,17 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
}
inline void MethodDescriptorProto::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+input_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ input_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+output_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ output_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@@ -5711,25 +5611,21 @@ output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString
MethodDescriptorProto::~MethodDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.MethodDescriptorProto)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void MethodDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- output_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ input_type_.Destroy();
+ output_type_.Destroy();
if (this != internal_default_instance()) delete options_;
}
-void MethodDescriptorProto::ArenaDtor(void* object) {
- MethodDescriptorProto* _this = reinterpret_cast< MethodDescriptorProto* >(object);
- (void)_this;
-}
-void MethodDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void MethodDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -5763,22 +5659,22 @@ void MethodDescriptorProto::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -5786,11 +5682,11 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_input_type();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.input_type");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.input_type");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -5798,11 +5694,11 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
auto str = _internal_mutable_output_type();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.output_type");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.output_type");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -5895,26 +5791,25 @@ uint8_t* MethodDescriptorProto::_InternalSerialize(
// optional .google.protobuf.MethodOptions options = 4;
if (cached_has_bits & 0x00000008u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 4, _Internal::options(this), target, stream);
+ InternalWriteMessage(4, _Internal::options(this),
+ _Internal::options(this).GetCachedSize(), target, stream);
}
// optional bool client_streaming = 5 [default = false];
if (cached_has_bits & 0x00000010u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_client_streaming(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_client_streaming(), target);
}
// optional bool server_streaming = 6 [default = false];
if (cached_has_bits & 0x00000020u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(6, this->_internal_server_streaming(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(6, this->_internal_server_streaming(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -6038,17 +5933,14 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&input_type_, lhs_arena,
&other->input_type_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&output_type_, lhs_arena,
&other->output_type_, rhs_arena
);
@@ -6061,7 +5953,7 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]);
}
@@ -6139,9 +6031,6 @@ FileOptions::FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FileOptions)
}
FileOptions::FileOptions(const FileOptions& from)
@@ -6150,84 +6039,84 @@ FileOptions::FileOptions(const FileOptions& from)
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(internal_default_instance(), from._extensions_);
- java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ java_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ java_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_java_package()) {
- java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_package(),
+ java_package_.Set(from._internal_java_package(),
GetArenaForAllocation());
}
- java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ java_outer_classname_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ java_outer_classname_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_java_outer_classname()) {
- java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_outer_classname(),
+ java_outer_classname_.Set(from._internal_java_outer_classname(),
GetArenaForAllocation());
}
- go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ go_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ go_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_go_package()) {
- go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_go_package(),
+ go_package_.Set(from._internal_go_package(),
GetArenaForAllocation());
}
- objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ objc_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ objc_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_objc_class_prefix()) {
- objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_objc_class_prefix(),
+ objc_class_prefix_.Set(from._internal_objc_class_prefix(),
GetArenaForAllocation());
}
- csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ csharp_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ csharp_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_csharp_namespace()) {
- csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_csharp_namespace(),
+ csharp_namespace_.Set(from._internal_csharp_namespace(),
GetArenaForAllocation());
}
- swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ swift_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ swift_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_swift_prefix()) {
- swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_swift_prefix(),
+ swift_prefix_.Set(from._internal_swift_prefix(),
GetArenaForAllocation());
}
- php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ php_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ php_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_php_class_prefix()) {
- php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_class_prefix(),
+ php_class_prefix_.Set(from._internal_php_class_prefix(),
GetArenaForAllocation());
}
- php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ php_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ php_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_php_namespace()) {
- php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_namespace(),
+ php_namespace_.Set(from._internal_php_namespace(),
GetArenaForAllocation());
}
- php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ php_metadata_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ php_metadata_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_php_metadata_namespace()) {
- php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_metadata_namespace(),
+ php_metadata_namespace_.Set(from._internal_php_metadata_namespace(),
GetArenaForAllocation());
}
- ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ ruby_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ ruby_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_ruby_package()) {
- ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_ruby_package(),
+ ruby_package_.Set(from._internal_ruby_package(),
GetArenaForAllocation());
}
::memcpy(&java_multiple_files_, &from.java_multiple_files_,
@@ -6237,45 +6126,45 @@ FileOptions::FileOptions(const FileOptions& from)
}
inline void FileOptions::SharedCtor() {
-java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+java_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ java_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+java_outer_classname_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ java_outer_classname_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+go_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ go_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+objc_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ objc_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+csharp_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ csharp_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+swift_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ swift_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+php_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ php_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+php_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ php_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+php_metadata_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ php_metadata_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ruby_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ ruby_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&java_multiple_files_) - reinterpret_cast<char*>(this)),
@@ -6287,31 +6176,27 @@ cc_enable_arenas_ = true;
FileOptions::~FileOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.FileOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FileOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == 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());
- objc_class_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- csharp_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- swift_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- php_class_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- php_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- php_metadata_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- ruby_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ java_package_.Destroy();
+ java_outer_classname_.Destroy();
+ go_package_.Destroy();
+ objc_class_prefix_.Destroy();
+ csharp_namespace_.Destroy();
+ swift_prefix_.Destroy();
+ php_class_prefix_.Destroy();
+ php_namespace_.Destroy();
+ php_metadata_namespace_.Destroy();
+ ruby_package_.Destroy();
}
-void FileOptions::ArenaDtor(void* object) {
- FileOptions* _this = reinterpret_cast< FileOptions* >(object);
- (void)_this;
-}
-void FileOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FileOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -6375,22 +6260,22 @@ void FileOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FileOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string java_package = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_java_package();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.java_package");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.java_package");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6398,11 +6283,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
auto str = _internal_mutable_java_outer_classname();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.java_outer_classname");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.java_outer_classname");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6432,11 +6317,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 11:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) {
auto str = _internal_mutable_go_package();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.go_package");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.go_package");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6507,11 +6392,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 36:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
auto str = _internal_mutable_objc_class_prefix();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.objc_class_prefix");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.objc_class_prefix");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6519,11 +6404,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 37:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
auto str = _internal_mutable_csharp_namespace();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.csharp_namespace");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.csharp_namespace");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6531,11 +6416,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 39:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
auto str = _internal_mutable_swift_prefix();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.swift_prefix");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.swift_prefix");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6543,11 +6428,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 40:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
auto str = _internal_mutable_php_class_prefix();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.php_class_prefix");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_class_prefix");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6555,11 +6440,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 41:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 74)) {
auto str = _internal_mutable_php_namespace();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.php_namespace");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_namespace");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6576,11 +6461,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 44:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 98)) {
auto str = _internal_mutable_php_metadata_namespace();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.php_metadata_namespace");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_metadata_namespace");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6588,11 +6473,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
case 45:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 106)) {
auto str = _internal_mutable_ruby_package();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.ruby_package");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.ruby_package");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -6668,14 +6553,14 @@ uint8_t* FileOptions::_InternalSerialize(
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (cached_has_bits & 0x00040000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
9, this->_internal_optimize_for(), target);
}
// optional bool java_multiple_files = 10 [default = false];
if (cached_has_bits & 0x00000400u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_java_multiple_files(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(10, this->_internal_java_multiple_files(), target);
}
// optional string go_package = 11;
@@ -6691,43 +6576,43 @@ uint8_t* FileOptions::_InternalSerialize(
// optional bool cc_generic_services = 16 [default = false];
if (cached_has_bits & 0x00002000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(16, this->_internal_cc_generic_services(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(16, this->_internal_cc_generic_services(), target);
}
// optional bool java_generic_services = 17 [default = false];
if (cached_has_bits & 0x00004000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(17, this->_internal_java_generic_services(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(17, this->_internal_java_generic_services(), target);
}
// optional bool py_generic_services = 18 [default = false];
if (cached_has_bits & 0x00008000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(18, this->_internal_py_generic_services(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(18, this->_internal_py_generic_services(), target);
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
if (cached_has_bits & 0x00000800u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(20, this->_internal_java_generate_equals_and_hash(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(20, this->_internal_java_generate_equals_and_hash(), target);
}
// optional bool deprecated = 23 [default = false];
if (cached_has_bits & 0x00020000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(23, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(23, this->_internal_deprecated(), target);
}
// optional bool java_string_check_utf8 = 27 [default = false];
if (cached_has_bits & 0x00001000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(27, this->_internal_java_string_check_utf8(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(27, this->_internal_java_string_check_utf8(), target);
}
// 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);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(31, this->_internal_cc_enable_arenas(), target);
}
// optional string objc_class_prefix = 36;
@@ -6783,7 +6668,7 @@ uint8_t* FileOptions::_InternalSerialize(
// optional bool php_generic_services = 42 [default = false];
if (cached_has_bits & 0x00010000u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(42, this->_internal_php_generic_services(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(42, this->_internal_php_generic_services(), target);
}
// optional string php_metadata_namespace = 44;
@@ -6807,11 +6692,11 @@ uint8_t* FileOptions::_InternalSerialize(
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -6819,7 +6704,7 @@ uint8_t* FileOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -6962,7 +6847,7 @@ size_t FileOptions::ByteSizeLong() const {
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (cached_has_bits & 0x00040000u) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_optimize_for());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_optimize_for());
}
// optional bool cc_enable_arenas = 31 [default = true];
@@ -7093,52 +6978,42 @@ void FileOptions::InternalSwap(FileOptions* other) {
swap(_has_bits_[0], other->_has_bits_[0]);
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&java_package_, lhs_arena,
&other->java_package_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&java_outer_classname_, lhs_arena,
&other->java_outer_classname_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&go_package_, lhs_arena,
&other->go_package_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&objc_class_prefix_, lhs_arena,
&other->objc_class_prefix_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&csharp_namespace_, lhs_arena,
&other->csharp_namespace_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&swift_prefix_, lhs_arena,
&other->swift_prefix_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&php_class_prefix_, lhs_arena,
&other->php_class_prefix_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&php_namespace_, lhs_arena,
&other->php_namespace_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&php_metadata_namespace_, lhs_arena,
&other->php_metadata_namespace_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&ruby_package_, lhs_arena,
&other->ruby_package_, rhs_arena
);
@@ -7153,7 +7028,7 @@ void FileOptions::InternalSwap(FileOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]);
}
@@ -7183,9 +7058,6 @@ MessageOptions::MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.MessageOptions)
}
MessageOptions::MessageOptions(const MessageOptions& from)
@@ -7209,21 +7081,17 @@ inline void MessageOptions::SharedCtor() {
MessageOptions::~MessageOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.MessageOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void MessageOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void MessageOptions::ArenaDtor(void* object) {
- MessageOptions* _this = reinterpret_cast< MessageOptions* >(object);
- (void)_this;
-}
-void MessageOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void MessageOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -7243,12 +7111,12 @@ void MessageOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* MessageOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool message_set_wire_format = 1 [default = false];
case 1:
@@ -7338,33 +7206,33 @@ uint8_t* MessageOptions::_InternalSerialize(
// optional bool message_set_wire_format = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(1, this->_internal_message_set_wire_format(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_message_set_wire_format(), target);
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_no_standard_descriptor_accessor(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_no_standard_descriptor_accessor(), target);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
}
// optional bool map_entry = 7;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(7, this->_internal_map_entry(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(7, this->_internal_map_entry(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -7372,7 +7240,7 @@ uint8_t* MessageOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -7494,7 +7362,7 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]);
}
@@ -7508,19 +7376,22 @@ class FieldOptions::_Internal {
(*has_bits)[0] |= 1u;
}
static void set_has_packed(HasBits* has_bits) {
- (*has_bits)[0] |= 2u;
+ (*has_bits)[0] |= 4u;
}
static void set_has_jstype(HasBits* has_bits) {
- (*has_bits)[0] |= 32u;
+ (*has_bits)[0] |= 2u;
}
static void set_has_lazy(HasBits* has_bits) {
- (*has_bits)[0] |= 4u;
+ (*has_bits)[0] |= 8u;
+ }
+ static void set_has_unverified_lazy(HasBits* has_bits) {
+ (*has_bits)[0] |= 16u;
}
static void set_has_deprecated(HasBits* has_bits) {
- (*has_bits)[0] |= 8u;
+ (*has_bits)[0] |= 32u;
}
static void set_has_weak(HasBits* has_bits) {
- (*has_bits)[0] |= 16u;
+ (*has_bits)[0] |= 64u;
}
};
@@ -7530,9 +7401,6 @@ FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FieldOptions)
}
FieldOptions::FieldOptions(const FieldOptions& from)
@@ -7542,35 +7410,31 @@ FieldOptions::FieldOptions(const FieldOptions& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(internal_default_instance(), from._extensions_);
::memcpy(&ctype_, &from.ctype_,
- static_cast<size_t>(reinterpret_cast<char*>(&jstype_) -
- reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_));
+ static_cast<size_t>(reinterpret_cast<char*>(&weak_) -
+ reinterpret_cast<char*>(&ctype_)) + sizeof(weak_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions)
}
inline void FieldOptions::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&ctype_) - reinterpret_cast<char*>(this)),
- 0, static_cast<size_t>(reinterpret_cast<char*>(&jstype_) -
- reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_));
+ 0, static_cast<size_t>(reinterpret_cast<char*>(&weak_) -
+ reinterpret_cast<char*>(&ctype_)) + sizeof(weak_));
}
FieldOptions::~FieldOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.FieldOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FieldOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void FieldOptions::ArenaDtor(void* object) {
- FieldOptions* _this = reinterpret_cast< FieldOptions* >(object);
- (void)_this;
-}
-void FieldOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FieldOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -7584,21 +7448,21 @@ void FieldOptions::Clear() {
_extensions_.Clear();
uninterpreted_option_.Clear();
cached_has_bits = _has_bits_[0];
- if (cached_has_bits & 0x0000003fu) {
+ if (cached_has_bits & 0x0000007fu) {
::memset(&ctype_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&jstype_) -
- reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_));
+ reinterpret_cast<char*>(&weak_) -
+ reinterpret_cast<char*>(&ctype_)) + sizeof(weak_));
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FieldOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
case 1:
@@ -7662,6 +7526,15 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I
} else
goto handle_unusual;
continue;
+ // optional bool unverified_lazy = 15 [default = false];
+ case 15:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 120)) {
+ _Internal::set_has_unverified_lazy(&has_bits);
+ unverified_lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ CHK_(ptr);
+ } else
+ goto handle_unusual;
+ continue;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
@@ -7714,47 +7587,53 @@ uint8_t* FieldOptions::_InternalSerialize(
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
1, this->_internal_ctype(), target);
}
// optional bool packed = 2;
- if (cached_has_bits & 0x00000002u) {
+ if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_packed(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_packed(), target);
}
// optional bool deprecated = 3 [default = false];
- if (cached_has_bits & 0x00000008u) {
+ if (cached_has_bits & 0x00000020u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
}
// optional bool lazy = 5 [default = false];
- if (cached_has_bits & 0x00000004u) {
+ if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_lazy(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_lazy(), target);
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
- if (cached_has_bits & 0x00000020u) {
+ if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
6, this->_internal_jstype(), target);
}
// optional bool weak = 10 [default = false];
+ if (cached_has_bits & 0x00000040u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(10, this->_internal_weak(), target);
+ }
+
+ // optional bool unverified_lazy = 15 [default = false];
if (cached_has_bits & 0x00000010u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_weak(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(15, this->_internal_unverified_lazy(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -7762,7 +7641,7 @@ uint8_t* FieldOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -7787,37 +7666,42 @@ size_t FieldOptions::ByteSizeLong() const {
}
cached_has_bits = _has_bits_[0];
- if (cached_has_bits & 0x0000003fu) {
+ if (cached_has_bits & 0x0000007fu) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_ctype());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_ctype());
}
- // optional bool packed = 2;
+ // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
if (cached_has_bits & 0x00000002u) {
- total_size += 1 + 1;
+ total_size += 1 +
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_jstype());
}
- // optional bool lazy = 5 [default = false];
+ // optional bool packed = 2;
if (cached_has_bits & 0x00000004u) {
total_size += 1 + 1;
}
- // optional bool deprecated = 3 [default = false];
+ // optional bool lazy = 5 [default = false];
if (cached_has_bits & 0x00000008u) {
total_size += 1 + 1;
}
- // optional bool weak = 10 [default = false];
+ // optional bool unverified_lazy = 15 [default = false];
if (cached_has_bits & 0x00000010u) {
total_size += 1 + 1;
}
- // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
+ // optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000020u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_jstype());
+ total_size += 1 + 1;
+ }
+
+ // optional bool weak = 10 [default = false];
+ if (cached_has_bits & 0x00000040u) {
+ total_size += 1 + 1;
}
}
@@ -7845,24 +7729,27 @@ void FieldOptions::MergeFrom(const FieldOptions& from) {
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
cached_has_bits = from._has_bits_[0];
- if (cached_has_bits & 0x0000003fu) {
+ if (cached_has_bits & 0x0000007fu) {
if (cached_has_bits & 0x00000001u) {
ctype_ = from.ctype_;
}
if (cached_has_bits & 0x00000002u) {
- packed_ = from.packed_;
+ jstype_ = from.jstype_;
}
if (cached_has_bits & 0x00000004u) {
- lazy_ = from.lazy_;
+ packed_ = from.packed_;
}
if (cached_has_bits & 0x00000008u) {
- deprecated_ = from.deprecated_;
+ lazy_ = from.lazy_;
}
if (cached_has_bits & 0x00000010u) {
- weak_ = from.weak_;
+ unverified_lazy_ = from.unverified_lazy_;
}
if (cached_has_bits & 0x00000020u) {
- jstype_ = from.jstype_;
+ deprecated_ = from.deprecated_;
+ }
+ if (cached_has_bits & 0x00000040u) {
+ weak_ = from.weak_;
}
_has_bits_[0] |= cached_has_bits;
}
@@ -7894,15 +7781,15 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
swap(_has_bits_[0], other->_has_bits_[0]);
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(FieldOptions, jstype_)
- + sizeof(FieldOptions::jstype_)
+ PROTOBUF_FIELD_OFFSET(FieldOptions, weak_)
+ + sizeof(FieldOptions::weak_)
- PROTOBUF_FIELD_OFFSET(FieldOptions, ctype_)>(
reinterpret_cast<char*>(&ctype_),
reinterpret_cast<char*>(&other->ctype_));
}
::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]);
}
@@ -7919,9 +7806,6 @@ OneofOptions::OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.OneofOptions)
}
OneofOptions::OneofOptions(const OneofOptions& from)
@@ -7937,21 +7821,17 @@ inline void OneofOptions::SharedCtor() {
OneofOptions::~OneofOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.OneofOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void OneofOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void OneofOptions::ArenaDtor(void* object) {
- OneofOptions* _this = reinterpret_cast< OneofOptions* >(object);
- (void)_this;
-}
-void OneofOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void OneofOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -7967,11 +7847,11 @@ void OneofOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* OneofOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* OneofOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
@@ -8021,11 +7901,11 @@ uint8_t* OneofOptions::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -8033,7 +7913,7 @@ uint8_t* OneofOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -8109,7 +7989,7 @@ void OneofOptions::InternalSwap(OneofOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]);
}
@@ -8133,9 +8013,6 @@ EnumOptions::EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumOptions)
}
EnumOptions::EnumOptions(const EnumOptions& from)
@@ -8159,21 +8036,17 @@ inline void EnumOptions::SharedCtor() {
EnumOptions::~EnumOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void EnumOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void EnumOptions::ArenaDtor(void* object) {
- EnumOptions* _this = reinterpret_cast< EnumOptions* >(object);
- (void)_this;
-}
-void EnumOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void EnumOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -8193,12 +8066,12 @@ void EnumOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* EnumOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool allow_alias = 2;
case 2:
@@ -8270,21 +8143,21 @@ uint8_t* EnumOptions::_InternalSerialize(
// optional bool allow_alias = 2;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_allow_alias(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_allow_alias(), target);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -8292,7 +8165,7 @@ uint8_t* EnumOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -8398,7 +8271,7 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]);
}
@@ -8419,9 +8292,6 @@ EnumValueOptions::EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueOptions)
}
EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
@@ -8440,21 +8310,17 @@ deprecated_ = false;
EnumValueOptions::~EnumValueOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumValueOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void EnumValueOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void EnumValueOptions::ArenaDtor(void* object) {
- EnumValueOptions* _this = reinterpret_cast< EnumValueOptions* >(object);
- (void)_this;
-}
-void EnumValueOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void EnumValueOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -8472,12 +8338,12 @@ void EnumValueOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* EnumValueOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool deprecated = 1 [default = false];
case 1:
@@ -8540,15 +8406,15 @@ uint8_t* EnumValueOptions::_InternalSerialize(
// optional bool deprecated = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(1, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -8556,7 +8422,7 @@ uint8_t* EnumValueOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -8643,7 +8509,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumValueOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]);
}
@@ -8664,9 +8530,6 @@ ServiceOptions::ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceOptions)
}
ServiceOptions::ServiceOptions(const ServiceOptions& from)
@@ -8685,21 +8548,17 @@ deprecated_ = false;
ServiceOptions::~ServiceOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.ServiceOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ServiceOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void ServiceOptions::ArenaDtor(void* object) {
- ServiceOptions* _this = reinterpret_cast< ServiceOptions* >(object);
- (void)_this;
-}
-void ServiceOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void ServiceOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -8717,12 +8576,12 @@ void ServiceOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* ServiceOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool deprecated = 33 [default = false];
case 33:
@@ -8785,15 +8644,15 @@ uint8_t* ServiceOptions::_InternalSerialize(
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -8801,7 +8660,7 @@ uint8_t* ServiceOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -8888,7 +8747,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ServiceOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]);
}
@@ -8912,9 +8771,6 @@ MethodOptions::MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
_extensions_(arena),
uninterpreted_option_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.MethodOptions)
}
MethodOptions::MethodOptions(const MethodOptions& from)
@@ -8938,21 +8794,17 @@ inline void MethodOptions::SharedCtor() {
MethodOptions::~MethodOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.MethodOptions)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void MethodOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void MethodOptions::ArenaDtor(void* object) {
- MethodOptions* _this = reinterpret_cast< MethodOptions* >(object);
- (void)_this;
-}
-void MethodOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void MethodOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -8975,12 +8827,12 @@ void MethodOptions::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* MethodOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool deprecated = 33 [default = false];
case 33:
@@ -9056,22 +8908,22 @@ uint8_t* MethodOptions::_InternalSerialize(
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target);
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
34, this->_internal_idempotency_level(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) {
+ const auto& repfield = this->_internal_uninterpreted_option(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream);
+ InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream);
}
// Extension range [1000, 536870912)
@@ -9079,7 +8931,7 @@ uint8_t* MethodOptions::_InternalSerialize(
internal_default_instance(), 1000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -9113,7 +8965,7 @@ size_t MethodOptions::ByteSizeLong() const {
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
if (cached_has_bits & 0x00000002u) {
total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_idempotency_level());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_idempotency_level());
}
}
@@ -9186,7 +9038,7 @@ void MethodOptions::InternalSwap(MethodOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]);
}
@@ -9211,21 +9063,18 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption.NamePart)
}
UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_part_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_part_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name_part()) {
- name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name_part(),
+ name_part_.Set(from._internal_name_part(),
GetArenaForAllocation());
}
is_extension_ = from.is_extension_;
@@ -9233,31 +9082,27 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp
}
inline void UninterpretedOption_NamePart::SharedCtor() {
-name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_part_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_part_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
is_extension_ = false;
}
UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
// @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption.NamePart)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void UninterpretedOption_NamePart::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_part_.Destroy();
}
-void UninterpretedOption_NamePart::ArenaDtor(void* object) {
- UninterpretedOption_NamePart* _this = reinterpret_cast< UninterpretedOption_NamePart* >(object);
- (void)_this;
-}
-void UninterpretedOption_NamePart::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void UninterpretedOption_NamePart::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -9277,22 +9122,22 @@ void UninterpretedOption_NamePart::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// required string name_part = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name_part();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.UninterpretedOption.NamePart.name_part");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.NamePart.name_part");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -9349,11 +9194,11 @@ uint8_t* UninterpretedOption_NamePart::_InternalSerialize(
// required bool is_extension = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_is_extension(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_is_extension(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -9452,7 +9297,6 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_part_, lhs_arena,
&other->name_part_, rhs_arena
);
@@ -9460,7 +9304,7 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
}
::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption_NamePart::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]);
}
@@ -9495,9 +9339,6 @@ UninterpretedOption::UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
name_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption)
}
UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
@@ -9505,28 +9346,28 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
_has_bits_(from._has_bits_),
name_(from.name_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ identifier_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ identifier_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_identifier_value()) {
- identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_identifier_value(),
+ identifier_value_.Set(from._internal_identifier_value(),
GetArenaForAllocation());
}
- string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ string_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ string_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_string_value()) {
- string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_string_value(),
+ string_value_.Set(from._internal_string_value(),
GetArenaForAllocation());
}
- aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ aggregate_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ aggregate_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_aggregate_value()) {
- aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_aggregate_value(),
+ aggregate_value_.Set(from._internal_aggregate_value(),
GetArenaForAllocation());
}
::memcpy(&positive_int_value_, &from.positive_int_value_,
@@ -9536,17 +9377,17 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
}
inline void UninterpretedOption::SharedCtor() {
-identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+identifier_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ identifier_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+string_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ string_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+aggregate_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ aggregate_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&positive_int_value_) - reinterpret_cast<char*>(this)),
@@ -9556,24 +9397,20 @@ aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptySt
UninterpretedOption::~UninterpretedOption() {
// @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void UninterpretedOption::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == 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());
+ identifier_value_.Destroy();
+ string_value_.Destroy();
+ aggregate_value_.Destroy();
}
-void UninterpretedOption::ArenaDtor(void* object) {
- UninterpretedOption* _this = reinterpret_cast< UninterpretedOption* >(object);
- (void)_this;
-}
-void UninterpretedOption::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void UninterpretedOption::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -9606,12 +9443,12 @@ void UninterpretedOption::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* UninterpretedOption::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
case 2:
@@ -9630,11 +9467,11 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
auto str = _internal_mutable_identifier_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.UninterpretedOption.identifier_value");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.identifier_value");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -9669,7 +9506,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
auto str = _internal_mutable_string_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
} else
goto handle_unusual;
@@ -9678,11 +9515,11 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
auto str = _internal_mutable_aggregate_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.UninterpretedOption.aggregate_value");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.aggregate_value");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -9717,11 +9554,11 @@ uint8_t* UninterpretedOption::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_name_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_name_size()); i < n; i++) {
+ const auto& repfield = this->_internal_name(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_name(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
cached_has_bits = _has_bits_[0];
@@ -9738,19 +9575,19 @@ uint8_t* UninterpretedOption::_InternalSerialize(
// optional uint64 positive_int_value = 4;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(4, this->_internal_positive_int_value(), target);
+ target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_positive_int_value(), target);
}
// optional int64 negative_int_value = 5;
if (cached_has_bits & 0x00000010u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(5, this->_internal_negative_int_value(), target);
+ target = ::_pbi::WireFormatLite::WriteInt64ToArray(5, this->_internal_negative_int_value(), target);
}
// optional double double_value = 6;
if (cached_has_bits & 0x00000020u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(6, this->_internal_double_value(), target);
+ target = ::_pbi::WireFormatLite::WriteDoubleToArray(6, this->_internal_double_value(), target);
}
// optional bytes string_value = 7;
@@ -9770,7 +9607,7 @@ uint8_t* UninterpretedOption::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -9817,12 +9654,12 @@ size_t UninterpretedOption::ByteSizeLong() const {
// optional uint64 positive_int_value = 4;
if (cached_has_bits & 0x00000008u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_positive_int_value());
+ total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_positive_int_value());
}
// optional int64 negative_int_value = 5;
if (cached_has_bits & 0x00000010u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_negative_int_value());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_negative_int_value());
}
// optional double double_value = 6;
@@ -9900,17 +9737,14 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
swap(_has_bits_[0], other->_has_bits_[0]);
name_.InternalSwap(&other->name_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&identifier_value_, lhs_arena,
&other->identifier_value_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&string_value_, lhs_arena,
&other->string_value_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&aggregate_value_, lhs_arena,
&other->aggregate_value_, rhs_arena
);
@@ -9923,7 +9757,7 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]);
}
@@ -9948,9 +9782,6 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena*
span_(arena),
leading_detached_comments_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo.Location)
}
SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from)
@@ -9960,55 +9791,51 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location&
span_(from.span_),
leading_detached_comments_(from.leading_detached_comments_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ leading_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ leading_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_leading_comments()) {
- leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_leading_comments(),
+ leading_comments_.Set(from._internal_leading_comments(),
GetArenaForAllocation());
}
- trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ trailing_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ trailing_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_trailing_comments()) {
- trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_trailing_comments(),
+ trailing_comments_.Set(from._internal_trailing_comments(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)
}
inline void SourceCodeInfo_Location::SharedCtor() {
-leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+leading_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ leading_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+trailing_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ trailing_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
SourceCodeInfo_Location::~SourceCodeInfo_Location() {
// @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo.Location)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void SourceCodeInfo_Location::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- trailing_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ leading_comments_.Destroy();
+ trailing_comments_.Destroy();
}
-void SourceCodeInfo_Location::ArenaDtor(void* object) {
- SourceCodeInfo_Location* _this = reinterpret_cast< SourceCodeInfo_Location* >(object);
- (void)_this;
-}
-void SourceCodeInfo_Location::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void SourceCodeInfo_Location::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -10035,12 +9862,12 @@ void SourceCodeInfo_Location::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated int32 path = 1 [packed = true];
case 1:
@@ -10068,11 +9895,11 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
auto str = _internal_mutable_leading_comments();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_comments");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_comments");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -10080,11 +9907,11 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
auto str = _internal_mutable_trailing_comments();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.trailing_comments");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.trailing_comments");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -10095,11 +9922,11 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_
do {
ptr += 1;
auto str = _internal_add_leading_detached_comments();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
#endif // !NDEBUG
- CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
} else
@@ -10185,7 +10012,7 @@ uint8_t* SourceCodeInfo_Location::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -10202,14 +10029,13 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
// repeated int32 path = 1 [packed = true];
{
- size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
+ size_t data_size = ::_pbi::WireFormatLite::
Int32Size(this->path_);
if (data_size > 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
- static_cast<arc_i32>(data_size));
+ ::_pbi::WireFormatLite::Int32Size(static_cast<arc_i32>(data_size));
}
- int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size);
+ int cached_size = ::_pbi::ToCachedSize(data_size);
_path_cached_byte_size_.store(cached_size,
std::memory_order_relaxed);
total_size += data_size;
@@ -10217,14 +10043,13 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
// repeated int32 span = 2 [packed = true];
{
- size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
+ size_t data_size = ::_pbi::WireFormatLite::
Int32Size(this->span_);
if (data_size > 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
- static_cast<arc_i32>(data_size));
+ ::_pbi::WireFormatLite::Int32Size(static_cast<arc_i32>(data_size));
}
- int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size);
+ int cached_size = ::_pbi::ToCachedSize(data_size);
_span_cached_byte_size_.store(cached_size,
std::memory_order_relaxed);
total_size += data_size;
@@ -10313,19 +10138,17 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
span_.InternalSwap(&other->span_);
leading_detached_comments_.InternalSwap(&other->leading_detached_comments_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&leading_comments_, lhs_arena,
&other->leading_comments_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&trailing_comments_, lhs_arena,
&other->trailing_comments_, rhs_arena
);
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]);
}
@@ -10341,9 +10164,6 @@ SourceCodeInfo::SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
location_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo)
}
SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)
@@ -10358,21 +10178,17 @@ inline void SourceCodeInfo::SharedCtor() {
SourceCodeInfo::~SourceCodeInfo() {
// @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void SourceCodeInfo::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void SourceCodeInfo::ArenaDtor(void* object) {
- SourceCodeInfo* _this = reinterpret_cast< SourceCodeInfo* >(object);
- (void)_this;
-}
-void SourceCodeInfo::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void SourceCodeInfo::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -10387,11 +10203,11 @@ void SourceCodeInfo::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* SourceCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* SourceCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
case 1:
@@ -10436,15 +10252,15 @@ uint8_t* SourceCodeInfo::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_location_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_location_size()); i < n; i++) {
+ const auto& repfield = this->_internal_location(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(1, this->_internal_location(i), target, stream);
+ InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -10510,7 +10326,7 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]);
}
@@ -10536,9 +10352,6 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
path_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from)
@@ -10546,12 +10359,12 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn
_has_bits_(from._has_bits_),
path_(from.path_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ source_file_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ source_file_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_source_file()) {
- source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_file(),
+ source_file_.Set(from._internal_source_file(),
GetArenaForAllocation());
}
::memcpy(&begin_, &from.begin_,
@@ -10561,9 +10374,9 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn
}
inline void GeneratedCodeInfo_Annotation::SharedCtor() {
-source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+source_file_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ source_file_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&begin_) - reinterpret_cast<char*>(this)),
@@ -10573,22 +10386,18 @@ source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString
GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
// @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo.Annotation)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void GeneratedCodeInfo_Annotation::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- source_file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ source_file_.Destroy();
}
-void GeneratedCodeInfo_Annotation::ArenaDtor(void* object) {
- GeneratedCodeInfo_Annotation* _this = reinterpret_cast< GeneratedCodeInfo_Annotation* >(object);
- (void)_this;
-}
-void GeneratedCodeInfo_Annotation::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -10613,12 +10422,12 @@ void GeneratedCodeInfo_Annotation::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated int32 path = 1 [packed = true];
case 1:
@@ -10635,11 +10444,11 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_source_file();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.GeneratedCodeInfo.Annotation.source_file");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.GeneratedCodeInfo.Annotation.source_file");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -10714,17 +10523,17 @@ uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize(
// optional int32 begin = 3;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_begin(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_begin(), target);
}
// optional int32 end = 4;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_end(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(4, this->_internal_end(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -10741,14 +10550,13 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
// repeated int32 path = 1 [packed = true];
{
- size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
+ size_t data_size = ::_pbi::WireFormatLite::
Int32Size(this->path_);
if (data_size > 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
- static_cast<arc_i32>(data_size));
+ ::_pbi::WireFormatLite::Int32Size(static_cast<arc_i32>(data_size));
}
- int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size);
+ int cached_size = ::_pbi::ToCachedSize(data_size);
_path_cached_byte_size_.store(cached_size,
std::memory_order_relaxed);
total_size += data_size;
@@ -10765,12 +10573,12 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
// optional int32 begin = 3;
if (cached_has_bits & 0x00000002u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_begin());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_begin());
}
// optional int32 end = 4;
if (cached_has_bits & 0x00000004u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
}
}
@@ -10832,7 +10640,6 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
swap(_has_bits_[0], other->_has_bits_[0]);
path_.InternalSwap(&other->path_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&source_file_, lhs_arena,
&other->source_file_, rhs_arena
);
@@ -10845,7 +10652,7 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
}
::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]);
}
@@ -10861,9 +10668,6 @@ GeneratedCodeInfo::GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
annotation_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo)
}
GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from)
@@ -10878,21 +10682,17 @@ inline void GeneratedCodeInfo::SharedCtor() {
GeneratedCodeInfo::~GeneratedCodeInfo() {
// @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void GeneratedCodeInfo::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void GeneratedCodeInfo::ArenaDtor(void* object) {
- GeneratedCodeInfo* _this = reinterpret_cast< GeneratedCodeInfo* >(object);
- (void)_this;
-}
-void GeneratedCodeInfo::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void GeneratedCodeInfo::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -10907,11 +10707,11 @@ void GeneratedCodeInfo::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
case 1:
@@ -10956,15 +10756,15 @@ uint8_t* GeneratedCodeInfo::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_annotation_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_annotation_size()); i < n; i++) {
+ const auto& repfield = this->_internal_annotation(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(1, this->_internal_annotation(i), target, stream);
+ InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -11030,7 +10830,7 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]);
}
@@ -11038,85 +10838,112 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MessageOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MessageOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MessageOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::MessageOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::OneofOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumValueOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ServiceOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodOptions*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::MethodOptions >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h
index ecf3a8af07..cf564479bb 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -43,14 +42,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[27]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto;
@@ -334,7 +325,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
public:
inline FileDescriptorSet() : FileDescriptorSet(nullptr) {}
~FileDescriptorSet() override;
- explicit constexpr FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FileDescriptorSet(const FileDescriptorSet& from);
FileDescriptorSet(FileDescriptorSet&& from) noexcept
@@ -443,9 +434,6 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
protected:
explicit FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -496,7 +484,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
public:
inline FileDescriptorProto() : FileDescriptorProto(nullptr) {}
~FileDescriptorProto() override;
- explicit constexpr FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FileDescriptorProto(const FileDescriptorProto& from);
FileDescriptorProto(FileDescriptorProto&& from) noexcept
@@ -605,9 +593,6 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
protected:
explicit FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -893,7 +878,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
public:
inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {}
~DescriptorProto_ExtensionRange() override;
- explicit constexpr DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from);
DescriptorProto_ExtensionRange(DescriptorProto_ExtensionRange&& from) noexcept
@@ -1002,9 +987,6 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
protected:
explicit DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1086,7 +1068,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
public:
inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {}
~DescriptorProto_ReservedRange() override;
- explicit constexpr DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from);
DescriptorProto_ReservedRange(DescriptorProto_ReservedRange&& from) noexcept
@@ -1195,9 +1177,6 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
protected:
explicit DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1259,7 +1238,7 @@ class PROTOBUF_EXPORT DescriptorProto final :
public:
inline DescriptorProto() : DescriptorProto(nullptr) {}
~DescriptorProto() override;
- explicit constexpr DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DescriptorProto(const DescriptorProto& from);
DescriptorProto(DescriptorProto&& from) noexcept
@@ -1368,9 +1347,6 @@ class PROTOBUF_EXPORT DescriptorProto final :
protected:
explicit DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1611,7 +1587,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
public:
inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {}
~ExtensionRangeOptions() override;
- explicit constexpr ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ExtensionRangeOptions(const ExtensionRangeOptions& from);
ExtensionRangeOptions(ExtensionRangeOptions&& from) noexcept
@@ -1720,9 +1696,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
protected:
explicit ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1965,7 +1938,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
public:
inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {}
~FieldDescriptorProto() override;
- explicit constexpr FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FieldDescriptorProto(const FieldDescriptorProto& from);
FieldDescriptorProto(FieldDescriptorProto&& from) noexcept
@@ -2074,9 +2047,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
protected:
explicit FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2397,7 +2367,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
public:
inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {}
~OneofDescriptorProto() override;
- explicit constexpr OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
OneofDescriptorProto(const OneofDescriptorProto& from);
OneofDescriptorProto(OneofDescriptorProto&& from) noexcept
@@ -2506,9 +2476,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
protected:
explicit OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2580,7 +2547,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
public:
inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {}
~EnumDescriptorProto_EnumReservedRange() override;
- explicit constexpr EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from);
EnumDescriptorProto_EnumReservedRange(EnumDescriptorProto_EnumReservedRange&& from) noexcept
@@ -2689,9 +2656,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
protected:
explicit EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2753,7 +2717,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
public:
inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {}
~EnumDescriptorProto() override;
- explicit constexpr EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumDescriptorProto(const EnumDescriptorProto& from);
EnumDescriptorProto(EnumDescriptorProto&& from) noexcept
@@ -2862,9 +2826,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
protected:
explicit EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3004,7 +2965,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
public:
inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {}
~EnumValueDescriptorProto() override;
- explicit constexpr EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumValueDescriptorProto(const EnumValueDescriptorProto& from);
EnumValueDescriptorProto(EnumValueDescriptorProto&& from) noexcept
@@ -3113,9 +3074,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
protected:
explicit EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3202,7 +3160,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
public:
inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {}
~ServiceDescriptorProto() override;
- explicit constexpr ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ServiceDescriptorProto(const ServiceDescriptorProto& from);
ServiceDescriptorProto(ServiceDescriptorProto&& from) noexcept
@@ -3311,9 +3269,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
protected:
explicit ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3405,7 +3360,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
public:
inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {}
~MethodDescriptorProto() override;
- explicit constexpr MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
MethodDescriptorProto(const MethodDescriptorProto& from);
MethodDescriptorProto(MethodDescriptorProto&& from) noexcept
@@ -3514,9 +3469,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
protected:
explicit MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3658,7 +3610,7 @@ class PROTOBUF_EXPORT FileOptions final :
public:
inline FileOptions() : FileOptions(nullptr) {}
~FileOptions() override;
- explicit constexpr FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FileOptions(const FileOptions& from);
FileOptions(FileOptions&& from) noexcept
@@ -3767,9 +3719,6 @@ class PROTOBUF_EXPORT FileOptions final :
protected:
explicit FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -4395,7 +4344,7 @@ class PROTOBUF_EXPORT MessageOptions final :
public:
inline MessageOptions() : MessageOptions(nullptr) {}
~MessageOptions() override;
- explicit constexpr MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
MessageOptions(const MessageOptions& from);
MessageOptions(MessageOptions&& from) noexcept
@@ -4504,9 +4453,6 @@ class PROTOBUF_EXPORT MessageOptions final :
protected:
explicit MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -4810,7 +4756,7 @@ class PROTOBUF_EXPORT FieldOptions final :
public:
inline FieldOptions() : FieldOptions(nullptr) {}
~FieldOptions() override;
- explicit constexpr FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FieldOptions(const FieldOptions& from);
FieldOptions(FieldOptions&& from) noexcept
@@ -4919,9 +4865,6 @@ class PROTOBUF_EXPORT FieldOptions final :
protected:
explicit FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -5000,11 +4943,12 @@ class PROTOBUF_EXPORT FieldOptions final :
enum : int {
kUninterpretedOptionFieldNumber = 999,
kCtypeFieldNumber = 1,
+ kJstypeFieldNumber = 6,
kPackedFieldNumber = 2,
kLazyFieldNumber = 5,
+ kUnverifiedLazyFieldNumber = 15,
kDeprecatedFieldNumber = 3,
kWeakFieldNumber = 10,
- kJstypeFieldNumber = 6,
};
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
@@ -5037,6 +4981,19 @@ class PROTOBUF_EXPORT FieldOptions final :
void _internal_set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value);
public:
+ // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
+ bool has_jstype() const;
+ private:
+ bool _internal_has_jstype() const;
+ public:
+ void clear_jstype();
+ ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType jstype() const;
+ void set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value);
+ private:
+ ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType _internal_jstype() const;
+ void _internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value);
+ public:
+
// optional bool packed = 2;
bool has_packed() const;
private:
@@ -5063,6 +5020,19 @@ class PROTOBUF_EXPORT FieldOptions final :
void _internal_set_lazy(bool value);
public:
+ // optional bool unverified_lazy = 15 [default = false];
+ bool has_unverified_lazy() const;
+ private:
+ bool _internal_has_unverified_lazy() const;
+ public:
+ void clear_unverified_lazy();
+ bool unverified_lazy() const;
+ void set_unverified_lazy(bool value);
+ private:
+ bool _internal_unverified_lazy() const;
+ void _internal_set_unverified_lazy(bool value);
+ public:
+
// optional bool deprecated = 3 [default = false];
bool has_deprecated() const;
private:
@@ -5089,19 +5059,6 @@ class PROTOBUF_EXPORT FieldOptions final :
void _internal_set_weak(bool value);
public:
- // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
- bool has_jstype() const;
- private:
- bool _internal_has_jstype() const;
- public:
- void clear_jstype();
- ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType jstype() const;
- void set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value);
- private:
- ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType _internal_jstype() const;
- void _internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value);
- public:
-
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
@@ -5305,11 +5262,12 @@ class PROTOBUF_EXPORT FieldOptions final :
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_;
int ctype_;
+ int jstype_;
bool packed_;
bool lazy_;
+ bool unverified_lazy_;
bool deprecated_;
bool weak_;
- int jstype_;
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
};
// -------------------------------------------------------------------
@@ -5319,7 +5277,7 @@ class PROTOBUF_EXPORT OneofOptions final :
public:
inline OneofOptions() : OneofOptions(nullptr) {}
~OneofOptions() override;
- explicit constexpr OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
OneofOptions(const OneofOptions& from);
OneofOptions(OneofOptions&& from) noexcept
@@ -5428,9 +5386,6 @@ class PROTOBUF_EXPORT OneofOptions final :
protected:
explicit OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -5673,7 +5628,7 @@ class PROTOBUF_EXPORT EnumOptions final :
public:
inline EnumOptions() : EnumOptions(nullptr) {}
~EnumOptions() override;
- explicit constexpr EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumOptions(const EnumOptions& from);
EnumOptions(EnumOptions&& from) noexcept
@@ -5782,9 +5737,6 @@ class PROTOBUF_EXPORT EnumOptions final :
protected:
explicit EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -6058,7 +6010,7 @@ class PROTOBUF_EXPORT EnumValueOptions final :
public:
inline EnumValueOptions() : EnumValueOptions(nullptr) {}
~EnumValueOptions() override;
- explicit constexpr EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumValueOptions(const EnumValueOptions& from);
EnumValueOptions(EnumValueOptions&& from) noexcept
@@ -6167,9 +6119,6 @@ class PROTOBUF_EXPORT EnumValueOptions final :
protected:
explicit EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -6428,7 +6377,7 @@ class PROTOBUF_EXPORT ServiceOptions final :
public:
inline ServiceOptions() : ServiceOptions(nullptr) {}
~ServiceOptions() override;
- explicit constexpr ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ServiceOptions(const ServiceOptions& from);
ServiceOptions(ServiceOptions&& from) noexcept
@@ -6537,9 +6486,6 @@ class PROTOBUF_EXPORT ServiceOptions final :
protected:
explicit ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -6798,7 +6744,7 @@ class PROTOBUF_EXPORT MethodOptions final :
public:
inline MethodOptions() : MethodOptions(nullptr) {}
~MethodOptions() override;
- explicit constexpr MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
MethodOptions(const MethodOptions& from);
MethodOptions(MethodOptions&& from) noexcept
@@ -6907,9 +6853,6 @@ class PROTOBUF_EXPORT MethodOptions final :
protected:
explicit MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7215,7 +7158,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
public:
inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {}
~UninterpretedOption_NamePart() override;
- explicit constexpr UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from);
UninterpretedOption_NamePart(UninterpretedOption_NamePart&& from) noexcept
@@ -7324,9 +7267,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
protected:
explicit UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7396,7 +7336,7 @@ class PROTOBUF_EXPORT UninterpretedOption final :
public:
inline UninterpretedOption() : UninterpretedOption(nullptr) {}
~UninterpretedOption() override;
- explicit constexpr UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UninterpretedOption(const UninterpretedOption& from);
UninterpretedOption(UninterpretedOption&& from) noexcept
@@ -7505,9 +7445,6 @@ class PROTOBUF_EXPORT UninterpretedOption final :
protected:
explicit UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7666,7 +7603,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
public:
inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {}
~SourceCodeInfo_Location() override;
- explicit constexpr SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SourceCodeInfo_Location(const SourceCodeInfo_Location& from);
SourceCodeInfo_Location(SourceCodeInfo_Location&& from) noexcept
@@ -7775,9 +7712,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
protected:
explicit SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7925,7 +7859,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
public:
inline SourceCodeInfo() : SourceCodeInfo(nullptr) {}
~SourceCodeInfo() override;
- explicit constexpr SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SourceCodeInfo(const SourceCodeInfo& from);
SourceCodeInfo(SourceCodeInfo&& from) noexcept
@@ -8034,9 +7968,6 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
protected:
explicit SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -8089,7 +8020,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
public:
inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {}
~GeneratedCodeInfo_Annotation() override;
- explicit constexpr GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from);
GeneratedCodeInfo_Annotation(GeneratedCodeInfo_Annotation&& from) noexcept
@@ -8198,9 +8129,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
protected:
explicit GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -8307,7 +8235,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
public:
inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {}
~GeneratedCodeInfo() override;
- explicit constexpr GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
GeneratedCodeInfo(const GeneratedCodeInfo& from);
GeneratedCodeInfo(GeneratedCodeInfo&& from) noexcept
@@ -8416,9 +8344,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
protected:
explicit GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -8539,7 +8464,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)
}
inline TProtoStringType* FileDescriptorProto::mutable_name() {
@@ -8552,11 +8477,11 @@ inline const TProtoStringType& FileDescriptorProto::_internal_name() const {
}
inline void FileDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name)
@@ -8564,10 +8489,10 @@ inline TProtoStringType* FileDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -8578,11 +8503,10 @@ inline void FileDescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name)
@@ -8608,7 +8532,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileDescriptorProto::set_package(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)
}
inline TProtoStringType* FileDescriptorProto::mutable_package() {
@@ -8621,11 +8545,11 @@ inline const TProtoStringType& FileDescriptorProto::_internal_package() const {
}
inline void FileDescriptorProto::_internal_set_package(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::_internal_mutable_package() {
_has_bits_[0] |= 0x00000002u;
- return package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return package_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::release_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package)
@@ -8633,10 +8557,10 @@ inline TProtoStringType* FileDescriptorProto::release_package() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = package_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (package_.IsDefault()) {
+ package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -8647,11 +8571,10 @@ inline void FileDescriptorProto::set_allocated_package(TProtoStringType* package
} else {
_has_bits_[0] &= ~0x00000002u;
}
- package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), package,
- GetArenaForAllocation());
+ package_.SetAllocated(package, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (package_.IsDefault()) {
+ package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package)
@@ -9063,7 +8986,7 @@ inline void FileDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::FileOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -9153,7 +9076,7 @@ inline void FileDescriptorProto::set_allocated_source_code_info(::PROTOBUF_NAMES
}
if (source_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>::GetOwningArena(source_code_info);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(source_code_info);
if (message_arena != submessage_arena) {
source_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_code_info, submessage_arena);
@@ -9186,7 +9109,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileDescriptorProto::set_syntax(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
- syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ syntax_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)
}
inline TProtoStringType* FileDescriptorProto::mutable_syntax() {
@@ -9199,11 +9122,11 @@ inline const TProtoStringType& FileDescriptorProto::_internal_syntax() const {
}
inline void FileDescriptorProto::_internal_set_syntax(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000004u;
- syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ syntax_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::_internal_mutable_syntax() {
_has_bits_[0] |= 0x00000004u;
- return syntax_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return syntax_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::release_syntax() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax)
@@ -9211,10 +9134,10 @@ inline TProtoStringType* FileDescriptorProto::release_syntax() {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
- auto* p = syntax_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = syntax_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (syntax_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (syntax_.IsDefault()) {
+ syntax_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -9225,11 +9148,10 @@ inline void FileDescriptorProto::set_allocated_syntax(TProtoStringType* syntax)
} else {
_has_bits_[0] &= ~0x00000004u;
}
- syntax_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), syntax,
- GetArenaForAllocation());
+ syntax_.SetAllocated(syntax, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (syntax_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (syntax_.IsDefault()) {
+ syntax_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)
@@ -9372,7 +9294,7 @@ inline void DescriptorProto_ExtensionRange::set_allocated_options(::PROTOBUF_NAM
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -9469,7 +9391,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void DescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)
}
inline TProtoStringType* DescriptorProto::mutable_name() {
@@ -9482,11 +9404,11 @@ inline const TProtoStringType& DescriptorProto::_internal_name() const {
}
inline void DescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* DescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* DescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name)
@@ -9494,10 +9416,10 @@ inline TProtoStringType* DescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -9508,11 +9430,10 @@ inline void DescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name)
@@ -9835,7 +9756,7 @@ inline void DescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::Mess
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::MessageOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -10031,7 +9952,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FieldDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)
}
inline TProtoStringType* FieldDescriptorProto::mutable_name() {
@@ -10044,11 +9965,11 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_name() const {
}
inline void FieldDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name)
@@ -10056,10 +9977,10 @@ inline TProtoStringType* FieldDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10070,11 +9991,10 @@ inline void FieldDescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name)
@@ -10186,7 +10106,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FieldDescriptorProto::set_type_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
- type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ type_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)
}
inline TProtoStringType* FieldDescriptorProto::mutable_type_name() {
@@ -10199,11 +10119,11 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_type_name() const
}
inline void FieldDescriptorProto::_internal_set_type_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000004u;
- type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ type_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_type_name() {
_has_bits_[0] |= 0x00000004u;
- return type_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return type_name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_type_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name)
@@ -10211,10 +10131,10 @@ inline TProtoStringType* FieldDescriptorProto::release_type_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
- auto* p = type_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = type_name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (type_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (type_name_.IsDefault()) {
+ type_name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10225,11 +10145,10 @@ inline void FieldDescriptorProto::set_allocated_type_name(TProtoStringType* type
} else {
_has_bits_[0] &= ~0x00000004u;
}
- type_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_name,
- GetArenaForAllocation());
+ type_name_.SetAllocated(type_name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (type_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (type_name_.IsDefault()) {
+ type_name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name)
@@ -10255,7 +10174,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FieldDescriptorProto::set_extendee(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ extendee_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)
}
inline TProtoStringType* FieldDescriptorProto::mutable_extendee() {
@@ -10268,11 +10187,11 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_extendee() const
}
inline void FieldDescriptorProto::_internal_set_extendee(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ extendee_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_extendee() {
_has_bits_[0] |= 0x00000002u;
- return extendee_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return extendee_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_extendee() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee)
@@ -10280,10 +10199,10 @@ inline TProtoStringType* FieldDescriptorProto::release_extendee() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = extendee_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = extendee_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (extendee_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (extendee_.IsDefault()) {
+ extendee_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10294,11 +10213,10 @@ inline void FieldDescriptorProto::set_allocated_extendee(TProtoStringType* exten
} else {
_has_bits_[0] &= ~0x00000002u;
}
- extendee_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), extendee,
- GetArenaForAllocation());
+ extendee_.SetAllocated(extendee, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (extendee_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (extendee_.IsDefault()) {
+ extendee_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee)
@@ -10324,7 +10242,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FieldDescriptorProto::set_default_value(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000008u;
- default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)
}
inline TProtoStringType* FieldDescriptorProto::mutable_default_value() {
@@ -10337,11 +10255,11 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_default_value() c
}
inline void FieldDescriptorProto::_internal_set_default_value(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000008u;
- default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ default_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_default_value() {
_has_bits_[0] |= 0x00000008u;
- return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return default_value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value)
@@ -10349,10 +10267,10 @@ inline TProtoStringType* FieldDescriptorProto::release_default_value() {
return nullptr;
}
_has_bits_[0] &= ~0x00000008u;
- auto* p = default_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = default_value_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (default_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (default_value_.IsDefault()) {
+ default_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10363,11 +10281,10 @@ inline void FieldDescriptorProto::set_allocated_default_value(TProtoStringType*
} else {
_has_bits_[0] &= ~0x00000008u;
}
- default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value,
- GetArenaForAllocation());
+ default_value_.SetAllocated(default_value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (default_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (default_value_.IsDefault()) {
+ default_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value)
@@ -10421,7 +10338,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FieldDescriptorProto::set_json_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000010u;
- json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)
}
inline TProtoStringType* FieldDescriptorProto::mutable_json_name() {
@@ -10434,11 +10351,11 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_json_name() const
}
inline void FieldDescriptorProto::_internal_set_json_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000010u;
- json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ json_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_json_name() {
_has_bits_[0] |= 0x00000010u;
- return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return json_name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name)
@@ -10446,10 +10363,10 @@ inline TProtoStringType* FieldDescriptorProto::release_json_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000010u;
- auto* p = json_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = json_name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (json_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (json_name_.IsDefault()) {
+ json_name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10460,11 +10377,10 @@ inline void FieldDescriptorProto::set_allocated_json_name(TProtoStringType* json
} else {
_has_bits_[0] &= ~0x00000010u;
}
- json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name,
- GetArenaForAllocation());
+ json_name_.SetAllocated(json_name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (json_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (json_name_.IsDefault()) {
+ json_name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name)
@@ -10547,7 +10463,7 @@ inline void FieldDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID:
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::FieldOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -10612,7 +10528,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void OneofDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)
}
inline TProtoStringType* OneofDescriptorProto::mutable_name() {
@@ -10625,11 +10541,11 @@ inline const TProtoStringType& OneofDescriptorProto::_internal_name() const {
}
inline void OneofDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* OneofDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* OneofDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name)
@@ -10637,10 +10553,10 @@ inline TProtoStringType* OneofDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10651,11 +10567,10 @@ inline void OneofDescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name)
@@ -10738,7 +10653,7 @@ inline void OneofDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID:
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::OneofOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -10835,7 +10750,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void EnumDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)
}
inline TProtoStringType* EnumDescriptorProto::mutable_name() {
@@ -10848,11 +10763,11 @@ inline const TProtoStringType& EnumDescriptorProto::_internal_name() const {
}
inline void EnumDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* EnumDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* EnumDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name)
@@ -10860,10 +10775,10 @@ inline TProtoStringType* EnumDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -10874,11 +10789,10 @@ inline void EnumDescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name)
@@ -11001,7 +10915,7 @@ inline void EnumDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::EnumOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -11153,7 +11067,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void EnumValueDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)
}
inline TProtoStringType* EnumValueDescriptorProto::mutable_name() {
@@ -11166,11 +11080,11 @@ inline const TProtoStringType& EnumValueDescriptorProto::_internal_name() const
}
inline void EnumValueDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* EnumValueDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* EnumValueDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name)
@@ -11178,10 +11092,10 @@ inline TProtoStringType* EnumValueDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -11192,11 +11106,10 @@ inline void EnumValueDescriptorProto::set_allocated_name(TProtoStringType* name)
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name)
@@ -11307,7 +11220,7 @@ inline void EnumValueDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -11344,7 +11257,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void ServiceDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)
}
inline TProtoStringType* ServiceDescriptorProto::mutable_name() {
@@ -11357,11 +11270,11 @@ inline const TProtoStringType& ServiceDescriptorProto::_internal_name() const {
}
inline void ServiceDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* ServiceDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* ServiceDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name)
@@ -11369,10 +11282,10 @@ inline TProtoStringType* ServiceDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -11383,11 +11296,10 @@ inline void ServiceDescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name)
@@ -11510,7 +11422,7 @@ inline void ServiceDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_I
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ServiceOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -11547,7 +11459,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void MethodDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)
}
inline TProtoStringType* MethodDescriptorProto::mutable_name() {
@@ -11560,11 +11472,11 @@ inline const TProtoStringType& MethodDescriptorProto::_internal_name() const {
}
inline void MethodDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name)
@@ -11572,10 +11484,10 @@ inline TProtoStringType* MethodDescriptorProto::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -11586,11 +11498,10 @@ inline void MethodDescriptorProto::set_allocated_name(TProtoStringType* name) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name)
@@ -11616,7 +11527,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void MethodDescriptorProto::set_input_type(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ input_type_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)
}
inline TProtoStringType* MethodDescriptorProto::mutable_input_type() {
@@ -11629,11 +11540,11 @@ inline const TProtoStringType& MethodDescriptorProto::_internal_input_type() con
}
inline void MethodDescriptorProto::_internal_set_input_type(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ input_type_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::_internal_mutable_input_type() {
_has_bits_[0] |= 0x00000002u;
- return input_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return input_type_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::release_input_type() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type)
@@ -11641,10 +11552,10 @@ inline TProtoStringType* MethodDescriptorProto::release_input_type() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = input_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = input_type_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (input_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (input_type_.IsDefault()) {
+ input_type_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -11655,11 +11566,10 @@ inline void MethodDescriptorProto::set_allocated_input_type(TProtoStringType* in
} else {
_has_bits_[0] &= ~0x00000002u;
}
- input_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), input_type,
- GetArenaForAllocation());
+ input_type_.SetAllocated(input_type, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (input_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (input_type_.IsDefault()) {
+ input_type_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type)
@@ -11685,7 +11595,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void MethodDescriptorProto::set_output_type(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
- output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ output_type_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)
}
inline TProtoStringType* MethodDescriptorProto::mutable_output_type() {
@@ -11698,11 +11608,11 @@ inline const TProtoStringType& MethodDescriptorProto::_internal_output_type() co
}
inline void MethodDescriptorProto::_internal_set_output_type(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000004u;
- output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ output_type_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::_internal_mutable_output_type() {
_has_bits_[0] |= 0x00000004u;
- return output_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return output_type_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::release_output_type() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type)
@@ -11710,10 +11620,10 @@ inline TProtoStringType* MethodDescriptorProto::release_output_type() {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
- auto* p = output_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = output_type_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (output_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (output_type_.IsDefault()) {
+ output_type_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -11724,11 +11634,10 @@ inline void MethodDescriptorProto::set_allocated_output_type(TProtoStringType* o
} else {
_has_bits_[0] &= ~0x00000004u;
}
- output_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), output_type,
- GetArenaForAllocation());
+ output_type_.SetAllocated(output_type, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (output_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (output_type_.IsDefault()) {
+ output_type_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type)
@@ -11811,7 +11720,7 @@ inline void MethodDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID
}
if (options) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::MethodOptions>::GetOwningArena(options);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options);
if (message_arena != submessage_arena) {
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
@@ -11904,7 +11813,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_java_package(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ java_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)
}
inline TProtoStringType* FileOptions::mutable_java_package() {
@@ -11917,11 +11826,11 @@ inline const TProtoStringType& FileOptions::_internal_java_package() const {
}
inline void FileOptions::_internal_set_java_package(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ java_package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_java_package() {
_has_bits_[0] |= 0x00000001u;
- return java_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return java_package_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_java_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package)
@@ -11929,10 +11838,10 @@ inline TProtoStringType* FileOptions::release_java_package() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = java_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = java_package_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (java_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (java_package_.IsDefault()) {
+ java_package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -11943,11 +11852,10 @@ inline void FileOptions::set_allocated_java_package(TProtoStringType* java_packa
} else {
_has_bits_[0] &= ~0x00000001u;
}
- java_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_package,
- GetArenaForAllocation());
+ java_package_.SetAllocated(java_package, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (java_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (java_package_.IsDefault()) {
+ java_package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package)
@@ -11973,7 +11881,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_java_outer_classname(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ java_outer_classname_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)
}
inline TProtoStringType* FileOptions::mutable_java_outer_classname() {
@@ -11986,11 +11894,11 @@ inline const TProtoStringType& FileOptions::_internal_java_outer_classname() con
}
inline void FileOptions::_internal_set_java_outer_classname(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ java_outer_classname_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_java_outer_classname() {
_has_bits_[0] |= 0x00000002u;
- return java_outer_classname_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return java_outer_classname_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_java_outer_classname() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname)
@@ -11998,10 +11906,10 @@ inline TProtoStringType* FileOptions::release_java_outer_classname() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = java_outer_classname_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = java_outer_classname_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (java_outer_classname_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (java_outer_classname_.IsDefault()) {
+ java_outer_classname_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12012,11 +11920,10 @@ inline void FileOptions::set_allocated_java_outer_classname(TProtoStringType* ja
} else {
_has_bits_[0] &= ~0x00000002u;
}
- java_outer_classname_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_outer_classname,
- GetArenaForAllocation());
+ java_outer_classname_.SetAllocated(java_outer_classname, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (java_outer_classname_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (java_outer_classname_.IsDefault()) {
+ java_outer_classname_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname)
@@ -12155,7 +12062,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_go_package(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
- go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ go_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)
}
inline TProtoStringType* FileOptions::mutable_go_package() {
@@ -12168,11 +12075,11 @@ inline const TProtoStringType& FileOptions::_internal_go_package() const {
}
inline void FileOptions::_internal_set_go_package(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000004u;
- go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ go_package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_go_package() {
_has_bits_[0] |= 0x00000004u;
- return go_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return go_package_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_go_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package)
@@ -12180,10 +12087,10 @@ inline TProtoStringType* FileOptions::release_go_package() {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
- auto* p = go_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = go_package_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (go_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (go_package_.IsDefault()) {
+ go_package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12194,11 +12101,10 @@ inline void FileOptions::set_allocated_go_package(TProtoStringType* go_package)
} else {
_has_bits_[0] &= ~0x00000004u;
}
- go_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), go_package,
- GetArenaForAllocation());
+ go_package_.SetAllocated(go_package, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (go_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (go_package_.IsDefault()) {
+ go_package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package)
@@ -12392,7 +12298,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_objc_class_prefix(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000008u;
- objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ objc_class_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)
}
inline TProtoStringType* FileOptions::mutable_objc_class_prefix() {
@@ -12405,11 +12311,11 @@ inline const TProtoStringType& FileOptions::_internal_objc_class_prefix() const
}
inline void FileOptions::_internal_set_objc_class_prefix(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000008u;
- objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ objc_class_prefix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_objc_class_prefix() {
_has_bits_[0] |= 0x00000008u;
- return objc_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return objc_class_prefix_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_objc_class_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix)
@@ -12417,10 +12323,10 @@ inline TProtoStringType* FileOptions::release_objc_class_prefix() {
return nullptr;
}
_has_bits_[0] &= ~0x00000008u;
- auto* p = objc_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = objc_class_prefix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (objc_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (objc_class_prefix_.IsDefault()) {
+ objc_class_prefix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12431,11 +12337,10 @@ inline void FileOptions::set_allocated_objc_class_prefix(TProtoStringType* objc_
} else {
_has_bits_[0] &= ~0x00000008u;
}
- objc_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), objc_class_prefix,
- GetArenaForAllocation());
+ objc_class_prefix_.SetAllocated(objc_class_prefix, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (objc_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (objc_class_prefix_.IsDefault()) {
+ objc_class_prefix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix)
@@ -12461,7 +12366,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_csharp_namespace(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000010u;
- csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ csharp_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)
}
inline TProtoStringType* FileOptions::mutable_csharp_namespace() {
@@ -12474,11 +12379,11 @@ inline const TProtoStringType& FileOptions::_internal_csharp_namespace() const {
}
inline void FileOptions::_internal_set_csharp_namespace(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000010u;
- csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ csharp_namespace_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_csharp_namespace() {
_has_bits_[0] |= 0x00000010u;
- return csharp_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return csharp_namespace_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_csharp_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace)
@@ -12486,10 +12391,10 @@ inline TProtoStringType* FileOptions::release_csharp_namespace() {
return nullptr;
}
_has_bits_[0] &= ~0x00000010u;
- auto* p = csharp_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = csharp_namespace_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (csharp_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (csharp_namespace_.IsDefault()) {
+ csharp_namespace_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12500,11 +12405,10 @@ inline void FileOptions::set_allocated_csharp_namespace(TProtoStringType* csharp
} else {
_has_bits_[0] &= ~0x00000010u;
}
- csharp_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), csharp_namespace,
- GetArenaForAllocation());
+ csharp_namespace_.SetAllocated(csharp_namespace, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (csharp_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (csharp_namespace_.IsDefault()) {
+ csharp_namespace_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)
@@ -12530,7 +12434,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_swift_prefix(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000020u;
- swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ swift_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix)
}
inline TProtoStringType* FileOptions::mutable_swift_prefix() {
@@ -12543,11 +12447,11 @@ inline const TProtoStringType& FileOptions::_internal_swift_prefix() const {
}
inline void FileOptions::_internal_set_swift_prefix(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000020u;
- swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ swift_prefix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_swift_prefix() {
_has_bits_[0] |= 0x00000020u;
- return swift_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return swift_prefix_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_swift_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix)
@@ -12555,10 +12459,10 @@ inline TProtoStringType* FileOptions::release_swift_prefix() {
return nullptr;
}
_has_bits_[0] &= ~0x00000020u;
- auto* p = swift_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = swift_prefix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (swift_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (swift_prefix_.IsDefault()) {
+ swift_prefix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12569,11 +12473,10 @@ inline void FileOptions::set_allocated_swift_prefix(TProtoStringType* swift_pref
} else {
_has_bits_[0] &= ~0x00000020u;
}
- swift_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), swift_prefix,
- GetArenaForAllocation());
+ swift_prefix_.SetAllocated(swift_prefix, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (swift_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (swift_prefix_.IsDefault()) {
+ swift_prefix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix)
@@ -12599,7 +12502,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_php_class_prefix(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000040u;
- php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ php_class_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix)
}
inline TProtoStringType* FileOptions::mutable_php_class_prefix() {
@@ -12612,11 +12515,11 @@ inline const TProtoStringType& FileOptions::_internal_php_class_prefix() const {
}
inline void FileOptions::_internal_set_php_class_prefix(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000040u;
- php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ php_class_prefix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_php_class_prefix() {
_has_bits_[0] |= 0x00000040u;
- return php_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return php_class_prefix_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_php_class_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix)
@@ -12624,10 +12527,10 @@ inline TProtoStringType* FileOptions::release_php_class_prefix() {
return nullptr;
}
_has_bits_[0] &= ~0x00000040u;
- auto* p = php_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = php_class_prefix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (php_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (php_class_prefix_.IsDefault()) {
+ php_class_prefix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12638,11 +12541,10 @@ inline void FileOptions::set_allocated_php_class_prefix(TProtoStringType* php_cl
} else {
_has_bits_[0] &= ~0x00000040u;
}
- php_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_class_prefix,
- GetArenaForAllocation());
+ php_class_prefix_.SetAllocated(php_class_prefix, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (php_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (php_class_prefix_.IsDefault()) {
+ php_class_prefix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix)
@@ -12668,7 +12570,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_php_namespace(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000080u;
- php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ php_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace)
}
inline TProtoStringType* FileOptions::mutable_php_namespace() {
@@ -12681,11 +12583,11 @@ inline const TProtoStringType& FileOptions::_internal_php_namespace() const {
}
inline void FileOptions::_internal_set_php_namespace(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000080u;
- php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ php_namespace_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_php_namespace() {
_has_bits_[0] |= 0x00000080u;
- return php_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return php_namespace_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_php_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace)
@@ -12693,10 +12595,10 @@ inline TProtoStringType* FileOptions::release_php_namespace() {
return nullptr;
}
_has_bits_[0] &= ~0x00000080u;
- auto* p = php_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = php_namespace_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (php_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (php_namespace_.IsDefault()) {
+ php_namespace_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12707,11 +12609,10 @@ inline void FileOptions::set_allocated_php_namespace(TProtoStringType* php_names
} else {
_has_bits_[0] &= ~0x00000080u;
}
- php_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_namespace,
- GetArenaForAllocation());
+ php_namespace_.SetAllocated(php_namespace, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (php_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (php_namespace_.IsDefault()) {
+ php_namespace_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace)
@@ -12737,7 +12638,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_php_metadata_namespace(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000100u;
- php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ php_metadata_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace)
}
inline TProtoStringType* FileOptions::mutable_php_metadata_namespace() {
@@ -12750,11 +12651,11 @@ inline const TProtoStringType& FileOptions::_internal_php_metadata_namespace() c
}
inline void FileOptions::_internal_set_php_metadata_namespace(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000100u;
- php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ php_metadata_namespace_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_php_metadata_namespace() {
_has_bits_[0] |= 0x00000100u;
- return php_metadata_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return php_metadata_namespace_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_php_metadata_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_metadata_namespace)
@@ -12762,10 +12663,10 @@ inline TProtoStringType* FileOptions::release_php_metadata_namespace() {
return nullptr;
}
_has_bits_[0] &= ~0x00000100u;
- auto* p = php_metadata_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = php_metadata_namespace_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (php_metadata_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (php_metadata_namespace_.IsDefault()) {
+ php_metadata_namespace_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12776,11 +12677,10 @@ inline void FileOptions::set_allocated_php_metadata_namespace(TProtoStringType*
} else {
_has_bits_[0] &= ~0x00000100u;
}
- php_metadata_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_metadata_namespace,
- GetArenaForAllocation());
+ php_metadata_namespace_.SetAllocated(php_metadata_namespace, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (php_metadata_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (php_metadata_namespace_.IsDefault()) {
+ php_metadata_namespace_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_metadata_namespace)
@@ -12806,7 +12706,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void FileOptions::set_ruby_package(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000200u;
- ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ ruby_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package)
}
inline TProtoStringType* FileOptions::mutable_ruby_package() {
@@ -12819,11 +12719,11 @@ inline const TProtoStringType& FileOptions::_internal_ruby_package() const {
}
inline void FileOptions::_internal_set_ruby_package(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000200u;
- ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ ruby_package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_ruby_package() {
_has_bits_[0] |= 0x00000200u;
- return ruby_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return ruby_package_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_ruby_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.ruby_package)
@@ -12831,10 +12731,10 @@ inline TProtoStringType* FileOptions::release_ruby_package() {
return nullptr;
}
_has_bits_[0] &= ~0x00000200u;
- auto* p = ruby_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = ruby_package_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (ruby_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (ruby_package_.IsDefault()) {
+ ruby_package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -12845,11 +12745,10 @@ inline void FileOptions::set_allocated_ruby_package(TProtoStringType* ruby_packa
} else {
_has_bits_[0] &= ~0x00000200u;
}
- ruby_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ruby_package,
- GetArenaForAllocation());
+ ruby_package_.SetAllocated(ruby_package, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (ruby_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (ruby_package_.IsDefault()) {
+ ruby_package_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.ruby_package)
@@ -13086,7 +12985,7 @@ inline void FieldOptions::set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType
// optional bool packed = 2;
inline bool FieldOptions::_internal_has_packed() const {
- bool value = (_has_bits_[0] & 0x00000002u) != 0;
+ bool value = (_has_bits_[0] & 0x00000004u) != 0;
return value;
}
inline bool FieldOptions::has_packed() const {
@@ -13094,7 +12993,7 @@ inline bool FieldOptions::has_packed() const {
}
inline void FieldOptions::clear_packed() {
packed_ = false;
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline bool FieldOptions::_internal_packed() const {
return packed_;
@@ -13104,7 +13003,7 @@ inline bool FieldOptions::packed() const {
return _internal_packed();
}
inline void FieldOptions::_internal_set_packed(bool value) {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000004u;
packed_ = value;
}
inline void FieldOptions::set_packed(bool value) {
@@ -13114,7 +13013,7 @@ inline void FieldOptions::set_packed(bool value) {
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
inline bool FieldOptions::_internal_has_jstype() const {
- bool value = (_has_bits_[0] & 0x00000020u) != 0;
+ bool value = (_has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline bool FieldOptions::has_jstype() const {
@@ -13122,7 +13021,7 @@ inline bool FieldOptions::has_jstype() const {
}
inline void FieldOptions::clear_jstype() {
jstype_ = 0;
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::_internal_jstype() const {
return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType >(jstype_);
@@ -13133,7 +13032,7 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::jstype() const
}
inline void FieldOptions::_internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) {
assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_IsValid(value));
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00000002u;
jstype_ = value;
}
inline void FieldOptions::set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) {
@@ -13143,7 +13042,7 @@ inline void FieldOptions::set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSTyp
// optional bool lazy = 5 [default = false];
inline bool FieldOptions::_internal_has_lazy() const {
- bool value = (_has_bits_[0] & 0x00000004u) != 0;
+ bool value = (_has_bits_[0] & 0x00000008u) != 0;
return value;
}
inline bool FieldOptions::has_lazy() const {
@@ -13151,7 +13050,7 @@ inline bool FieldOptions::has_lazy() const {
}
inline void FieldOptions::clear_lazy() {
lazy_ = false;
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000008u;
}
inline bool FieldOptions::_internal_lazy() const {
return lazy_;
@@ -13161,7 +13060,7 @@ inline bool FieldOptions::lazy() const {
return _internal_lazy();
}
inline void FieldOptions::_internal_set_lazy(bool value) {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000008u;
lazy_ = value;
}
inline void FieldOptions::set_lazy(bool value) {
@@ -13169,9 +13068,37 @@ inline void FieldOptions::set_lazy(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy)
}
+// optional bool unverified_lazy = 15 [default = false];
+inline bool FieldOptions::_internal_has_unverified_lazy() const {
+ bool value = (_has_bits_[0] & 0x00000010u) != 0;
+ return value;
+}
+inline bool FieldOptions::has_unverified_lazy() const {
+ return _internal_has_unverified_lazy();
+}
+inline void FieldOptions::clear_unverified_lazy() {
+ unverified_lazy_ = false;
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline bool FieldOptions::_internal_unverified_lazy() const {
+ return unverified_lazy_;
+}
+inline bool FieldOptions::unverified_lazy() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.unverified_lazy)
+ return _internal_unverified_lazy();
+}
+inline void FieldOptions::_internal_set_unverified_lazy(bool value) {
+ _has_bits_[0] |= 0x00000010u;
+ unverified_lazy_ = value;
+}
+inline void FieldOptions::set_unverified_lazy(bool value) {
+ _internal_set_unverified_lazy(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.unverified_lazy)
+}
+
// optional bool deprecated = 3 [default = false];
inline bool FieldOptions::_internal_has_deprecated() const {
- bool value = (_has_bits_[0] & 0x00000008u) != 0;
+ bool value = (_has_bits_[0] & 0x00000020u) != 0;
return value;
}
inline bool FieldOptions::has_deprecated() const {
@@ -13179,7 +13106,7 @@ inline bool FieldOptions::has_deprecated() const {
}
inline void FieldOptions::clear_deprecated() {
deprecated_ = false;
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000020u;
}
inline bool FieldOptions::_internal_deprecated() const {
return deprecated_;
@@ -13189,7 +13116,7 @@ inline bool FieldOptions::deprecated() const {
return _internal_deprecated();
}
inline void FieldOptions::_internal_set_deprecated(bool value) {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000020u;
deprecated_ = value;
}
inline void FieldOptions::set_deprecated(bool value) {
@@ -13199,7 +13126,7 @@ inline void FieldOptions::set_deprecated(bool value) {
// optional bool weak = 10 [default = false];
inline bool FieldOptions::_internal_has_weak() const {
- bool value = (_has_bits_[0] & 0x00000010u) != 0;
+ bool value = (_has_bits_[0] & 0x00000040u) != 0;
return value;
}
inline bool FieldOptions::has_weak() const {
@@ -13207,7 +13134,7 @@ inline bool FieldOptions::has_weak() const {
}
inline void FieldOptions::clear_weak() {
weak_ = false;
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000040u;
}
inline bool FieldOptions::_internal_weak() const {
return weak_;
@@ -13217,7 +13144,7 @@ inline bool FieldOptions::weak() const {
return _internal_weak();
}
inline void FieldOptions::_internal_set_weak(bool value) {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000040u;
weak_ = value;
}
inline void FieldOptions::set_weak(bool value) {
@@ -13678,7 +13605,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void UninterpretedOption_NamePart::set_name_part(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_part_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)
}
inline TProtoStringType* UninterpretedOption_NamePart::mutable_name_part() {
@@ -13691,11 +13618,11 @@ inline const TProtoStringType& UninterpretedOption_NamePart::_internal_name_part
}
inline void UninterpretedOption_NamePart::_internal_set_name_part(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_part_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption_NamePart::_internal_mutable_name_part() {
_has_bits_[0] |= 0x00000001u;
- return name_part_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_part_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption_NamePart::release_name_part() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)
@@ -13703,10 +13630,10 @@ inline TProtoStringType* UninterpretedOption_NamePart::release_name_part() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_part_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_part_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_part_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_part_.IsDefault()) {
+ name_part_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -13717,11 +13644,10 @@ inline void UninterpretedOption_NamePart::set_allocated_name_part(TProtoStringTy
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_part_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name_part,
- GetArenaForAllocation());
+ name_part_.SetAllocated(name_part, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_part_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_part_.IsDefault()) {
+ name_part_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)
@@ -13819,7 +13745,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void UninterpretedOption::set_identifier_value(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ identifier_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)
}
inline TProtoStringType* UninterpretedOption::mutable_identifier_value() {
@@ -13832,11 +13758,11 @@ inline const TProtoStringType& UninterpretedOption::_internal_identifier_value()
}
inline void UninterpretedOption::_internal_set_identifier_value(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ identifier_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::_internal_mutable_identifier_value() {
_has_bits_[0] |= 0x00000001u;
- return identifier_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return identifier_value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::release_identifier_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value)
@@ -13844,10 +13770,10 @@ inline TProtoStringType* UninterpretedOption::release_identifier_value() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = identifier_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = identifier_value_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (identifier_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (identifier_value_.IsDefault()) {
+ identifier_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -13858,11 +13784,10 @@ inline void UninterpretedOption::set_allocated_identifier_value(TProtoStringType
} else {
_has_bits_[0] &= ~0x00000001u;
}
- identifier_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), identifier_value,
- GetArenaForAllocation());
+ identifier_value_.SetAllocated(identifier_value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (identifier_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (identifier_value_.IsDefault()) {
+ identifier_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value)
@@ -13972,7 +13897,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void UninterpretedOption::set_string_value(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- string_value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ string_value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)
}
inline TProtoStringType* UninterpretedOption::mutable_string_value() {
@@ -13985,11 +13910,11 @@ inline const TProtoStringType& UninterpretedOption::_internal_string_value() con
}
inline void UninterpretedOption::_internal_set_string_value(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ string_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::_internal_mutable_string_value() {
_has_bits_[0] |= 0x00000002u;
- return string_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return string_value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::release_string_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value)
@@ -13997,10 +13922,10 @@ inline TProtoStringType* UninterpretedOption::release_string_value() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = string_value_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (string_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (string_value_.IsDefault()) {
+ string_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -14011,11 +13936,10 @@ inline void UninterpretedOption::set_allocated_string_value(TProtoStringType* st
} else {
_has_bits_[0] &= ~0x00000002u;
}
- string_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value,
- GetArenaForAllocation());
+ string_value_.SetAllocated(string_value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (string_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (string_value_.IsDefault()) {
+ string_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value)
@@ -14041,7 +13965,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void UninterpretedOption::set_aggregate_value(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
- aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ aggregate_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)
}
inline TProtoStringType* UninterpretedOption::mutable_aggregate_value() {
@@ -14054,11 +13978,11 @@ inline const TProtoStringType& UninterpretedOption::_internal_aggregate_value()
}
inline void UninterpretedOption::_internal_set_aggregate_value(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000004u;
- aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ aggregate_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::_internal_mutable_aggregate_value() {
_has_bits_[0] |= 0x00000004u;
- return aggregate_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return aggregate_value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::release_aggregate_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value)
@@ -14066,10 +13990,10 @@ inline TProtoStringType* UninterpretedOption::release_aggregate_value() {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
- auto* p = aggregate_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = aggregate_value_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (aggregate_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (aggregate_value_.IsDefault()) {
+ aggregate_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -14080,11 +14004,10 @@ inline void UninterpretedOption::set_allocated_aggregate_value(TProtoStringType*
} else {
_has_bits_[0] &= ~0x00000004u;
}
- aggregate_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), aggregate_value,
- GetArenaForAllocation());
+ aggregate_value_.SetAllocated(aggregate_value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (aggregate_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (aggregate_value_.IsDefault()) {
+ aggregate_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)
@@ -14208,7 +14131,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void SourceCodeInfo_Location::set_leading_comments(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ leading_comments_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
inline TProtoStringType* SourceCodeInfo_Location::mutable_leading_comments() {
@@ -14221,11 +14144,11 @@ inline const TProtoStringType& SourceCodeInfo_Location::_internal_leading_commen
}
inline void SourceCodeInfo_Location::_internal_set_leading_comments(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ leading_comments_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::_internal_mutable_leading_comments() {
_has_bits_[0] |= 0x00000001u;
- return leading_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return leading_comments_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::release_leading_comments() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments)
@@ -14233,10 +14156,10 @@ inline TProtoStringType* SourceCodeInfo_Location::release_leading_comments() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = leading_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = leading_comments_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (leading_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (leading_comments_.IsDefault()) {
+ leading_comments_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -14247,11 +14170,10 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(TProtoString
} else {
_has_bits_[0] &= ~0x00000001u;
}
- leading_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), leading_comments,
- GetArenaForAllocation());
+ leading_comments_.SetAllocated(leading_comments, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (leading_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (leading_comments_.IsDefault()) {
+ leading_comments_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments)
@@ -14277,7 +14199,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void SourceCodeInfo_Location::set_trailing_comments(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ trailing_comments_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
inline TProtoStringType* SourceCodeInfo_Location::mutable_trailing_comments() {
@@ -14290,11 +14212,11 @@ inline const TProtoStringType& SourceCodeInfo_Location::_internal_trailing_comme
}
inline void SourceCodeInfo_Location::_internal_set_trailing_comments(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ trailing_comments_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::_internal_mutable_trailing_comments() {
_has_bits_[0] |= 0x00000002u;
- return trailing_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return trailing_comments_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::release_trailing_comments() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments)
@@ -14302,10 +14224,10 @@ inline TProtoStringType* SourceCodeInfo_Location::release_trailing_comments() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = trailing_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = trailing_comments_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (trailing_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (trailing_comments_.IsDefault()) {
+ trailing_comments_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -14316,11 +14238,10 @@ inline void SourceCodeInfo_Location::set_allocated_trailing_comments(TProtoStrin
} else {
_has_bits_[0] &= ~0x00000002u;
}
- trailing_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), trailing_comments,
- GetArenaForAllocation());
+ trailing_comments_.SetAllocated(trailing_comments, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (trailing_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (trailing_comments_.IsDefault()) {
+ trailing_comments_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments)
@@ -14516,7 +14437,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void GeneratedCodeInfo_Annotation::set_source_file(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ source_file_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
inline TProtoStringType* GeneratedCodeInfo_Annotation::mutable_source_file() {
@@ -14529,11 +14450,11 @@ inline const TProtoStringType& GeneratedCodeInfo_Annotation::_internal_source_fi
}
inline void GeneratedCodeInfo_Annotation::_internal_set_source_file(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ source_file_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() {
_has_bits_[0] |= 0x00000001u;
- return source_file_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return source_file_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* GeneratedCodeInfo_Annotation::release_source_file() {
// @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
@@ -14541,10 +14462,10 @@ inline TProtoStringType* GeneratedCodeInfo_Annotation::release_source_file() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = source_file_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = source_file_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (source_file_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (source_file_.IsDefault()) {
+ source_file_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -14555,11 +14476,10 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(TProtoString
} else {
_has_bits_[0] &= ~0x00000001u;
}
- source_file_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), source_file,
- GetArenaForAllocation());
+ source_file_.SetAllocated(source_file, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (source_file_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (source_file_.IsDefault()) {
+ source_file_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.proto b/contrib/libs/protobuf/src/google/protobuf/descriptor.proto
index 156e410ae1..49ec6534b1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.proto
@@ -199,7 +199,6 @@ message FieldDescriptorProto {
// For booleans, "true" or "false".
// For strings, contains the default text contents (not escaped in any way).
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
- // TODO(kenton): Base-64 encode?
optional string default_value = 7;
// If set, gives the index of a oneof in the containing type's oneof_decl
@@ -604,8 +603,19 @@ message FieldOptions {
// implementation must either *always* check its required fields, or *never*
// check its required fields, regardless of whether or not the message has
// been parsed.
+ //
+ // As of 2021, lazy does no correctness checks on the byte stream during
+ // parsing. This may lead to crashes if and when an invalid byte stream is
+ // finally parsed upon access.
+ //
+ // TODO(b/211906113): Enable validation on lazy fields.
optional bool lazy = 5 [default = false];
+ // unverified_lazy does no correctness checks on the byte stream. This should
+ // only be used where lazy with verification is prohibitive for performance
+ // reasons.
+ optional bool unverified_lazy = 15 [default = false];
+
// Is this field deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for accessors, or it will be completely ignored; in the very least, this
@@ -803,8 +813,8 @@ message SourceCodeInfo {
// location.
//
// Each element is a field number or an index. They form a path from
- // the root FileDescriptorProto to the place where the definition. For
- // example, this path:
+ // the root FileDescriptorProto to the place where the definition occurs.
+ // For example, this path:
// [ 4, 3, 2, 7, 1 ]
// refers to:
// file.message_type(3) // 4, 3
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc
index 4b05990240..e221b3c6c9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc
@@ -34,6 +34,7 @@
#include <google/protobuf/descriptor_database.h>
+#include <algorithm>
#include <set>
#include <google/protobuf/descriptor.pb.h>
@@ -1027,5 +1028,21 @@ bool MergedDescriptorDatabase::FindAllExtensionNumbers(
}
+bool MergedDescriptorDatabase::FindAllFileNames(
+ std::vector<TProtoStringType>* output) {
+ bool implemented = false;
+ for (DescriptorDatabase* source : sources_) {
+ std::vector<TProtoStringType> source_output;
+ if (source->FindAllFileNames(&source_output)) {
+ output->reserve(output->size() + source_output.size());
+ for (auto& source : source_output) {
+ output->push_back(std::move(source));
+ }
+ implemented = true;
+ }
+ }
+ return implemented;
+}
+
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h
index 9c9941031d..a1ff1cc63f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h
@@ -37,13 +37,16 @@
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
#define GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
+
#include <map>
#include <string>
#include <utility>
#include <vector>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -378,6 +381,10 @@ class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
std::vector<int>* output) override;
+ // This function is best-effort. Returns true if at least one underlying
+ // DescriptorDatabase returns true.
+ bool FindAllFileNames(std::vector<TProtoStringType>* output) override;
+
private:
std::vector<DescriptorDatabase*> sources_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
diff --git a/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc b/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc
index a88ff6686d..d2cd15f04a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc
@@ -16,24 +16,28 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr Duration::Duration(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR Duration::Duration(
+ ::_pbi::ConstantInitialized)
: seconds_(arc_i64{0})
, nanos_(0){}
struct DurationDefaultTypeInternal {
- constexpr DurationDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DurationDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~DurationDefaultTypeInternal() {}
union {
Duration _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DurationDefaultTypeInternal _Duration_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DurationDefaultTypeInternal _Duration_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fduration_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fduration_2eproto[1];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -45,12 +49,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] PROTO
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, seconds_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, nanos_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Duration)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Duration_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Duration_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -61,19 +65,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROT
"uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo"
"gle.Protobuf.WellKnownTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = {
- false, false, 235, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto",
- &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, nullptr, 0, 1,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = {
+ false, false, 235, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto,
+ "google/protobuf/duration.proto",
+ &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, nullptr, 0, 1,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fduration_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fduration_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fduration_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fduration_2eproto(&descriptor_table_google_2fprotobuf_2fduration_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fduration_2eproto(&descriptor_table_google_2fprotobuf_2fduration_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -86,9 +92,6 @@ Duration::Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Duration)
}
Duration::Duration(const Duration& from)
@@ -109,21 +112,17 @@ inline void Duration::SharedCtor() {
Duration::~Duration() {
// @@protoc_insertion_point(destructor:google.protobuf.Duration)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Duration::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void Duration::ArenaDtor(void* object) {
- Duration* _this = reinterpret_cast< Duration* >(object);
- (void)_this;
-}
-void Duration::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Duration::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -140,11 +139,11 @@ void Duration::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Duration::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Duration::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int64 seconds = 1;
case 1:
@@ -194,17 +193,17 @@ uint8_t* Duration::_InternalSerialize(
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target);
+ target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target);
}
// int32 nanos = 2;
if (this->_internal_nanos() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -221,12 +220,12 @@ size_t Duration::ByteSizeLong() const {
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_seconds());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seconds());
}
// int32 nanos = 2;
if (this->_internal_nanos() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_nanos());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_nanos());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -283,7 +282,7 @@ void Duration::InternalSwap(Duration* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Duration::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fduration_2eproto_getter, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once,
file_level_metadata_google_2fprotobuf_2fduration_2eproto[0]);
}
@@ -291,7 +290,8 @@ void Duration::InternalSwap(Duration* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Duration* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Duration >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Duration*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Duration >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Duration >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/duration.pb.h b/contrib/libs/protobuf/src/google/protobuf/duration.pb.h
index a306c7c946..553046eeba 100644
--- a/contrib/libs/protobuf/src/google/protobuf/duration.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/duration.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto;
@@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Duration final :
public:
inline Duration() : Duration(nullptr) {}
~Duration() override;
- explicit constexpr Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Duration(const Duration& from);
Duration(Duration&& from) noexcept
@@ -172,9 +163,6 @@ class PROTOBUF_EXPORT Duration final :
protected:
explicit Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
diff --git a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc
index b68ecc8d9b..0a0f758df2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc
@@ -70,8 +70,8 @@
#include <new>
#include <unordered_map>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/unknown_field_set.h>
@@ -85,7 +85,8 @@
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/wire_format.h>
-#include <google/protobuf/port_def.inc> // NOLINT
+// Must be included last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -100,14 +101,6 @@ using internal::ArenaStringPtr;
// ===================================================================
// Some helper tables and functions...
-class DynamicMessageReflectionHelper {
- public:
- static bool IsLazyField(const Reflection* reflection,
- const FieldDescriptor* field) {
- return reflection->IsLazyField(field);
- }
-};
-
namespace {
bool IsMapFieldInApi(const FieldDescriptor* field) { return field->is_map(); }
@@ -232,7 +225,7 @@ class DynamicMessage : public Message {
// This should only be used by GetPrototypeNoLock() to avoid dead lock.
DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, bool lock_factory);
- ~DynamicMessage();
+ ~DynamicMessage() override;
// Called on the prototype after construction to initialize message fields.
// Cross linking the default instances allows for fast reflection access of
@@ -277,13 +270,6 @@ class DynamicMessage : public Message {
bool is_prototype() const;
- inline int OffsetValue(int v, FieldDescriptor::Type type) const {
- if (type == FieldDescriptor::TYPE_MESSAGE) {
- return v & ~0x1u;
- }
- return v;
- }
-
inline void* OffsetToPointer(int offset) {
return reinterpret_cast<uint8_t*>(this) + offset;
}
@@ -355,23 +341,20 @@ DynamicMessage::DynamicMessage(DynamicMessageFactory::TypeInfo* type_info,
}
inline void* DynamicMessage::MutableRaw(int i) {
- return OffsetToPointer(
- OffsetValue(type_info_->offsets[i], type_info_->type->field(i)->type()));
+ return OffsetToPointer(type_info_->offsets[i]);
}
-void* DynamicMessage::MutableExtensionsRaw() {
+inline void* DynamicMessage::MutableExtensionsRaw() {
return OffsetToPointer(type_info_->extensions_offset);
}
-void* DynamicMessage::MutableWeakFieldMapRaw() {
+inline void* DynamicMessage::MutableWeakFieldMapRaw() {
return OffsetToPointer(type_info_->weak_field_map_offset);
}
-void* DynamicMessage::MutableOneofCaseRaw(int i) {
+inline void* DynamicMessage::MutableOneofCaseRaw(int i) {
return OffsetToPointer(type_info_->oneof_case_offset + sizeof(arc_ui32) * i);
}
-void* DynamicMessage::MutableOneofFieldRaw(const FieldDescriptor* f) {
- return OffsetToPointer(
- OffsetValue(type_info_->offsets[type_info_->type->field_count() +
- f->containing_oneof()->index()],
- f->type()));
+inline void* DynamicMessage::MutableOneofFieldRaw(const FieldDescriptor* f) {
+ return OffsetToPointer(type_info_->offsets[type_info_->type->field_count() +
+ f->containing_oneof()->index()]);
}
void DynamicMessage::SharedCtor(bool lock_factory) {
@@ -433,12 +416,8 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING:
if (!field->is_repeated()) {
- const TProtoStringType* default_value =
- field->default_value_string().empty()
- ? &internal::GetEmptyStringAlreadyInited()
- : nullptr;
ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr();
- asp->UnsafeSetDefault(default_value);
+ asp->InitDefault();
} else {
new (field_ptr)
RepeatedPtrField<TProtoStringType>(GetArenaForAllocation());
@@ -539,13 +518,7 @@ DynamicMessage::~DynamicMessage() {
switch (field->options().ctype()) {
default:
case FieldOptions::STRING: {
- // Oneof string fields are never set as a default instance.
- // We just need to pass some arbitrary default string to make it
- // work. This allows us to not have the real default accessible
- // from reflection.
- const TProtoStringType* default_value = nullptr;
- reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
- default_value, nullptr);
+ reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy();
break;
}
}
@@ -599,13 +572,7 @@ DynamicMessage::~DynamicMessage() {
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
- const TProtoStringType* default_value =
- reinterpret_cast<const ArenaStringPtr*>(
- type_info_->prototype->OffsetToPointer(
- type_info_->offsets[i]))
- ->GetPointer();
- reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(default_value,
- nullptr);
+ reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy();
break;
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h
index fa188aaf87..8de3681012 100644
--- a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h
+++ b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h
@@ -38,14 +38,15 @@
#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
+
#include <algorithm>
#include <memory>
#include <unordered_map>
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/message.h>
#include <google/protobuf/stubs/mutex.h>
+#include <google/protobuf/message.h>
#include <google/protobuf/reflection.h>
#include <google/protobuf/repeated_field.h>
@@ -53,6 +54,7 @@
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -94,7 +96,7 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
// the zero-arg constructor.
DynamicMessageFactory(const DescriptorPool* pool);
- ~DynamicMessageFactory();
+ ~DynamicMessageFactory() override;
// Call this to tell the DynamicMessageFactory that if it is given a
// Descriptor d for which:
diff --git a/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc b/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc
index 841e143a1d..3db5dbaab8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc
@@ -16,22 +16,26 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr Empty::Empty(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){}
+PROTOBUF_CONSTEXPR Empty::Empty(
+ ::_pbi::ConstantInitialized){}
struct EmptyDefaultTypeInternal {
- constexpr EmptyDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EmptyDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EmptyDefaultTypeInternal() {}
union {
Empty _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EmptyDefaultTypeInternal _Empty_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EmptyDefaultTypeInternal _Empty_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fempty_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fempty_2eproto[1];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -41,12 +45,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] PROTOBUF
~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Empty)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -56,19 +60,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBU
"/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P"
"rotobuf.WellKnownTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = {
- false, false, 190, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto",
- &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, nullptr, 0, 1,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = {
+ false, false, 190, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto,
+ "google/protobuf/empty.proto",
+ &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, nullptr, 0, 1,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fempty_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fempty_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fempty_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fempty_2eproto(&descriptor_table_google_2fprotobuf_2fempty_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fempty_2eproto(&descriptor_table_google_2fprotobuf_2fempty_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -105,7 +111,7 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Empty::GetClassData() const {
::PROTOBUF_NAMESPACE_ID::Metadata Empty::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fempty_2eproto_getter, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once,
file_level_metadata_google_2fprotobuf_2fempty_2eproto[0]);
}
@@ -113,7 +119,8 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Empty::GetClassData() const {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Empty* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Empty >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Empty*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Empty >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Empty >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/empty.pb.h b/contrib/libs/protobuf/src/google/protobuf/empty.pb.h
index 5e81d7e9ef..36f15c557f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/empty.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/empty.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -24,7 +24,6 @@
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_bases.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -43,14 +42,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto;
@@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Empty final :
public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
public:
inline Empty() : Empty(nullptr) {}
- explicit constexpr Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Empty(const Empty& from);
Empty(Empty&& from) noexcept
@@ -160,7 +151,6 @@ class PROTOBUF_EXPORT Empty final :
protected:
explicit Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
public:
static const ClassData _class_data_;
@@ -179,7 +169,6 @@ class PROTOBUF_EXPORT Empty final :
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
- mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_google_2fprotobuf_2fempty_2eproto;
};
// ===================================================================
diff --git a/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h b/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h
index 69de60f76d..329b2db291 100644
--- a/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h
+++ b/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h
@@ -59,7 +59,7 @@ namespace internal {
// 3. Call get() and get_mutable() only if the object is initialized.
// 4. Call Destruct() only if the object is initialized.
// After the call, the object becomes uninitialized.
-template <typename T>
+template <typename T, size_t min_align = 1>
class ExplicitlyConstructed {
public:
void DefaultConstruct() { new (&union_) T(); }
@@ -76,12 +76,18 @@ class ExplicitlyConstructed {
private:
union AlignedUnion {
- alignas(T) char space[sizeof(T)];
+ alignas(min_align > alignof(T) ? min_align
+ : alignof(T)) char space[sizeof(T)];
arc_i64 align_to_int64;
void* align_to_ptr;
} union_;
};
+// ArenaStringPtr compatible explicitly constructed string type.
+// This empty string type is aligned with a minimum alignment of 8 bytes
+// which is the minimum requirement of ArenaStringPtr
+using ExplicitlyConstructedArenaString = ExplicitlyConstructed<TProtoStringType, 8>;
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/extension_set.cc b/contrib/libs/protobuf/src/google/protobuf/extension_set.cc
index af851b2a45..67f4c677de 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set.cc
@@ -39,13 +39,14 @@
#include <utility>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/extension_set_inl.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/extension_set_inl.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/metadata_lite.h>
+#include <google/protobuf/parse_context.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/hash.h>
@@ -152,11 +153,13 @@ bool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) {
void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
- bool is_packed) {
+ bool is_packed,
+ LazyEagerVerifyFnType verify_func) {
GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_ENUM);
GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE);
GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_GROUP);
- ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
+ ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
+ verify_func);
Register(info);
}
@@ -178,7 +181,7 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee,
bool is_repeated, bool is_packed,
EnumValidityFunc* is_valid) {
GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
- ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
+ ExtensionInfo info(extendee, number, type, is_repeated, is_packed, nullptr);
info.enum_validity_check.func = CallNoArgValidityFunc;
// See comment in CallNoArgValidityFunc() about why we use a c-style cast.
info.enum_validity_check.arg = (void*)is_valid;
@@ -188,10 +191,12 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee,
void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee,
int number, FieldType type,
bool is_repeated, bool is_packed,
- const MessageLite* prototype) {
+ const MessageLite* prototype,
+ LazyEagerVerifyFnType verify_func) {
GOOGLE_CHECK(type == WireFormatLite::TYPE_MESSAGE ||
type == WireFormatLite::TYPE_GROUP);
- ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
+ ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
+ verify_func);
info.message_info = {prototype};
Register(info);
}
@@ -221,18 +226,14 @@ ExtensionSet::~ExtensionSet() {
void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat,
uint16_t flat_capacity) {
-#ifdef __cpp_sized_deallocation
// Arena::CreateArray already requires a trivially destructible type, but
// ensure this constraint is not violated in the future.
static_assert(std::is_trivially_destructible<KeyValue>::value,
"CreateArray requires a trivially destructible type");
// A const-cast is needed, but this is safe as we are about to deallocate the
// array.
- ::operator delete[](const_cast<ExtensionSet::KeyValue*>(flat),
- sizeof(*flat) * flat_capacity);
-#else // !__cpp_sized_deallocation
- delete[] flat;
-#endif // !__cpp_sized_deallocation
+ internal::SizedArrayDelete(const_cast<KeyValue*>(flat),
+ sizeof(*flat) * flat_capacity);
}
// Defined in extension_set_heavy.cc.
@@ -1268,21 +1269,6 @@ bool ExtensionSet::FindExtensionInfoFromFieldNumber(
return expected_wire_type == wire_type;
}
-bool ExtensionSet::ParseField(arc_ui32 tag, io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- FieldSkipper* field_skipper) {
- int number;
- bool was_packed_on_wire;
- ExtensionInfo extension;
- if (!FindExtensionInfoFromTag(tag, extension_finder, &number, &extension,
- &was_packed_on_wire)) {
- return field_skipper->SkipField(input, tag);
- } else {
- return ParseFieldWithExtensionInfo(number, was_packed_on_wire, extension,
- input, field_skipper);
- }
-}
-
const char* ExtensionSet::ParseField(arc_ui64 tag, const char* ptr,
const MessageLite* extendee,
internal::InternalMetadata* metadata,
@@ -1307,249 +1293,6 @@ const char* ExtensionSet::ParseMessageSetItem(
metadata, ctx);
}
-bool ExtensionSet::ParseFieldWithExtensionInfo(int number,
- bool was_packed_on_wire,
- const ExtensionInfo& extension,
- io::CodedInputStream* input,
- FieldSkipper* field_skipper) {
- // Explicitly not read extension.is_packed, instead check whether the field
- // was encoded in packed form on the wire.
- if (was_packed_on_wire) {
- arc_ui32 size;
- if (!input->ReadVarint32(&size)) return false;
- io::CodedInputStream::Limit limit = input->PushLimit(size);
-
- switch (extension.type) {
-#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \
- case WireFormatLite::TYPE_##UPPERCASE: \
- while (input->BytesUntilLimit() > 0) { \
- CPP_LOWERCASE value; \
- if (!WireFormatLite::ReadPrimitive<CPP_LOWERCASE, \
- WireFormatLite::TYPE_##UPPERCASE>( \
- input, &value)) \
- return false; \
- Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
- extension.is_packed, value, extension.descriptor); \
- } \
- break
-
- HANDLE_TYPE(INT32, Int32, arc_i32);
- HANDLE_TYPE(INT64, Int64, arc_i64);
- HANDLE_TYPE(UINT32, UInt32, arc_ui32);
- HANDLE_TYPE(UINT64, UInt64, arc_ui64);
- HANDLE_TYPE(SINT32, Int32, arc_i32);
- HANDLE_TYPE(SINT64, Int64, arc_i64);
- HANDLE_TYPE(FIXED32, UInt32, arc_ui32);
- HANDLE_TYPE(FIXED64, UInt64, arc_ui64);
- HANDLE_TYPE(SFIXED32, Int32, arc_i32);
- HANDLE_TYPE(SFIXED64, Int64, arc_i64);
- HANDLE_TYPE(FLOAT, Float, float);
- HANDLE_TYPE(DOUBLE, Double, double);
- HANDLE_TYPE(BOOL, Bool, bool);
-#undef HANDLE_TYPE
-
- case WireFormatLite::TYPE_ENUM:
- while (input->BytesUntilLimit() > 0) {
- int value;
- if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
- input, &value))
- return false;
- if (extension.enum_validity_check.func(
- extension.enum_validity_check.arg, value)) {
- AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed,
- value, extension.descriptor);
- } else {
- // Invalid value. Treat as unknown.
- field_skipper->SkipUnknownEnum(number, value);
- }
- }
- break;
-
- case WireFormatLite::TYPE_STRING:
- case WireFormatLite::TYPE_BYTES:
- case WireFormatLite::TYPE_GROUP:
- case WireFormatLite::TYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
- break;
- }
-
- input->PopLimit(limit);
- } else {
- switch (extension.type) {
-#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \
- case WireFormatLite::TYPE_##UPPERCASE: { \
- CPP_LOWERCASE value; \
- if (!WireFormatLite::ReadPrimitive<CPP_LOWERCASE, \
- WireFormatLite::TYPE_##UPPERCASE>( \
- input, &value)) \
- return false; \
- if (extension.is_repeated) { \
- Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
- extension.is_packed, value, extension.descriptor); \
- } else { \
- Set##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, value, \
- extension.descriptor); \
- } \
- } break
-
- HANDLE_TYPE(INT32, Int32, arc_i32);
- HANDLE_TYPE(INT64, Int64, arc_i64);
- HANDLE_TYPE(UINT32, UInt32, arc_ui32);
- HANDLE_TYPE(UINT64, UInt64, arc_ui64);
- HANDLE_TYPE(SINT32, Int32, arc_i32);
- HANDLE_TYPE(SINT64, Int64, arc_i64);
- HANDLE_TYPE(FIXED32, UInt32, arc_ui32);
- HANDLE_TYPE(FIXED64, UInt64, arc_ui64);
- HANDLE_TYPE(SFIXED32, Int32, arc_i32);
- HANDLE_TYPE(SFIXED64, Int64, arc_i64);
- HANDLE_TYPE(FLOAT, Float, float);
- HANDLE_TYPE(DOUBLE, Double, double);
- HANDLE_TYPE(BOOL, Bool, bool);
-#undef HANDLE_TYPE
-
- case WireFormatLite::TYPE_ENUM: {
- int value;
- if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
- input, &value))
- return false;
-
- if (!extension.enum_validity_check.func(
- extension.enum_validity_check.arg, value)) {
- // Invalid value. Treat as unknown.
- field_skipper->SkipUnknownEnum(number, value);
- } else if (extension.is_repeated) {
- AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed, value,
- extension.descriptor);
- } else {
- SetEnum(number, WireFormatLite::TYPE_ENUM, value,
- extension.descriptor);
- }
- break;
- }
-
- case WireFormatLite::TYPE_STRING: {
- TProtoStringType* value =
- extension.is_repeated
- ? AddString(number, WireFormatLite::TYPE_STRING,
- extension.descriptor)
- : MutableString(number, WireFormatLite::TYPE_STRING,
- extension.descriptor);
- if (!WireFormatLite::ReadString(input, value)) return false;
- break;
- }
-
- case WireFormatLite::TYPE_BYTES: {
- TProtoStringType* value =
- extension.is_repeated
- ? AddString(number, WireFormatLite::TYPE_BYTES,
- extension.descriptor)
- : MutableString(number, WireFormatLite::TYPE_BYTES,
- extension.descriptor);
- if (!WireFormatLite::ReadBytes(input, value)) return false;
- break;
- }
-
- case WireFormatLite::TYPE_GROUP: {
- MessageLite* value =
- extension.is_repeated
- ? AddMessage(number, WireFormatLite::TYPE_GROUP,
- *extension.message_info.prototype,
- extension.descriptor)
- : MutableMessage(number, WireFormatLite::TYPE_GROUP,
- *extension.message_info.prototype,
- extension.descriptor);
- if (!WireFormatLite::ReadGroup(number, input, value)) return false;
- break;
- }
-
- case WireFormatLite::TYPE_MESSAGE: {
- MessageLite* value =
- extension.is_repeated
- ? AddMessage(number, WireFormatLite::TYPE_MESSAGE,
- *extension.message_info.prototype,
- extension.descriptor)
- : MutableMessage(number, WireFormatLite::TYPE_MESSAGE,
- *extension.message_info.prototype,
- extension.descriptor);
- if (!WireFormatLite::ReadMessage(input, value)) return false;
- break;
- }
- }
- }
-
- return true;
-}
-
-bool ExtensionSet::ParseField(arc_ui32 tag, io::CodedInputStream* input,
- const MessageLite* extendee) {
- FieldSkipper skipper;
- GeneratedExtensionFinder finder(extendee);
- return ParseField(tag, input, &finder, &skipper);
-}
-
-bool ExtensionSet::ParseField(arc_ui32 tag, io::CodedInputStream* input,
- const MessageLite* extendee,
- io::CodedOutputStream* unknown_fields) {
- CodedOutputStreamFieldSkipper skipper(unknown_fields);
- GeneratedExtensionFinder finder(extendee);
- return ParseField(tag, input, &finder, &skipper);
-}
-
-bool ExtensionSet::ParseMessageSetLite(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- FieldSkipper* field_skipper) {
- while (true) {
- const arc_ui32 tag = input->ReadTag();
- switch (tag) {
- case 0:
- return true;
- case WireFormatLite::kMessageSetItemStartTag:
- if (!ParseMessageSetItemLite(input, extension_finder, field_skipper)) {
- return false;
- }
- break;
- default:
- if (!ParseField(tag, input, extension_finder, field_skipper)) {
- return false;
- }
- break;
- }
- }
-}
-
-bool ExtensionSet::ParseMessageSetItemLite(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- FieldSkipper* field_skipper) {
- struct MSLite {
- bool ParseField(int type_id, io::CodedInputStream* input) {
- return me->ParseField(
- WireFormatLite::WIRETYPE_LENGTH_DELIMITED + 8 * type_id, input,
- extension_finder, field_skipper);
- }
-
- bool SkipField(arc_ui32 tag, io::CodedInputStream* input) {
- return field_skipper->SkipField(input, tag);
- }
-
- ExtensionSet* me;
- ExtensionFinder* extension_finder;
- FieldSkipper* field_skipper;
- };
-
- return ParseMessageSetItemImpl(input,
- MSLite{this, extension_finder, field_skipper});
-}
-
-bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,
- const MessageLite* extendee,
- TProtoStringType* unknown_fields) {
- io::StringOutputStream zcis(unknown_fields);
- io::CodedOutputStream output(&zcis);
- CodedOutputStreamFieldSkipper skipper(&output);
- GeneratedExtensionFinder finder(extendee);
- return ParseMessageSetLite(input, &finder, &skipper);
-}
-
uint8_t* ExtensionSet::_InternalSerializeImpl(
const MessageLite* extendee, int start_field_number, int end_field_number,
uint8_t* target, io::EpsCopyOutputStream* stream) const {
@@ -2093,18 +1836,20 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray(
HANDLE_TYPE(STRING, String, string);
HANDLE_TYPE(BYTES, Bytes, string);
#undef HANDLE_TYPE
-#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
- case WireFormatLite::TYPE_##UPPERCASE: \
- for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
- target = stream->EnsureSpace(target); \
- target = WireFormatLite::InternalWrite##CAMELCASE( \
- number, repeated_##LOWERCASE##_value->Get(i), target, stream); \
- } \
- break
-
- HANDLE_TYPE(GROUP, Group, message);
- HANDLE_TYPE(MESSAGE, Message, message);
-#undef HANDLE_TYPE
+ case WireFormatLite::TYPE_GROUP:
+ for (int i = 0; i < repeated_message_value->size(); i++) {
+ target = stream->EnsureSpace(target);
+ target = WireFormatLite::InternalWriteGroup(
+ number, repeated_message_value->Get(i), target, stream);
+ }
+ break;
+ case WireFormatLite::TYPE_MESSAGE:
+ for (int i = 0; i < repeated_message_value->size(); i++) {
+ auto& msg = repeated_message_value->Get(i);
+ target = WireFormatLite::InternalWriteMessage(
+ number, msg, msg.GetCachedSize(), target, stream);
+ }
+ break;
}
}
} else if (!is_cleared) {
@@ -2150,9 +1895,9 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray(
target = lazymessage_value->WriteMessageToArray(prototype, number,
target, stream);
} else {
- target = stream->EnsureSpace(target);
- target = WireFormatLite::InternalWriteMessage(number, *message_value,
- target, stream);
+ target = WireFormatLite::InternalWriteMessage(
+ number, *message_value, message_value->GetCachedSize(), target,
+ stream);
}
break;
}
@@ -2201,8 +1946,8 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(
prototype, WireFormatLite::kMessageSetMessageNumber, target, stream);
} else {
target = WireFormatLite::InternalWriteMessage(
- WireFormatLite::kMessageSetMessageNumber, *message_value, target,
- stream);
+ WireFormatLite::kMessageSetMessageNumber, *message_value,
+ message_value->GetCachedSize(), target, stream);
}
// End group.
target = stream->EnsureSpace(target);
@@ -2247,6 +1992,15 @@ size_t ExtensionSet::MessageSetByteSize() const {
return total_size;
}
+LazyEagerVerifyFnType FindExtensionLazyEagerVerifyFn(
+ const MessageLite* extendee, int number) {
+ const ExtensionInfo* registered = FindRegisteredExtension(extendee, number);
+ if (registered != nullptr) {
+ return registered->lazy_eager_verify_func;
+ }
+ return nullptr;
+}
+
} // namespace internal
} // namespace protobuf
diff --git a/contrib/libs/protobuf/src/google/protobuf/extension_set.h b/contrib/libs/protobuf/src/google/protobuf/extension_set.h
index 1ea91bfa32..327705631d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set.h
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set.h
@@ -38,6 +38,7 @@
#ifndef GOOGLE_PROTOBUF_EXTENSION_SET_H__
#define GOOGLE_PROTOBUF_EXTENSION_SET_H__
+
#include <algorithm>
#include <cassert>
#include <map>
@@ -47,9 +48,9 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/wire_format_lite.h>
@@ -74,6 +75,7 @@ class Reflection; // message.h
class UnknownFieldSet; // unknown_field_set.h
namespace internal {
class FieldSkipper; // wire_format_lite.h
+enum class LazyVerifyOption;
} // namespace internal
} // namespace protobuf
} // namespace google
@@ -103,13 +105,15 @@ typedef bool EnumValidityFuncWithArg(const void* arg, int number);
struct ExtensionInfo {
constexpr ExtensionInfo() : enum_validity_check() {}
constexpr ExtensionInfo(const MessageLite* extendee, int param_number,
- FieldType type_param, bool isrepeated, bool ispacked)
+ FieldType type_param, bool isrepeated, bool ispacked,
+ LazyEagerVerifyFnType verify_func)
: message(extendee),
number(param_number),
type(type_param),
is_repeated(isrepeated),
is_packed(ispacked),
- enum_validity_check() {}
+ enum_validity_check(),
+ lazy_eager_verify_func(verify_func) {}
const MessageLite* message = nullptr;
int number = 0;
@@ -136,6 +140,11 @@ struct ExtensionInfo {
// nullptr. Must not be nullptr if the descriptor for the extension does not
// live in the same pool as the descriptor for the containing type.
const FieldDescriptor* descriptor = nullptr;
+
+ // If this field is potentially lazy this function can be used as a cheap
+ // verification of the raw bytes.
+ // If nullptr then no verification is performed.
+ LazyEagerVerifyFnType lazy_eager_verify_func = nullptr;
};
// Abstract interface for an object which looks up extension definitions. Used
@@ -163,9 +172,6 @@ class PROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder {
const MessageLite* extendee_;
};
-// A FieldSkipper used for parsing MessageSet.
-class MessageSetFieldSkipper;
-
// Note: extension_set_heavy.cc defines DescriptorPoolExtensionFinder for
// finding extensions from a DescriptorPool.
@@ -184,6 +190,7 @@ class PROTOBUF_EXPORT ExtensionSet {
public:
constexpr ExtensionSet();
explicit ExtensionSet(Arena* arena);
+ ExtensionSet(ArenaInitialized, Arena* arena) : ExtensionSet(arena) {}
~ExtensionSet();
// These are called at startup by protocol-compiler-generated code to
@@ -193,14 +200,16 @@ class PROTOBUF_EXPORT ExtensionSet {
// methods do.
static void RegisterExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
- bool is_packed);
+ bool is_packed,
+ LazyEagerVerifyFnType verify_func);
static void RegisterEnumExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
bool is_packed, EnumValidityFunc* is_valid);
static void RegisterMessageExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
bool is_packed,
- const MessageLite* prototype);
+ const MessageLite* prototype,
+ LazyEagerVerifyFnType verify_func);
// =================================================================
@@ -368,9 +377,6 @@ class PROTOBUF_EXPORT ExtensionSet {
MessageLite* UnsafeArenaReleaseLast(int number);
void SwapElements(int number, int index1, int index2);
- // -----------------------------------------------------------------
- // TODO(kenton): Hardcore memory management accessors
-
// =================================================================
// convenience methods for implementing methods of Message
//
@@ -386,26 +392,6 @@ class PROTOBUF_EXPORT ExtensionSet {
void UnsafeShallowSwapExtension(ExtensionSet* other, int number);
bool IsInitialized() const;
- // Parses a single extension from the input. The input should start out
- // positioned immediately after the tag.
- bool ParseField(arc_ui32 tag, io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- FieldSkipper* field_skipper);
-
- // Specific versions for lite or full messages (constructs the appropriate
- // FieldSkipper automatically). |extendee| is the default
- // instance for the containing message; it is used only to look up the
- // extension by number. See RegisterExtension(), above. Unlike the other
- // methods of ExtensionSet, this only works for generated message types --
- // it looks up extensions registered using RegisterExtension().
- bool ParseField(arc_ui32 tag, io::CodedInputStream* input,
- const MessageLite* extendee);
- bool ParseField(arc_ui32 tag, io::CodedInputStream* input,
- const Message* extendee, UnknownFieldSet* unknown_fields);
- bool ParseField(arc_ui32 tag, io::CodedInputStream* input,
- const MessageLite* extendee,
- io::CodedOutputStream* unknown_fields);
-
// Lite parser
const char* ParseField(arc_ui64 tag, const char* ptr,
const MessageLite* extendee,
@@ -446,22 +432,6 @@ class PROTOBUF_EXPORT ExtensionSet {
return ptr;
}
- // Parse an entire message in MessageSet format. Such messages have no
- // fields, only extensions.
- bool ParseMessageSetLite(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- FieldSkipper* field_skipper);
- bool ParseMessageSet(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- MessageSetFieldSkipper* field_skipper);
-
- // Specific versions for lite or full messages (constructs the appropriate
- // FieldSkipper automatically).
- bool ParseMessageSet(io::CodedInputStream* input, const MessageLite* extendee,
- TProtoStringType* unknown_fields);
- bool ParseMessageSet(io::CodedInputStream* input, const Message* extendee,
- UnknownFieldSet* unknown_fields);
-
// Write all extension fields with field numbers in the range
// [start_field_number, end_field_number)
// to the output stream, using the cached sizes computed when ByteSize() was
@@ -601,10 +571,9 @@ class PROTOBUF_EXPORT ExtensionSet {
virtual void MergeFromMessage(const MessageLite& msg, Arena* arena) = 0;
virtual void Clear() = 0;
- virtual bool ReadMessage(const MessageLite& prototype,
- io::CodedInputStream* input) = 0;
virtual const char* _InternalParse(const Message& prototype, Arena* arena,
- const char* ptr, ParseContext* ctx) = 0;
+ LazyVerifyOption option, const char* ptr,
+ ParseContext* ctx) = 0;
virtual uint8_t* WriteMessageToArray(
const MessageLite* prototype, int number, uint8_t* target,
io::EpsCopyOutputStream* stream) const = 0;
@@ -799,22 +768,6 @@ class PROTOBUF_EXPORT ExtensionSet {
const MessageLite* GetPrototypeForLazyMessage(const MessageLite* extendee,
int number) const;
- // Parses a single extension from the input. The input should start out
- // positioned immediately after the wire tag. This method is called in
- // ParseField() after field number and was_packed_on_wire is extracted from
- // the wire tag and ExtensionInfo is found by the field number.
- bool ParseFieldWithExtensionInfo(int field_number, bool was_packed_on_wire,
- const ExtensionInfo& extension,
- io::CodedInputStream* input,
- FieldSkipper* field_skipper);
-
- // Like ParseField(), but this method may parse singular message extensions
- // lazily depending on the value of FLAGS_eagerly_parse_message_sets.
- bool ParseFieldMaybeLazily(int wire_type, int field_number,
- io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- MessageSetFieldSkipper* field_skipper);
-
// Returns true if extension is present and lazy.
bool HasLazy(int number) const;
@@ -827,17 +780,6 @@ class PROTOBUF_EXPORT ExtensionSet {
// it does not exist.
Extension* MaybeNewRepeatedExtension(const FieldDescriptor* descriptor);
- // Parse a single MessageSet item -- called just after the item group start
- // tag has been read.
- bool ParseMessageSetItemLite(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- FieldSkipper* field_skipper);
- // Parse a single MessageSet item -- called just after the item group start
- // tag has been read.
- bool ParseMessageSetItem(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- MessageSetFieldSkipper* field_skipper);
-
bool FindExtension(int wire_type, arc_ui32 field, const MessageLite* extendee,
const internal::ParseContext* /*ctx*/,
ExtensionInfo* extension, bool* was_packed_on_wire) {
@@ -1023,9 +965,10 @@ class PrimitiveTypeTraits {
static inline void Set(int number, FieldType field_type, ConstType value,
ExtensionSet* set);
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType verify_func) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
- type, false, is_packed);
+ type, false, is_packed, verify_func);
}
};
@@ -1056,9 +999,10 @@ class RepeatedPrimitiveTypeTraits {
static const RepeatedFieldType* GetDefaultRepeatedField();
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType verify_func) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
- type, true, is_packed);
+ type, true, is_packed, verify_func);
}
};
@@ -1178,9 +1122,10 @@ class PROTOBUF_EXPORT StringTypeTraits {
return set->MutableString(number, field_type, nullptr);
}
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType verify_func) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
- type, false, is_packed);
+ type, false, is_packed, verify_func);
}
};
@@ -1234,9 +1179,10 @@ class PROTOBUF_EXPORT RepeatedStringTypeTraits {
static const RepeatedFieldType* GetDefaultRepeatedField();
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType fn) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
- type, true, is_packed);
+ type, true, is_packed, fn);
}
private:
@@ -1271,7 +1217,8 @@ class EnumTypeTraits {
set->SetEnum(number, field_type, value, nullptr);
}
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType fn) {
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
type, false, is_packed, IsValid);
}
@@ -1336,7 +1283,8 @@ class RepeatedEnumTypeTraits {
RepeatedPrimitiveTypeTraits<arc_i32>::GetDefaultRepeatedField());
}
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType fn) {
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
type, true, is_packed, IsValid);
}
@@ -1359,7 +1307,8 @@ class MessageTypeTraits {
ConstType default_value) {
return static_cast<const Type&>(set.GetMessage(number, default_value));
}
- static inline std::nullptr_t GetPtr(int /* number */, const ExtensionSet& /* set */,
+ static inline std::nullptr_t GetPtr(int /* number */,
+ const ExtensionSet& /* set */,
ConstType /* default_value */) {
// Cannot be implemented because of forward declared messages?
return nullptr;
@@ -1390,13 +1339,18 @@ class MessageTypeTraits {
set->UnsafeArenaReleaseMessage(number, Type::default_instance()));
}
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType fn) {
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
number, type, false, is_packed,
- &Type::default_instance());
+ &Type::default_instance(), fn);
}
};
+// Used by WireFormatVerify to extract the verify function from the registry.
+LazyEagerVerifyFnType FindExtensionLazyEagerVerifyFn(
+ const MessageLite* extendee, int number);
+
// forward declaration.
class RepeatedMessageGenericTypeTraits;
@@ -1412,7 +1366,8 @@ class RepeatedMessageTypeTraits {
static inline ConstType Get(int number, const ExtensionSet& set, int index) {
return static_cast<const Type&>(set.GetRepeatedMessage(number, index));
}
- static inline std::nullptr_t GetPtr(int /* number */, const ExtensionSet& /* set */,
+ static inline std::nullptr_t GetPtr(int /* number */,
+ const ExtensionSet& /* set */,
int /* index */) {
// Cannot be implemented because of forward declared messages?
return nullptr;
@@ -1450,10 +1405,11 @@ class RepeatedMessageTypeTraits {
static const RepeatedFieldType* GetDefaultRepeatedField();
template <typename ExtendeeT>
- static void Register(int number, FieldType type, bool is_packed) {
+ static void Register(int number, FieldType type, bool is_packed,
+ LazyEagerVerifyFnType fn) {
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
number, type, true, is_packed,
- &Type::default_instance());
+ &Type::default_instance(), fn);
}
};
@@ -1490,17 +1446,19 @@ class ExtensionIdentifier {
typedef TypeTraitsType TypeTraits;
typedef ExtendeeType Extendee;
- ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value)
+ ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value,
+ LazyEagerVerifyFnType verify_func = nullptr)
: number_(number), default_value_(default_value) {
- Register(number);
+ Register(number, verify_func);
}
inline int number() const { return number_; }
typename TypeTraits::ConstType default_value() const {
return default_value_;
}
- static void Register(int number) {
- TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed);
+ static void Register(int number, LazyEagerVerifyFnType verify_func) {
+ TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed,
+ verify_func);
}
typename TypeTraits::ConstType const& default_value_ref() const {
diff --git a/contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc b/contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc
index 7bb4433d70..56d93bc95b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc
@@ -36,50 +36,28 @@
// lite library because they use descriptors or reflection.
#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/extension_set_inl.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/extension_set.h>
+#include <google/protobuf/extension_set_inl.h>
#include <google/protobuf/message.h>
#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
namespace internal {
-// A FieldSkipper used to store unknown MessageSet fields into UnknownFieldSet.
-class MessageSetFieldSkipper : public UnknownFieldSetFieldSkipper {
- public:
- explicit MessageSetFieldSkipper(UnknownFieldSet* unknown_fields)
- : UnknownFieldSetFieldSkipper(unknown_fields) {}
- ~MessageSetFieldSkipper() override {}
-
- virtual bool SkipMessageSetField(io::CodedInputStream* input,
- int field_number);
-};
-bool MessageSetFieldSkipper::SkipMessageSetField(io::CodedInputStream* input,
- int field_number) {
- arc_ui32 length;
- if (!input->ReadVarint32(&length)) return false;
- if (unknown_fields_ == nullptr) {
- return input->Skip(length);
- } else {
- return input->ReadString(unknown_fields_->AddLengthDelimited(field_number),
- length);
- }
-}
-
-
// Implementation of ExtensionFinder which finds extensions in a given
// DescriptorPool, using the given MessageFactory to construct sub-objects.
// This class is implemented in extension_set_heavy.cc.
@@ -376,36 +354,6 @@ const char* ExtensionSet::ParseMessageSetItem(
metadata, ctx);
}
-bool ExtensionSet::ParseField(arc_ui32 tag, io::CodedInputStream* input,
- const Message* containing_type,
- UnknownFieldSet* unknown_fields) {
- UnknownFieldSetFieldSkipper skipper(unknown_fields);
- if (input->GetExtensionPool() == nullptr) {
- GeneratedExtensionFinder finder(containing_type);
- return ParseField(tag, input, &finder, &skipper);
- } else {
- DescriptorPoolExtensionFinder finder(input->GetExtensionPool(),
- input->GetExtensionFactory(),
- containing_type->GetDescriptor());
- return ParseField(tag, input, &finder, &skipper);
- }
-}
-
-bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,
- const Message* containing_type,
- UnknownFieldSet* unknown_fields) {
- MessageSetFieldSkipper skipper(unknown_fields);
- if (input->GetExtensionPool() == nullptr) {
- GeneratedExtensionFinder finder(containing_type);
- return ParseMessageSet(input, &finder, &skipper);
- } else {
- DescriptorPoolExtensionFinder finder(input->GetExtensionPool(),
- input->GetExtensionFactory(),
- containing_type->GetDescriptor());
- return ParseMessageSet(input, &finder, &skipper);
- }
-}
-
int ExtensionSet::SpaceUsedExcludingSelf() const {
return internal::FromIntSize(SpaceUsedExcludingSelfLong());
}
@@ -485,60 +433,6 @@ uint8_t* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
&stream);
}
-bool ExtensionSet::ParseFieldMaybeLazily(
- int wire_type, int field_number, io::CodedInputStream* input,
- ExtensionFinder* extension_finder, MessageSetFieldSkipper* field_skipper) {
- return ParseField(
- WireFormatLite::MakeTag(field_number,
- static_cast<WireFormatLite::WireType>(wire_type)),
- input, extension_finder, field_skipper);
-}
-
-bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- MessageSetFieldSkipper* field_skipper) {
- while (true) {
- const arc_ui32 tag = input->ReadTag();
- switch (tag) {
- case 0:
- return true;
- case WireFormatLite::kMessageSetItemStartTag:
- if (!ParseMessageSetItem(input, extension_finder, field_skipper)) {
- return false;
- }
- break;
- default:
- if (!ParseField(tag, input, extension_finder, field_skipper)) {
- return false;
- }
- break;
- }
- }
-}
-
-bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input,
- ExtensionFinder* extension_finder,
- MessageSetFieldSkipper* field_skipper) {
- struct MSFull {
- bool ParseField(int type_id, io::CodedInputStream* input) {
- return me->ParseFieldMaybeLazily(
- WireFormatLite::WIRETYPE_LENGTH_DELIMITED, type_id, input,
- extension_finder, field_skipper);
- }
-
- bool SkipField(arc_ui32 tag, io::CodedInputStream* input) {
- return field_skipper->SkipField(input, tag);
- }
-
- ExtensionSet* me;
- ExtensionFinder* extension_finder;
- MessageSetFieldSkipper* field_skipper;
- };
-
- return ParseMessageSetItemImpl(input,
- MSFull{this, extension_finder, field_skipper});
-}
-
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/extension_set_inl.h b/contrib/libs/protobuf/src/google/protobuf/extension_set_inl.h
index df05f610aa..b2bed39b72 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set_inl.h
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set_inl.h
@@ -31,9 +31,9 @@
#ifndef GOOGLE_PROTOBUF_EXTENSION_SET_INL_H__
#define GOOGLE_PROTOBUF_EXTENSION_SET_INL_H__
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/metadata_lite.h>
+#include <google/protobuf/parse_context.h>
namespace google {
namespace protobuf {
@@ -206,16 +206,21 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
const char* ptr, const Msg* extendee, internal::InternalMetadata* metadata,
internal::ParseContext* ctx) {
TProtoStringType payload;
- arc_ui32 type_id = 0;
- bool payload_read = false;
+ arc_ui32 type_id;
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
+ State state = State::kNoTag;
+
while (!ctx->Done(&ptr)) {
arc_ui32 tag = static_cast<uint8_t>(*ptr++);
if (tag == WireFormatLite::kMessageSetTypeIdTag) {
arc_ui64 tmp;
ptr = ParseBigVarint(ptr, &tmp);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- type_id = tmp;
- if (payload_read) {
+ if (state == State::kNoTag) {
+ type_id = tmp;
+ state = State::kHasType;
+ } else if (state == State::kHasPayload) {
+ type_id = tmp;
ExtensionInfo extension;
bool was_packed_on_wire;
if (!FindExtension(2, type_id, extendee, ctx, &extension,
@@ -241,20 +246,24 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) &&
tmp_ctx.EndedAtLimit());
}
- type_id = 0;
+ state = State::kDone;
}
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
- if (type_id != 0) {
+ if (state == State::kHasType) {
ptr = ParseFieldMaybeLazily(static_cast<arc_ui64>(type_id) * 8 + 2, ptr,
extendee, metadata, ctx);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
- type_id = 0;
+ state = State::kDone;
} else {
+ TProtoStringType tmp;
arc_i32 size = ReadSize(&ptr);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ptr = ctx->ReadString(ptr, size, &payload);
+ ptr = ctx->ReadString(ptr, size, &tmp);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- payload_read = true;
+ if (state == State::kNoTag) {
+ payload = std::move(tmp);
+ state = State::kHasPayload;
+ }
}
} else {
ptr = ReadTag(ptr - 1, &tag);
diff --git a/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc b/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc
index 25d027839e..a6e55fbb03 100644
--- a/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc
@@ -16,23 +16,27 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr FieldMask::FieldMask(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR FieldMask::FieldMask(
+ ::_pbi::ConstantInitialized)
: paths_(){}
struct FieldMaskDefaultTypeInternal {
- constexpr FieldMaskDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldMaskDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FieldMaskDefaultTypeInternal() {}
union {
FieldMask _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[1];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -43,12 +47,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] P
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, paths_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldMask)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -59,19 +63,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[]
"n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
".WellKnownTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = {
- false, false, 223, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto",
- &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, nullptr, 0, 1,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = {
+ false, false, 223, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto,
+ "google/protobuf/field_mask.proto",
+ &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, nullptr, 0, 1,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ffield_5fmask_2eproto(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ffield_5fmask_2eproto(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -85,9 +91,6 @@ FieldMask::FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
paths_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FieldMask)
}
FieldMask::FieldMask(const FieldMask& from)
@@ -102,21 +105,17 @@ inline void FieldMask::SharedCtor() {
FieldMask::~FieldMask() {
// @@protoc_insertion_point(destructor:google.protobuf.FieldMask)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FieldMask::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void FieldMask::ArenaDtor(void* object) {
- FieldMask* _this = reinterpret_cast< FieldMask* >(object);
- (void)_this;
-}
-void FieldMask::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FieldMask::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -131,11 +130,11 @@ void FieldMask::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FieldMask::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated string paths = 1;
case 1:
@@ -144,9 +143,9 @@ const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::
do {
ptr += 1;
auto str = _internal_add_paths();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldMask.paths"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.FieldMask.paths"));
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else
@@ -192,7 +191,7 @@ uint8_t* FieldMask::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -259,7 +258,7 @@ void FieldMask::InternalSwap(FieldMask* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FieldMask::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter, &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once,
file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[0]);
}
@@ -267,7 +266,8 @@ void FieldMask::InternalSwap(FieldMask* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldMask* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldMask >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldMask*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldMask >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldMask >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h b/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h
index fe0a7ae2db..4ac3bd4eee 100644
--- a/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
@@ -70,7 +61,7 @@ class PROTOBUF_EXPORT FieldMask final :
public:
inline FieldMask() : FieldMask(nullptr) {}
~FieldMask() override;
- explicit constexpr FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FieldMask(const FieldMask& from);
FieldMask(FieldMask&& from) noexcept
@@ -172,9 +163,6 @@ class PROTOBUF_EXPORT FieldMask final :
protected:
explicit FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h b/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h
index f20eba71b5..519ff242c8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h
@@ -39,16 +39,18 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
#define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
+
#include <string>
-#include <google/protobuf/generated_enum_util.h>
#include <google/protobuf/port.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/generated_enum_util.h>
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h b/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h
index d987a5e626..cd004478d8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h
@@ -31,11 +31,13 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
#define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
+
#include <type_traits>
-#include <google/protobuf/message_lite.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/message_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc
index 0679ab51a1..2122203074 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc
@@ -30,9 +30,9 @@
#include <google/protobuf/generated_message_bases.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format_lite.h>
@@ -52,8 +52,7 @@ void ZeroFieldsBase::Clear() {
}
ZeroFieldsBase::~ZeroFieldsBase() {
- if (GetArenaForAllocation() != nullptr) return;
- _internal_metadata_.Delete<UnknownFieldSet>();
+ (void)_internal_metadata_.DeleteReturnArena<UnknownFieldSet>();
}
size_t ZeroFieldsBase::ByteSizeLong() const {
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h
index 29ab66bd4f..ebd198417c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h
@@ -35,11 +35,11 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
+#include <google/protobuf/parse_context.h>
// Must come last:
#include <google/protobuf/port_def.inc>
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc
index dae6e8feae..1e424f134e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc
@@ -39,19 +39,18 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/stubs/mutex.h>
+#include <google/protobuf/stubs/casts.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/map_field_inl.h>
-#include <google/protobuf/stubs/mutex.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/stubs/strutil.h>
// clang-format off
@@ -258,7 +257,7 @@ bool Reflection::IsLazyExtension(const Message& message,
}
bool Reflection::IsLazilyVerifiedLazyField(const FieldDescriptor* field) const {
- return field->options().lazy();
+ return field->options().lazy() || field->options().unverified_lazy();
}
bool Reflection::IsEagerlyVerifiedLazyField(
@@ -279,6 +278,13 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
total_size += GetUnknownFields(message).SpaceUsedExcludingSelfLong();
+ // If this message owns an arena, add any unused space that's been allocated.
+ auto* arena = Arena::InternalGetArenaForAllocation(&message);
+ if (arena != nullptr && Arena::InternalGetOwningArena(&message) == nullptr &&
+ arena->InternalIsMessageOwnedArena()) {
+ total_size += arena->SpaceAllocated() - arena->SpaceUsed();
+ }
+
if (schema_.HasExtensionSet()) {
total_size += GetExtensionSet(message).SpaceUsedExcludingSelfLong();
}
@@ -346,31 +352,26 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
case FieldDescriptor::CPPTYPE_STRING: {
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
- case FieldOptions::STRING: {
+ case FieldOptions::STRING:
if (IsInlined(field)) {
const TProtoStringType* ptr =
&GetField<InlinedStringField>(message, field).GetNoArena();
total_size += StringSpaceUsedExcludingSelfLong(*ptr);
- break;
- }
-
- const TProtoStringType* ptr =
- GetField<ArenaStringPtr>(message, field).GetPointer();
-
- // Initially, the string points to the default value stored
- // in the prototype. Only count the string if it has been
- // changed from the default value.
- // Except oneof fields, those never point to a default instance,
- // and there is no default instance to point to.
- if (schema_.InRealOneof(field) ||
- ptr != DefaultRaw<ArenaStringPtr>(field).GetPointer()) {
- // string fields are represented by just a pointer, so also
- // include sizeof(string) as well.
- total_size +=
- sizeof(*ptr) + StringSpaceUsedExcludingSelfLong(*ptr);
+ } else {
+ // Initially, the string points to the default value stored
+ // in the prototype. Only count the string if it has been
+ // changed from the default value.
+ // Except oneof fields, those never point to a default instance,
+ // and there is no default instance to point to.
+ const auto& str = GetField<ArenaStringPtr>(message, field);
+ if (!str.IsDefault() || schema_.InRealOneof(field)) {
+ // string fields are represented by just a pointer, so also
+ // include sizeof(string) as well.
+ total_size += sizeof(TProtoStringType) +
+ StringSpaceUsedExcludingSelfLong(str.Get());
+ }
}
break;
- }
}
break;
}
@@ -478,8 +479,7 @@ class SwapFieldHelper {
static void SwapStringField(const Reflection* r, Message* lhs, Message* rhs,
const FieldDescriptor* field);
- static void SwapArenaStringPtr(const TProtoStringType* default_ptr,
- ArenaStringPtr* lhs, Arena* lhs_arena,
+ static void SwapArenaStringPtr(ArenaStringPtr* lhs, Arena* lhs_arena,
ArenaStringPtr* rhs, Arena* rhs_arena);
template <bool unsafe_shallow_swap>
@@ -494,6 +494,10 @@ class SwapFieldHelper {
static void SwapMessage(const Reflection* r, Message* lhs, Arena* lhs_arena,
Message* rhs, Arena* rhs_arena,
const FieldDescriptor* field);
+
+ static void SwapNonMessageNonStringField(const Reflection* r, Message* lhs,
+ Message* rhs,
+ const FieldDescriptor* field);
};
template <bool unsafe_shallow_swap>
@@ -524,21 +528,26 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs,
Arena* rhs_arena = rhs->GetArenaForAllocation();
auto* lhs_string = r->MutableRaw<InlinedStringField>(lhs, field);
auto* rhs_string = r->MutableRaw<InlinedStringField>(rhs, field);
- const uint32 index = r->schema_.InlinedStringIndex(field);
- uint32* lhs_state = &r->MutableInlinedStringDonatedArray(lhs)[index / 32];
- uint32* rhs_state = &r->MutableInlinedStringDonatedArray(rhs)[index / 32];
- const uint32 mask = ~(static_cast<uint32>(1) << (index % 32));
+ arc_ui32 index = r->schema_.InlinedStringIndex(field);
+ GOOGLE_DCHECK_GT(index, 0);
+ arc_ui32* lhs_array = r->MutableInlinedStringDonatedArray(lhs);
+ arc_ui32* rhs_array = r->MutableInlinedStringDonatedArray(rhs);
+ arc_ui32* lhs_state = &lhs_array[index / 32];
+ arc_ui32* rhs_state = &rhs_array[index / 32];
+ bool lhs_arena_dtor_registered = (lhs_array[0] & 0x1u) == 0;
+ bool rhs_arena_dtor_registered = (rhs_array[0] & 0x1u) == 0;
+ const arc_ui32 mask = ~(static_cast<arc_ui32>(1) << (index % 32));
if (unsafe_shallow_swap || lhs_arena == rhs_arena) {
- lhs_string->Swap(rhs_string, /*default_value=*/nullptr, lhs_arena,
- r->IsInlinedStringDonated(*lhs, field),
- r->IsInlinedStringDonated(*rhs, field),
- /*donating_states=*/lhs_state, rhs_state, mask);
+ InlinedStringField::InternalSwap(lhs_string, lhs_arena,
+ lhs_arena_dtor_registered, lhs, rhs_string,
+ rhs_arena, rhs_arena_dtor_registered, rhs);
} else {
const TProtoStringType temp = lhs_string->Get();
- lhs_string->Set(nullptr, rhs_string->Get(), lhs_arena,
- r->IsInlinedStringDonated(*lhs, field), lhs_state, mask);
- rhs_string->Set(nullptr, temp, rhs_arena,
- r->IsInlinedStringDonated(*rhs, field), rhs_state, mask);
+ lhs_string->Set(rhs_string->Get(), lhs_arena,
+ r->IsInlinedStringDonated(*lhs, field), lhs_state, mask,
+ lhs);
+ rhs_string->Set(temp, rhs_arena, r->IsInlinedStringDonated(*rhs, field),
+ rhs_state, mask, rhs);
}
}
@@ -552,8 +561,7 @@ void SwapFieldHelper::SwapNonInlinedStrings(const Reflection* r, Message* lhs,
ArenaStringPtr::UnsafeShallowSwap(lhs_string, rhs_string);
} else {
SwapFieldHelper::SwapArenaStringPtr(
- r->DefaultRaw<ArenaStringPtr>(field).GetPointer(), //
- lhs_string, lhs->GetArenaForAllocation(), //
+ lhs_string, lhs->GetArenaForAllocation(), //
rhs_string, rhs->GetArenaForAllocation());
}
}
@@ -577,28 +585,27 @@ void SwapFieldHelper::SwapStringField(const Reflection* r, Message* lhs,
}
}
-void SwapFieldHelper::SwapArenaStringPtr(const TProtoStringType* default_ptr,
- ArenaStringPtr* lhs, Arena* lhs_arena,
+void SwapFieldHelper::SwapArenaStringPtr(ArenaStringPtr* lhs, Arena* lhs_arena,
ArenaStringPtr* rhs,
Arena* rhs_arena) {
if (lhs_arena == rhs_arena) {
- ArenaStringPtr::InternalSwap(default_ptr, lhs, lhs_arena, rhs, rhs_arena);
- } else if (lhs->IsDefault(default_ptr) && rhs->IsDefault(default_ptr)) {
+ ArenaStringPtr::InternalSwap(lhs, lhs_arena, rhs, rhs_arena);
+ } else if (lhs->IsDefault() && rhs->IsDefault()) {
// Nothing to do.
- } else if (lhs->IsDefault(default_ptr)) {
- lhs->Set(default_ptr, rhs->Get(), lhs_arena);
+ } else if (lhs->IsDefault()) {
+ lhs->Set(rhs->Get(), lhs_arena);
// rhs needs to be destroyed before overwritten.
- rhs->Destroy(default_ptr, rhs_arena);
- rhs->UnsafeSetDefault(default_ptr);
- } else if (rhs->IsDefault(default_ptr)) {
- rhs->Set(default_ptr, lhs->Get(), rhs_arena);
+ rhs->Destroy();
+ rhs->InitDefault();
+ } else if (rhs->IsDefault()) {
+ rhs->Set(lhs->Get(), rhs_arena);
// lhs needs to be destroyed before overwritten.
- lhs->Destroy(default_ptr, lhs_arena);
- lhs->UnsafeSetDefault(default_ptr);
+ lhs->Destroy();
+ lhs->InitDefault();
} else {
TProtoStringType temp = lhs->Get();
- lhs->Set(default_ptr, rhs->Get(), lhs_arena);
- rhs->Set(default_ptr, std::move(temp), rhs_arena);
+ lhs->Set(rhs->Get(), lhs_arena);
+ rhs->Set(std::move(temp), rhs_arena);
}
}
@@ -673,6 +680,30 @@ void SwapFieldHelper::SwapMessage(const Reflection* r, Message* lhs,
}
}
+void SwapFieldHelper::SwapNonMessageNonStringField(
+ const Reflection* r, Message* lhs, Message* rhs,
+ const FieldDescriptor* field) {
+ switch (field->cpp_type()) {
+#define SWAP_VALUES(CPPTYPE, TYPE) \
+ case FieldDescriptor::CPPTYPE_##CPPTYPE: \
+ std::swap(*r->MutableRaw<TYPE>(lhs, field), \
+ *r->MutableRaw<TYPE>(rhs, field)); \
+ break;
+
+ SWAP_VALUES(INT32, arc_i32);
+ SWAP_VALUES(INT64, arc_i64);
+ SWAP_VALUES(UINT32, arc_ui32);
+ SWAP_VALUES(UINT64, arc_ui64);
+ SWAP_VALUES(FLOAT, float);
+ SWAP_VALUES(DOUBLE, double);
+ SWAP_VALUES(BOOL, bool);
+ SWAP_VALUES(ENUM, int);
+#undef SWAP_VALUES
+ default:
+ GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
+ }
+}
+
} // namespace internal
void Reflection::SwapField(Message* message1, Message* message2,
@@ -709,21 +740,6 @@ void Reflection::SwapField(Message* message1, Message* message2,
}
} else {
switch (field->cpp_type()) {
-#define SWAP_VALUES(CPPTYPE, TYPE) \
- case FieldDescriptor::CPPTYPE_##CPPTYPE: \
- std::swap(*MutableRaw<TYPE>(message1, field), \
- *MutableRaw<TYPE>(message2, field)); \
- break;
-
- SWAP_VALUES(INT32, arc_i32);
- SWAP_VALUES(INT64, arc_i64);
- SWAP_VALUES(UINT32, arc_ui32);
- SWAP_VALUES(UINT64, arc_ui64);
- SWAP_VALUES(FLOAT, float);
- SWAP_VALUES(DOUBLE, double);
- SWAP_VALUES(BOOL, bool);
- SWAP_VALUES(ENUM, int);
-#undef SWAP_VALUES
case FieldDescriptor::CPPTYPE_MESSAGE:
internal::SwapFieldHelper::SwapMessageField<false>(this, message1,
message2, field);
@@ -733,9 +749,9 @@ void Reflection::SwapField(Message* message1, Message* message2,
internal::SwapFieldHelper::SwapStringField<false>(this, message1,
message2, field);
break;
-
default:
- GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
+ internal::SwapFieldHelper::SwapNonMessageNonStringField(
+ this, message1, message2, field);
}
}
}
@@ -750,7 +766,8 @@ void Reflection::UnsafeShallowSwapField(Message* message1, Message* message2,
internal::SwapFieldHelper::SwapStringField<true>(this, message1, message2,
field);
} else {
- SwapField(message1, message2, field);
+ internal::SwapFieldHelper::SwapNonMessageNonStringField(this, message1,
+ message2, field);
}
return;
}
@@ -877,8 +894,8 @@ void Reflection::SwapOneofField(Message* lhs, Message* rhs,
};
GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
- uint32 oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor);
- uint32 oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor);
+ arc_ui32 oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor);
+ arc_ui32 oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor);
LocalVarWrapper temp;
MessageWrapper lhs_wrapper, rhs_wrapper;
@@ -1030,6 +1047,13 @@ void Reflection::SwapFieldsImpl(
// may depend on the information in has bits.
if (!field->is_repeated()) {
SwapBit(message1, message2, field);
+ if (field->options().ctype() == FieldOptions::STRING &&
+ IsInlined(field)) {
+ GOOGLE_DCHECK(!unsafe_shallow_swap ||
+ message1->GetArenaForAllocation() ==
+ message2->GetArenaForAllocation());
+ SwapInlinedStringDonated(message1, message2, field);
+ }
}
}
}
@@ -1096,8 +1120,8 @@ void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const {
// Swapping bits need to happen after swapping fields, because the latter may
// depend on the has bit information.
if (schema_.HasHasbits()) {
- uint32* lhs_has_bits = MutableHasBits(lhs);
- uint32* rhs_has_bits = MutableHasBits(rhs);
+ arc_ui32* lhs_has_bits = MutableHasBits(lhs);
+ arc_ui32* rhs_has_bits = MutableHasBits(rhs);
int fields_with_has_bits = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -1115,6 +1139,32 @@ void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const {
}
}
+ if (schema_.HasInlinedString()) {
+ arc_ui32* lhs_donated_array = MutableInlinedStringDonatedArray(lhs);
+ arc_ui32* rhs_donated_array = MutableInlinedStringDonatedArray(rhs);
+ int inlined_string_count = 0;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (field->is_extension() || field->is_repeated() ||
+ schema_.InRealOneof(field) ||
+ field->options().ctype() != FieldOptions::STRING ||
+ !IsInlined(field)) {
+ continue;
+ }
+ inlined_string_count++;
+ }
+
+ int donated_array_size = inlined_string_count == 0
+ ? 0
+ // One extra bit for the arena dtor tracking.
+ : (inlined_string_count + 1 + 31) / 32;
+ GOOGLE_CHECK_EQ((lhs_donated_array[0] & 0x1u) == 0,
+ (rhs_donated_array[0] & 0x1u) == 0);
+ for (int i = 0; i < donated_array_size; i++) {
+ std::swap(lhs_donated_array[i], rhs_donated_array[i]);
+ }
+ }
+
if (schema_.HasExtensionSet()) {
MutableExtensionSet(lhs)->InternalSwap(MutableExtensionSet(rhs));
}
@@ -1205,20 +1255,17 @@ void Reflection::ClearField(Message* message,
case FieldDescriptor::CPPTYPE_STRING: {
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
- case FieldOptions::STRING: {
+ case FieldOptions::STRING:
if (IsInlined(field)) {
// Currently, string with default value can't be inlined. So we
// don't have to handle default value here.
MutableRaw<InlinedStringField>(message, field)->ClearToEmpty();
- break;
+ } else {
+ auto* str = MutableRaw<ArenaStringPtr>(message, field);
+ str->Destroy();
+ str->InitDefault();
}
- const TProtoStringType* default_ptr =
- DefaultRaw<ArenaStringPtr>(field).GetPointer();
- MutableRaw<ArenaStringPtr>(message, field)
- ->SetAllocated(default_ptr, nullptr,
- message->GetArenaForAllocation());
break;
- }
}
break;
}
@@ -1597,17 +1644,13 @@ TProtoStringType Reflection::GetString(const Message& message,
}
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
- case FieldOptions::STRING: {
+ case FieldOptions::STRING:
if (IsInlined(field)) {
return GetField<InlinedStringField>(message, field).GetNoArena();
+ } else {
+ const auto& str = GetField<ArenaStringPtr>(message, field);
+ return str.IsDefault() ? field->default_value_string() : str.Get();
}
-
- if (auto* value =
- GetField<ArenaStringPtr>(message, field).GetPointer()) {
- return *value;
- }
- return field->default_value_string();
- }
}
}
}
@@ -1626,17 +1669,13 @@ const TProtoStringType& Reflection::GetStringReference(const Message& message,
}
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
- case FieldOptions::STRING: {
+ case FieldOptions::STRING:
if (IsInlined(field)) {
return GetField<InlinedStringField>(message, field).GetNoArena();
+ } else {
+ const auto& str = GetField<ArenaStringPtr>(message, field);
+ return str.IsDefault() ? field->default_value_string() : str.Get();
}
-
- if (auto* value =
- GetField<ArenaStringPtr>(message, field).GetPointer()) {
- return *value;
- }
- return field->default_value_string();
- }
}
}
}
@@ -1654,12 +1693,14 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
case FieldOptions::STRING: {
if (IsInlined(field)) {
const arc_ui32 index = schema_.InlinedStringIndex(field);
+ GOOGLE_DCHECK_GT(index, 0);
arc_ui32* states =
&MutableInlinedStringDonatedArray(message)[index / 32];
arc_ui32 mask = ~(static_cast<arc_ui32>(1) << (index % 32));
MutableField<InlinedStringField>(message, field)
- ->Set(nullptr, value, message->GetArenaForAllocation(),
- IsInlinedStringDonated(*message, field), states, mask);
+ ->Set(value, message->GetArenaForAllocation(),
+ IsInlinedStringDonated(*message, field), states, mask,
+ message);
break;
}
@@ -1667,18 +1708,12 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
// We just need to pass some arbitrary default string to make it work.
// This allows us to not have the real default accessible from
// reflection.
- const TProtoStringType* default_ptr =
- schema_.InRealOneof(field)
- ? nullptr
- : DefaultRaw<ArenaStringPtr>(field).GetPointer();
if (schema_.InRealOneof(field) && !HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof());
- MutableField<ArenaStringPtr>(message, field)
- ->UnsafeSetDefault(default_ptr);
+ MutableField<ArenaStringPtr>(message, field)->InitDefault();
}
MutableField<ArenaStringPtr>(message, field)
- ->Set(default_ptr, std::move(value),
- message->GetArenaForAllocation());
+ ->Set(std::move(value), message->GetArenaForAllocation());
break;
}
}
@@ -2325,7 +2360,7 @@ bool Reflection::InsertOrLookupMapValue(Message* message,
MapValueRef* val) const {
USAGE_CHECK(IsMapFieldInApi(field), "InsertOrLookupMapValue",
"Field is not a map field.");
- val->SetType(field->message_type()->FindFieldByName("value")->cpp_type());
+ val->SetType(field->message_type()->map_value()->cpp_type());
return MutableRaw<MapFieldBase>(message, field)
->InsertOrLookupMapValue(key, val);
}
@@ -2335,7 +2370,7 @@ bool Reflection::LookupMapValue(const Message& message,
MapValueConstRef* val) const {
USAGE_CHECK(IsMapFieldInApi(field), "LookupMapValue",
"Field is not a map field.");
- val->SetType(field->message_type()->FindFieldByName("value")->cpp_type());
+ val->SetType(field->message_type()->map_value()->cpp_type());
return GetRaw<MapFieldBase>(message, field).LookupMapValue(key, val);
}
@@ -2458,7 +2493,7 @@ const arc_ui32* Reflection::GetInlinedStringDonatedArray(
}
arc_ui32* Reflection::MutableInlinedStringDonatedArray(Message* message) const {
- GOOGLE_DCHECK(schema_.HasHasbits());
+ GOOGLE_DCHECK(schema_.HasInlinedString());
return GetPointerAtOffset<arc_ui32>(message,
schema_.InlinedStringDonatedOffset());
}
@@ -2466,8 +2501,48 @@ arc_ui32* Reflection::MutableInlinedStringDonatedArray(Message* message) const {
// Simple accessors for manipulating _inlined_string_donated_;
bool Reflection::IsInlinedStringDonated(const Message& message,
const FieldDescriptor* field) const {
- return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message),
- schema_.InlinedStringIndex(field));
+ arc_ui32 index = schema_.InlinedStringIndex(field);
+ GOOGLE_DCHECK_GT(index, 0);
+ return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message), index);
+}
+
+inline void SetInlinedStringDonated(arc_ui32 index, arc_ui32* array) {
+ array[index / 32] |= (static_cast<arc_ui32>(1) << (index % 32));
+}
+
+inline void ClearInlinedStringDonated(arc_ui32 index, arc_ui32* array) {
+ array[index / 32] &= ~(static_cast<arc_ui32>(1) << (index % 32));
+}
+
+void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs,
+ const FieldDescriptor* field) const {
+ Arena* lhs_arena = lhs->GetArenaForAllocation();
+ Arena* rhs_arena = rhs->GetArenaForAllocation();
+ // If arenas differ, inined string fields are swapped by copying values.
+ // Donation status should not be swapped.
+ if (lhs_arena != rhs_arena) {
+ return;
+ }
+ bool lhs_donated = IsInlinedStringDonated(*lhs, field);
+ bool rhs_donated = IsInlinedStringDonated(*rhs, field);
+ if (lhs_donated == rhs_donated) {
+ return;
+ }
+ // If one is undonated, both must have already registered ArenaDtor.
+ arc_ui32* lhs_array = MutableInlinedStringDonatedArray(lhs);
+ arc_ui32* rhs_array = MutableInlinedStringDonatedArray(rhs);
+ GOOGLE_CHECK_EQ(lhs_array[0] & 0x1u, 0u);
+ GOOGLE_CHECK_EQ(rhs_array[0] & 0x1u, 0u);
+ // Swap donation status bit.
+ arc_ui32 index = schema_.InlinedStringIndex(field);
+ GOOGLE_DCHECK_GT(index, 0);
+ if (rhs_donated) {
+ SetInlinedStringDonated(index, lhs_array);
+ ClearInlinedStringDonated(index, rhs_array);
+ } else { // lhs_donated
+ ClearInlinedStringDonated(index, lhs_array);
+ SetInlinedStringDonated(index, rhs_array);
+ }
}
// Simple accessors for manipulating has_bits_.
@@ -2618,8 +2693,7 @@ void Reflection::ClearOneof(Message* message,
// We just need to pass some arbitrary default string to make it
// work. This allows us to not have the real default accessible
// from reflection.
- MutableField<ArenaStringPtr>(message, field)
- ->Destroy(nullptr, message->GetArenaForAllocation());
+ MutableField<ArenaStringPtr>(message, field)->Destroy();
break;
}
}
@@ -2632,6 +2706,7 @@ void Reflection::ClearOneof(Message* message,
default:
break;
}
+ } else {
}
*MutableOneofCase(message, oneof_descriptor) = 0;
@@ -3027,10 +3102,8 @@ void UnknownFieldSetSerializer(const uint8_t* base, arc_ui32 offset,
const void* ptr = base + offset;
const InternalMetadata* metadata = static_cast<const InternalMetadata*>(ptr);
if (metadata->have_unknown_fields()) {
- internal::WireFormat::SerializeUnknownFields(
- metadata->unknown_fields<UnknownFieldSet>(
- UnknownFieldSet::default_instance),
- output);
+ metadata->unknown_fields<UnknownFieldSet>(UnknownFieldSet::default_instance)
+ .SerializeToCodedStream(output);
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h
index 502881f876..a12b855176 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h
@@ -40,15 +40,17 @@
#include <string>
#include <vector>
+
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -137,8 +139,8 @@ struct ReflectionSchema {
arc_ui32 GetFieldOffset(const FieldDescriptor* field) const {
if (InRealOneof(field)) {
size_t offset =
- static_cast<size_t>(field->containing_type()->field_count() +
- field->containing_oneof()->index());
+ static_cast<size_t>(field->containing_type()->field_count()) +
+ field->containing_oneof()->index();
return OffsetValue(offsets_[offset], field->type());
} else {
return GetFieldOffsetNonOneof(field);
@@ -225,13 +227,6 @@ struct ReflectionSchema {
return false;
}
- // Returns true if the field's accessor is called by any external code (aka,
- // non proto library code).
- bool IsFieldUsed(const FieldDescriptor* field) const {
- (void)field;
- return true;
- }
-
bool IsFieldStripped(const FieldDescriptor* field) const {
(void)field;
return false;
@@ -269,9 +264,9 @@ struct ReflectionSchema {
if (type == FieldDescriptor::TYPE_MESSAGE ||
type == FieldDescriptor::TYPE_STRING ||
type == FieldDescriptor::TYPE_BYTES) {
- return v & 0x7FFFFFFEu;
+ return v & 0xFFFFFFFEu;
}
- return v & 0x7FFFFFFFu;
+ return v;
}
static bool Inlined(arc_ui32 v, FieldDescriptor::Type type) {
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.cc
deleted file mode 100644
index 8db7780c88..0000000000
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <google/protobuf/generated_message_table_driven.h>
-
-#include <type_traits>
-
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/generated_message_table_driven_lite.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/wire_format_lite.h>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-namespace {
-
-UnknownFieldSet* MutableUnknownFields(MessageLite* msg, arc_i64 arena_offset) {
- return Raw<InternalMetadata>(msg, arena_offset)
- ->mutable_unknown_fields<UnknownFieldSet>();
-}
-
-struct UnknownFieldHandler {
- // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?),
- // and conflating InternalMetaData into it, simplifying the template.
- static constexpr bool IsLite() { return false; }
-
- static bool Skip(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input, int tag) {
- GOOGLE_DCHECK(table.unknown_field_set);
-
- return WireFormat::SkipField(input, tag,
- MutableUnknownFields(msg, table.arena_offset));
- }
-
- static void Varint(MessageLite* msg, const ParseTable& table, int tag,
- int value) {
- GOOGLE_DCHECK(table.unknown_field_set);
-
- MutableUnknownFields(msg, table.arena_offset)
- ->AddVarint(WireFormatLite::GetTagFieldNumber(tag), value);
- }
-
- static bool ParseExtension(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input, int tag) {
- ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset);
- if (extensions == nullptr) {
- return false;
- }
-
- const Message* prototype =
- down_cast<const Message*>(table.default_instance());
-
- GOOGLE_DCHECK(prototype != nullptr);
- GOOGLE_DCHECK(table.unknown_field_set);
- UnknownFieldSet* unknown_fields =
- MutableUnknownFields(msg, table.arena_offset);
-
- return extensions->ParseField(tag, input, prototype, unknown_fields);
- }
-};
-
-} // namespace
-
-bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input) {
- return MergePartialFromCodedStreamImpl<UnknownFieldHandler>(msg, table,
- input);
-}
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.h
deleted file mode 100644
index 462fb28c25..0000000000
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.h
+++ /dev/null
@@ -1,351 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__
-#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__
-
-#include <google/protobuf/map.h>
-#include <google/protobuf/map_entry_lite.h>
-#include <google/protobuf/map_field_lite.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/wire_format_lite.h>
-
-// We require C++11 and Clang to use constexpr for variables, as GCC 4.8
-// requires constexpr to be consistent between declarations of variables
-// unnecessarily (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58541).
-// VS 2017 Update 3 also supports this usage of constexpr.
-#if defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1911)
-#define PROTOBUF_CONSTEXPR_VAR constexpr
-#else // !__clang__
-#define PROTOBUF_CONSTEXPR_VAR
-#endif // !_clang
-
-#ifdef SWIG
-#error "You cannot SWIG proto headers"
-#endif
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-// Processing-type masks.
-static constexpr const unsigned char kOneofMask = 0x40;
-static constexpr const unsigned char kRepeatedMask = 0x20;
-// Mask for the raw type: either a WireFormatLite::FieldType or one of the
-// ProcessingTypes below, without the oneof or repeated flag.
-static constexpr const unsigned char kTypeMask = 0x1f;
-
-// Wire type masks.
-static constexpr const unsigned char kNotPackedMask = 0x10;
-static constexpr const unsigned char kInvalidMask = 0x20;
-
-enum ProcessingTypes {
- TYPE_STRING_CORD = 19,
- TYPE_STRING_STRING_PIECE = 20,
- TYPE_BYTES_CORD = 21,
- TYPE_BYTES_STRING_PIECE = 22,
- TYPE_STRING_INLINED = 23,
- TYPE_BYTES_INLINED = 24,
- TYPE_MAP = 25,
-};
-
-static_assert(TYPE_MAP < kRepeatedMask, "Invalid enum");
-
-struct PROTOBUF_EXPORT FieldMetadata {
- arc_ui32 offset; // offset of this field in the struct
- arc_ui32 tag; // field * 8 + wire_type
- // byte offset * 8 + bit_offset;
- // if the high bit is set then this is the byte offset of the oneof_case
- // for this field.
- arc_ui32 has_offset;
- arc_ui32 type; // the type of this field.
- const void* ptr; // auxiliary data
-
- // From the serializer point of view each fundamental type can occur in
- // 4 different ways. For simplicity we treat all combinations as a cartesion
- // product although not all combinations are allowed.
- enum FieldTypeClass {
- kPresence,
- kNoPresence,
- kRepeated,
- kPacked,
- kOneOf,
- kNumTypeClasses // must be last enum
- };
- // C++ protobuf has 20 fundamental types, were we added Cord and StringPiece
- // and also distinguish the same types if they have different wire format.
- enum {
- kCordType = 19,
- kStringPieceType = 20,
- kInlinedType = 21,
- kNumTypes = 21,
- kSpecial = kNumTypes * kNumTypeClasses,
- };
-
- static int CalculateType(int fundamental_type, FieldTypeClass type_class);
-};
-
-// TODO(ckennelly): Add a static assertion to ensure that these masks do not
-// conflict with wiretypes.
-
-// ParseTableField is kept small to help simplify instructions for computing
-// offsets, as we will always need this information to parse a field.
-// Additional data, needed for some types, is stored in
-// AuxiliaryParseTableField.
-struct ParseTableField {
- arc_ui32 offset;
- // The presence_index ordinarily represents a has_bit index, but for fields
- // inside a oneof it represents the index in _oneof_case_.
- arc_ui32 presence_index;
- unsigned char normal_wiretype;
- unsigned char packed_wiretype;
-
- // processing_type is given by:
- // (FieldDescriptor->type() << 1) | FieldDescriptor->is_packed()
- unsigned char processing_type;
-
- unsigned char tag_size;
-};
-
-struct ParseTable;
-
-union AuxiliaryParseTableField {
- typedef bool (*EnumValidator)(int);
-
- // Enums
- struct enum_aux {
- EnumValidator validator;
- };
- enum_aux enums;
- // Group, messages
- struct message_aux {
- // ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents
- // the tables from being constructed as a constexpr. We use void to avoid
- // the cast.
- const void* default_message_void;
- const MessageLite* default_message() const {
- return static_cast<const MessageLite*>(default_message_void);
- }
- };
- message_aux messages;
- // Strings
- struct string_aux {
- const void* default_ptr;
- const char* field_name;
- };
- string_aux strings;
-
- struct map_aux {
- bool (*parse_map)(io::CodedInputStream*, void*);
- };
- map_aux maps;
-
- AuxiliaryParseTableField() = default;
- constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::enum_aux e)
- : enums(e) {}
- constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::message_aux m)
- : messages(m) {}
- constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::string_aux s)
- : strings(s) {}
- constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::map_aux m)
- : maps(m) {}
-};
-
-struct ParseTable {
- const ParseTableField* fields;
- const AuxiliaryParseTableField* aux;
- int max_field_number;
- // TODO(ckennelly): Do something with this padding.
-
- // TODO(ckennelly): Vet these for sign extension.
- arc_i64 has_bits_offset;
- arc_i64 oneof_case_offset;
- arc_i64 extension_offset;
- arc_i64 arena_offset;
-
- // ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents
- // the tables from being constructed as a constexpr. We use void to avoid
- // the cast.
- const void* default_instance_void;
- const MessageLite* default_instance() const {
- return static_cast<const MessageLite*>(default_instance_void);
- }
-
- bool unknown_field_set;
-};
-
-static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large");
-// The tables must be composed of POD components to ensure link-time
-// initialization.
-static_assert(std::is_standard_layout<ParseTableField>::value, "");
-static_assert(std::is_trivial<ParseTableField>::value, "");
-static_assert(std::is_standard_layout<AuxiliaryParseTableField>::value, "");
-static_assert(std::is_trivial<AuxiliaryParseTableField>::value, "");
-static_assert(
- std::is_standard_layout<AuxiliaryParseTableField::enum_aux>::value, "");
-static_assert(std::is_trivial<AuxiliaryParseTableField::enum_aux>::value, "");
-static_assert(
- std::is_standard_layout<AuxiliaryParseTableField::message_aux>::value, "");
-static_assert(std::is_trivial<AuxiliaryParseTableField::message_aux>::value,
- "");
-static_assert(
- std::is_standard_layout<AuxiliaryParseTableField::string_aux>::value, "");
-static_assert(std::is_trivial<AuxiliaryParseTableField::string_aux>::value, "");
-static_assert(std::is_standard_layout<ParseTable>::value, "");
-static_assert(std::is_trivial<ParseTable>::value, "");
-
-// TODO(ckennelly): Consolidate these implementations into a single one, using
-// dynamic dispatch to the appropriate unknown field handler.
-bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input);
-bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input);
-
-template <typename Entry>
-bool ParseMap(io::CodedInputStream* input, void* map_field) {
- typedef typename MapEntryToMapField<Entry>::MapFieldType MapFieldType;
- typedef Map<typename Entry::EntryKeyType, typename Entry::EntryValueType>
- MapType;
- typedef typename Entry::template Parser<MapFieldType, MapType> ParserType;
-
- ParserType parser(static_cast<MapFieldType*>(map_field));
- return WireFormatLite::ReadMessageNoVirtual(input, &parser);
-}
-
-struct SerializationTable {
- int num_fields;
- const FieldMetadata* field_table;
-};
-
-PROTOBUF_EXPORT void SerializeInternal(const uint8_t* base,
- const FieldMetadata* table,
- arc_i32 num_fields,
- io::CodedOutputStream* output);
-
-inline void TableSerialize(const MessageLite& msg,
- const SerializationTable* table,
- io::CodedOutputStream* output) {
- const FieldMetadata* field_table = table->field_table;
- int num_fields = table->num_fields - 1;
- const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg);
- // TODO(gerbens) This skips the first test if we could use the fast
- // array serialization path, we should make this
- // int cached_size =
- // *reinterpret_cast<const arc_i32*>(base + field_table->offset);
- // SerializeWithCachedSize(msg, field_table + 1, num_fields, cached_size, ...)
- // But we keep conformance with the old way for now.
- SerializeInternal(base, field_table + 1, num_fields, output);
-}
-
-PROTOBUF_EXPORT uint8_t* SerializeInternalToArray(const uint8_t* base,
- const FieldMetadata* table,
- arc_i32 num_fields,
- bool is_deterministic,
- uint8_t* buffer);
-
-inline uint8_t* TableSerializeToArray(const MessageLite& msg,
- const SerializationTable* table,
- bool is_deterministic, uint8_t* buffer) {
- const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg);
- const FieldMetadata* field_table = table->field_table + 1;
- int num_fields = table->num_fields - 1;
- return SerializeInternalToArray(base, field_table, num_fields,
- is_deterministic, buffer);
-}
-
-template <typename T>
-struct CompareHelper {
- bool operator()(const T& a, const T& b) const { return a < b; }
-};
-
-template <>
-struct CompareHelper<ArenaStringPtr> {
- bool operator()(const ArenaStringPtr& a, const ArenaStringPtr& b) const {
- return a.Get() < b.Get();
- }
-};
-
-struct CompareMapKey {
- template <typename T>
- bool operator()(const MapEntryHelper<T>& a,
- const MapEntryHelper<T>& b) const {
- return Compare(a.key_, b.key_);
- }
- template <typename T>
- bool Compare(const T& a, const T& b) const {
- return CompareHelper<T>()(a, b);
- }
-};
-
-template <typename MapFieldType, const SerializationTable* table>
-void MapFieldSerializer(const uint8_t* base, arc_ui32 offset, arc_ui32 tag,
- arc_ui32 has_offset, io::CodedOutputStream* output) {
- typedef MapEntryHelper<typename MapFieldType::EntryTypeTrait> Entry;
- typedef typename MapFieldType::MapType::const_iterator Iter;
-
- const MapFieldType& map_field =
- *reinterpret_cast<const MapFieldType*>(base + offset);
- const SerializationTable* t =
- table +
- has_offset; // has_offset is overloaded for maps to mean table offset
- if (!output->IsSerializationDeterministic()) {
- for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end();
- ++it) {
- Entry map_entry(*it);
- output->WriteVarint32(tag);
- output->WriteVarint32(map_entry._cached_size_);
- SerializeInternal(reinterpret_cast<const uint8_t*>(&map_entry),
- t->field_table, t->num_fields, output);
- }
- } else {
- std::vector<Entry> v;
- for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end();
- ++it) {
- v.push_back(Entry(*it));
- }
- std::sort(v.begin(), v.end(), CompareMapKey());
- for (int i = 0; i < v.size(); i++) {
- output->WriteVarint32(tag);
- output->WriteVarint32(v[i]._cached_size_);
- SerializeInternal(reinterpret_cast<const uint8_t*>(&v[i]), t->field_table,
- t->num_fields, output);
- }
- }
-}
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc
deleted file mode 100644
index ed0a3d4d19..0000000000
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <google/protobuf/generated_message_table_driven_lite.h>
-
-#include <type_traits>
-
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-namespace {
-
-TProtoStringType* MutableUnknownFields(MessageLite* msg, arc_i64 arena_offset) {
- return Raw<InternalMetadata>(msg, arena_offset)
- ->mutable_unknown_fields<TProtoStringType>();
-}
-
-struct UnknownFieldHandlerLite {
- // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?),
- // and conflating InternalMetaData into it, simplifying the template.
- static constexpr bool IsLite() { return true; }
-
- static bool Skip(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input, int tag) {
- GOOGLE_DCHECK(!table.unknown_field_set);
- io::StringOutputStream unknown_fields_string(
- MutableUnknownFields(msg, table.arena_offset));
- io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false);
-
- return internal::WireFormatLite::SkipField(input, tag,
- &unknown_fields_stream);
- }
-
- static void Varint(MessageLite* msg, const ParseTable& table, int tag,
- int value) {
- GOOGLE_DCHECK(!table.unknown_field_set);
-
- io::StringOutputStream unknown_fields_string(
- MutableUnknownFields(msg, table.arena_offset));
- io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false);
- unknown_fields_stream.WriteVarint32(tag);
- unknown_fields_stream.WriteVarint32(value);
- }
-
- static bool ParseExtension(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input, int tag) {
- ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset);
- if (extensions == nullptr) {
- return false;
- }
-
- const MessageLite* prototype = table.default_instance();
-
- GOOGLE_DCHECK(!table.unknown_field_set);
- io::StringOutputStream unknown_fields_string(
- MutableUnknownFields(msg, table.arena_offset));
- io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false);
- return extensions->ParseField(tag, input, prototype,
- &unknown_fields_stream);
- }
-};
-
-} // namespace
-
-bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table,
- io::CodedInputStream* input) {
- return MergePartialFromCodedStreamImpl<UnknownFieldHandlerLite>(msg, table,
- input);
-}
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.h
deleted file mode 100644
index 50a619ee93..0000000000
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven_lite.h
+++ /dev/null
@@ -1,874 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
-#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
-
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/generated_message_table_driven.h>
-#include <google/protobuf/implicit_weak_message.h>
-#include <google/protobuf/inlined_string_field.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <type_traits>
-
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-
-enum StringType {
- StringType_STRING = 0,
- StringType_INLINED = 3
-};
-
-// Logically a superset of StringType, consisting of all field types that
-// require special initialization.
-enum ProcessingType {
- ProcessingType_STRING = 0,
- ProcessingType_CORD = 1,
- ProcessingType_STRING_PIECE = 2,
- ProcessingType_INLINED = 3,
- ProcessingType_MESSAGE = 4,
-};
-
-enum Cardinality {
- Cardinality_SINGULAR = 0,
- Cardinality_REPEATED = 1,
- Cardinality_ONEOF = 3
-};
-
-template <typename Type>
-inline Type* Raw(MessageLite* msg, arc_i64 offset) {
- return reinterpret_cast<Type*>(reinterpret_cast<uint8_t*>(msg) + offset);
-}
-
-template <typename Type>
-inline const Type* Raw(const MessageLite* msg, arc_i64 offset) {
- return reinterpret_cast<const Type*>(reinterpret_cast<const uint8_t*>(msg) +
- offset);
-}
-
-inline ExtensionSet* GetExtensionSet(MessageLite* msg,
- arc_i64 extension_offset) {
- if (extension_offset == -1) {
- return nullptr;
- }
-
- return Raw<ExtensionSet>(msg, extension_offset);
-}
-
-template <typename Type>
-inline Type* AddField(MessageLite* msg, arc_i64 offset) {
- static_assert(std::is_trivial<Type>::value ||
- std::is_same<Type, InlinedStringField>::value,
- "Do not assign");
-
- RepeatedField<Type>* repeated = Raw<RepeatedField<Type>>(msg, offset);
- return repeated->Add();
-}
-
-template <>
-inline TProtoStringType* AddField<TProtoStringType>(MessageLite* msg, arc_i64 offset) {
- RepeatedPtrField<TProtoStringType>* repeated =
- Raw<RepeatedPtrField<TProtoStringType>>(msg, offset);
- return repeated->Add();
-}
-
-
-template <typename Type>
-inline void AddField(MessageLite* msg, arc_i64 offset, Type value) {
- static_assert(std::is_trivial<Type>::value, "Do not assign");
- *AddField<Type>(msg, offset) = value;
-}
-
-inline void SetBit(arc_ui32* has_bits, arc_ui32 has_bit_index) {
- GOOGLE_DCHECK(has_bits != nullptr);
-
- arc_ui32 mask = static_cast<arc_ui32>(1u) << (has_bit_index % 32);
- has_bits[has_bit_index / 32u] |= mask;
-}
-
-template <typename Type>
-inline Type* MutableField(MessageLite* msg, arc_ui32* has_bits,
- arc_ui32 has_bit_index, arc_i64 offset) {
- SetBit(has_bits, has_bit_index);
- return Raw<Type>(msg, offset);
-}
-
-template <typename Type>
-inline void SetField(MessageLite* msg, arc_ui32* has_bits,
- arc_ui32 has_bit_index, arc_i64 offset, Type value) {
- static_assert(std::is_trivial<Type>::value, "Do not assign");
- *MutableField<Type>(msg, has_bits, has_bit_index, offset) = value;
-}
-
-template <typename Type>
-inline void SetOneofField(MessageLite* msg, arc_ui32* oneof_case,
- arc_ui32 oneof_case_index, arc_i64 offset,
- int field_number, Type value) {
- oneof_case[oneof_case_index] = field_number;
- *Raw<Type>(msg, offset) = value;
-}
-
-// Clears a oneof field. The field argument should correspond to the particular
-// field that is currently set in the oneof.
-inline void ClearOneofField(const ParseTableField& field, Arena* arena,
- MessageLite* msg) {
- switch (field.processing_type & kTypeMask) {
- case WireFormatLite::TYPE_MESSAGE:
- if (arena == nullptr) {
- delete *Raw<MessageLite*>(msg, field.offset);
- }
- break;
-
- case WireFormatLite::TYPE_STRING:
- case WireFormatLite::TYPE_BYTES:
- Raw<ArenaStringPtr>(msg, field.offset)
- ->Destroy(ArenaStringPtr::EmptyDefault{}, arena);
- break;
-
- case TYPE_STRING_INLINED:
- case TYPE_BYTES_INLINED:
- Raw<InlinedStringField>(msg, field.offset)->DestroyNoArena(nullptr);
- break;
-
- default:
- // No cleanup needed.
- break;
- }
-}
-
-// Clears and reinitializes a oneof field as necessary, in preparation for
-// parsing a new value with type field_type and field number field_number.
-//
-// Note: the oneof_case argument should point directly to the _oneof_case_
-// element corresponding to this particular oneof, not to the beginning of the
-// _oneof_case_ array.
-template <ProcessingType field_type>
-inline void ResetOneofField(const ParseTable& table, int field_number,
- Arena* arena, MessageLite* msg,
- arc_ui32* oneof_case, arc_i64 offset,
- const void* default_ptr) {
- if (static_cast<arc_i64>(*oneof_case) == field_number) {
- // The oneof is already set to the right type, so there is no need to clear
- // it.
- return;
- }
-
- if (*oneof_case != 0) {
- ClearOneofField(table.fields[*oneof_case], arena, msg);
- }
- *oneof_case = field_number;
-
- switch (field_type) {
- case ProcessingType_STRING:
- Raw<ArenaStringPtr>(msg, offset)
- ->UnsafeSetDefault(static_cast<const TProtoStringType*>(default_ptr));
- break;
- case ProcessingType_INLINED:
- new (Raw<InlinedStringField>(msg, offset))
- InlinedStringField(*static_cast<const TProtoStringType*>(default_ptr));
- break;
- case ProcessingType_MESSAGE:
- MessageLite** submessage = Raw<MessageLite*>(msg, offset);
- const MessageLite* prototype =
- table.aux[field_number].messages.default_message();
- *submessage = prototype->New(arena);
- break;
- }
-}
-
-template <typename UnknownFieldHandler, Cardinality cardinality,
- bool is_string_type, StringType ctype>
-static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg,
- Arena* arena, arc_ui32* has_bits,
- arc_ui32 has_bit_index, arc_i64 offset,
- const void* default_ptr,
- const char* field_name) {
- StringPiece utf8_string_data;
-#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- constexpr bool kValidateUtf8 = is_string_type;
-#else
- constexpr bool kValidateUtf8 = false;
-#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
-
- switch (ctype) {
- case StringType_INLINED: {
- TProtoStringType* value = nullptr;
- switch (cardinality) {
- case Cardinality_SINGULAR: {
- // TODO(ckennelly): Is this optimal?
- InlinedStringField* s = MutableField<InlinedStringField>(
- msg, has_bits, has_bit_index, offset);
- value = s->UnsafeMutablePointer();
- } break;
- case Cardinality_REPEATED: {
- value = AddField<TProtoStringType>(msg, offset);
- } break;
- case Cardinality_ONEOF: {
- InlinedStringField* s = Raw<InlinedStringField>(msg, offset);
- value = s->UnsafeMutablePointer();
- } break;
- }
- GOOGLE_DCHECK(value != nullptr);
- if (PROTOBUF_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) {
- return false;
- }
- utf8_string_data = *value;
- break;
- }
- case StringType_STRING: {
- switch (cardinality) {
- case Cardinality_SINGULAR: {
- ArenaStringPtr* field = MutableField<ArenaStringPtr>(
- msg, has_bits, has_bit_index, offset);
- TProtoStringType* value = field->MutableNoCopy(
- static_cast<const TProtoStringType*>(default_ptr), arena);
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadString(input, value))) {
- return false;
- }
- utf8_string_data = field->Get();
- } break;
- case Cardinality_REPEATED: {
- TProtoStringType* value = AddField<TProtoStringType>(msg, offset);
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadString(input, value))) {
- return false;
- }
- utf8_string_data = *value;
- } break;
- case Cardinality_ONEOF: {
- ArenaStringPtr* field = Raw<ArenaStringPtr>(msg, offset);
- TProtoStringType* value = field->MutableNoCopy(
- static_cast<const TProtoStringType*>(default_ptr), arena);
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadString(input, value))) {
- return false;
- }
- utf8_string_data = field->Get();
- } break;
- default:
- PROTOBUF_ASSUME(false);
- }
- break;
- }
- default:
- PROTOBUF_ASSUME(false);
- }
-
- if (kValidateUtf8) {
- // TODO(b/118759213): fail if proto3
- WireFormatLite::VerifyUtf8String(utf8_string_data.data(),
- utf8_string_data.length(),
- WireFormatLite::PARSE, field_name);
- }
- return true;
-}
-
-template <typename UnknownFieldHandler, Cardinality cardinality>
-inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input,
- MessageLite* msg, arc_ui32* presence,
- arc_ui32 presence_index, arc_i64 offset, arc_ui32 tag,
- int field_number) {
- int value;
- if (PROTOBUF_PREDICT_FALSE(
- (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
- input, &value)))) {
- return false;
- }
-
- AuxiliaryParseTableField::EnumValidator validator =
- table.aux[field_number].enums.validator;
- if (validator == nullptr || validator(value)) {
- switch (cardinality) {
- case Cardinality_SINGULAR:
- SetField(msg, presence, presence_index, offset, value);
- break;
- case Cardinality_REPEATED:
- AddField(msg, offset, value);
- break;
- case Cardinality_ONEOF:
- ClearOneofField(table.fields[presence[presence_index]], msg->GetArena(),
- msg);
- SetOneofField(msg, presence, presence_index, offset, field_number,
- value);
- break;
- default:
- PROTOBUF_ASSUME(false);
- }
- } else {
- UnknownFieldHandler::Varint(msg, table, tag, value);
- }
-
- return true;
-}
-
-// RepeatedMessageTypeHandler allows us to operate on RepeatedPtrField fields
-// without instantiating the specific template.
-class RepeatedMessageTypeHandler {
- public:
- typedef MessageLite Type;
- typedef MessageLite WeakType;
- static Arena* GetArena(Type* t) { return t->GetArena(); }
- static inline Type* NewFromPrototype(const Type* prototype,
- Arena* arena = nullptr) {
- return prototype->New(arena);
- }
- static void Delete(Type* t, Arena* arena = nullptr) {
- if (arena == nullptr) {
- delete t;
- }
- }
-};
-
-class MergePartialFromCodedStreamHelper {
- public:
- static MessageLite* Add(RepeatedPtrFieldBase* field,
- const MessageLite* prototype) {
- return field->Add<RepeatedMessageTypeHandler>(
- const_cast<MessageLite*>(prototype));
- }
-};
-
-template <typename UnknownFieldHandler, arc_ui32 kMaxTag>
-bool MergePartialFromCodedStreamInlined(MessageLite* msg,
- const ParseTable& table,
- io::CodedInputStream* input) {
- // We require that has_bits are present, as to avoid having to check for them
- // for every field.
- //
- // TODO(ckennelly): Make this a compile-time parameter with templates.
- GOOGLE_DCHECK_GE(table.has_bits_offset, 0);
- arc_ui32* has_bits = Raw<arc_ui32>(msg, table.has_bits_offset);
- GOOGLE_DCHECK(has_bits != nullptr);
-
- while (true) {
- arc_ui32 tag = input->ReadTagWithCutoffNoLastTag(kMaxTag).first;
- const WireFormatLite::WireType wire_type =
- WireFormatLite::GetTagWireType(tag);
- const int field_number = WireFormatLite::GetTagFieldNumber(tag);
-
- if (PROTOBUF_PREDICT_FALSE(field_number > table.max_field_number)) {
- // check for possible extensions
- if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) {
- // successfully parsed
- continue;
- }
-
- if (PROTOBUF_PREDICT_FALSE(
- !UnknownFieldHandler::Skip(msg, table, input, tag))) {
- return false;
- }
-
- continue;
- }
-
- // We implicitly verify that data points to a valid field as we check the
- // wire types. Entries in table.fields[i] that do not correspond to valid
- // field numbers have their normal_wiretype and packed_wiretype fields set
- // with the kInvalidMask value. As wire_type cannot take on that value, we
- // will never match.
- const ParseTableField* data = table.fields + field_number;
-
- // TODO(ckennelly): Avoid sign extension
- const arc_i64 presence_index = data->presence_index;
- const arc_i64 offset = data->offset;
- const unsigned char processing_type = data->processing_type;
-
- if (data->normal_wiretype == static_cast<unsigned char>(wire_type)) {
- switch (processing_type) {
-#define HANDLE_TYPE(TYPE, CPPTYPE) \
- case (WireFormatLite::TYPE_##TYPE): { \
- CPPTYPE value; \
- if (PROTOBUF_PREDICT_FALSE( \
- (!WireFormatLite::ReadPrimitive< \
- CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
- return false; \
- } \
- SetField(msg, has_bits, presence_index, offset, value); \
- break; \
- } \
- case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \
- RepeatedField<CPPTYPE>* values = Raw<RepeatedField<CPPTYPE>>(msg, offset); \
- if (PROTOBUF_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \
- CPPTYPE, WireFormatLite::TYPE_##TYPE>( \
- data->tag_size, tag, input, values)))) { \
- return false; \
- } \
- break; \
- } \
- case (WireFormatLite::TYPE_##TYPE) | kOneofMask: { \
- arc_ui32* oneof_case = Raw<arc_ui32>(msg, table.oneof_case_offset); \
- CPPTYPE value; \
- if (PROTOBUF_PREDICT_FALSE( \
- (!WireFormatLite::ReadPrimitive< \
- CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
- return false; \
- } \
- ClearOneofField(table.fields[oneof_case[presence_index]], msg->GetArena(), \
- msg); \
- SetOneofField(msg, oneof_case, presence_index, offset, field_number, \
- value); \
- break; \
- }
-
- HANDLE_TYPE(INT32, arc_i32)
- HANDLE_TYPE(INT64, arc_i64)
- HANDLE_TYPE(SINT32, arc_i32)
- HANDLE_TYPE(SINT64, arc_i64)
- HANDLE_TYPE(UINT32, arc_ui32)
- HANDLE_TYPE(UINT64, arc_ui64)
-
- HANDLE_TYPE(FIXED32, arc_ui32)
- HANDLE_TYPE(FIXED64, arc_ui64)
- HANDLE_TYPE(SFIXED32, arc_i32)
- HANDLE_TYPE(SFIXED64, arc_i64)
-
- HANDLE_TYPE(FLOAT, float)
- HANDLE_TYPE(DOUBLE, double)
-
- HANDLE_TYPE(BOOL, bool)
-#undef HANDLE_TYPE
- case WireFormatLite::TYPE_BYTES:
-#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case WireFormatLite::TYPE_STRING:
-#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- {
- Arena* const arena = msg->GetArena();
- const void* default_ptr = table.aux[field_number].strings.default_ptr;
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR,
- false, StringType_STRING>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, nullptr)))) {
- return false;
- }
- break;
- }
- case TYPE_BYTES_INLINED:
-#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case TYPE_STRING_INLINED:
-#endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- {
- Arena* const arena = msg->GetArena();
- const void* default_ptr = table.aux[field_number].strings.default_ptr;
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR,
- false, StringType_INLINED>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, nullptr)))) {
- return false;
- }
- break;
- }
- case WireFormatLite::TYPE_BYTES | kOneofMask:
-#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case WireFormatLite::TYPE_STRING | kOneofMask:
-#endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- {
- Arena* const arena = msg->GetArena();
- arc_ui32* oneof_case = Raw<arc_ui32>(msg, table.oneof_case_offset);
- const void* default_ptr = table.aux[field_number].strings.default_ptr;
-
- ResetOneofField<ProcessingType_STRING>(
- table, field_number, arena, msg, oneof_case + presence_index,
- offset, default_ptr);
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_ONEOF, false,
- StringType_STRING>(input, msg, arena, has_bits,
- presence_index, offset,
- default_ptr, nullptr)))) {
- return false;
- }
- break;
- }
- case (WireFormatLite::TYPE_BYTES) | kRepeatedMask:
- case TYPE_BYTES_INLINED | kRepeatedMask:
-#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case (WireFormatLite::TYPE_STRING) | kRepeatedMask:
- case TYPE_STRING_INLINED | kRepeatedMask:
-#endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- {
- Arena* const arena = msg->GetArena();
- const void* default_ptr = table.aux[field_number].strings.default_ptr;
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_REPEATED,
- false, StringType_STRING>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, nullptr)))) {
- return false;
- }
- break;
- }
-#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case (WireFormatLite::TYPE_STRING): {
- 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;
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR,
- true, StringType_STRING>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, field_name)))) {
- return false;
- }
- break;
- }
- case TYPE_STRING_INLINED | kRepeatedMask:
- case (WireFormatLite::TYPE_STRING) | kRepeatedMask: {
- 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;
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_REPEATED,
- true, StringType_STRING>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, field_name)))) {
- return false;
- }
- break;
- }
- case (WireFormatLite::TYPE_STRING) | kOneofMask: {
- Arena* const arena = msg->GetArena();
- arc_ui32* oneof_case = Raw<arc_ui32>(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;
-
- ResetOneofField<ProcessingType_STRING>(
- table, field_number, arena, msg, oneof_case + presence_index,
- offset, default_ptr);
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_ONEOF, true,
- StringType_STRING>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, field_name)))) {
- return false;
- }
- break;
- }
-#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case WireFormatLite::TYPE_ENUM: {
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleEnum<UnknownFieldHandler, Cardinality_SINGULAR>(
- table, input, msg, has_bits, presence_index, offset, tag,
- field_number)))) {
- return false;
- }
- break;
- }
- case WireFormatLite::TYPE_ENUM | kRepeatedMask: {
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleEnum<UnknownFieldHandler, Cardinality_REPEATED>(
- table, input, msg, has_bits, presence_index, offset, tag,
- field_number)))) {
- return false;
- }
- break;
- }
- case WireFormatLite::TYPE_ENUM | kOneofMask: {
- arc_ui32* oneof_case = Raw<arc_ui32>(msg, table.oneof_case_offset);
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleEnum<UnknownFieldHandler, Cardinality_ONEOF>(
- table, input, msg, oneof_case, presence_index, offset,
- tag, field_number)))) {
- return false;
- }
- break;
- }
- case WireFormatLite::TYPE_GROUP: {
- MessageLite** submsg_holder =
- MutableField<MessageLite*>(msg, has_bits, presence_index, offset);
- MessageLite* submsg = *submsg_holder;
-
- if (submsg == nullptr) {
- Arena* const arena = msg->GetArena();
- const MessageLite* prototype =
- table.aux[field_number].messages.default_message();
- submsg = prototype->New(arena);
- *submsg_holder = submsg;
- }
-
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadGroup(field_number, input, submsg))) {
- return false;
- }
-
- break;
- }
- case WireFormatLite::TYPE_GROUP | kRepeatedMask: {
- RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset);
- const MessageLite* prototype =
- table.aux[field_number].messages.default_message();
- GOOGLE_DCHECK(prototype != nullptr);
-
- MessageLite* submsg =
- MergePartialFromCodedStreamHelper::Add(field, prototype);
-
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadGroup(field_number, input, submsg))) {
- return false;
- }
-
- break;
- }
- case WireFormatLite::TYPE_MESSAGE: {
- MessageLite** submsg_holder =
- MutableField<MessageLite*>(msg, has_bits, presence_index, offset);
- MessageLite* submsg = *submsg_holder;
-
- if (submsg == nullptr) {
- Arena* const arena = msg->GetArena();
- const MessageLite* prototype =
- table.aux[field_number].messages.default_message();
- if (prototype == nullptr) {
- prototype = ImplicitWeakMessage::default_instance();
- }
- submsg = prototype->New(arena);
- *submsg_holder = submsg;
- }
-
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadMessage(input, submsg))) {
- return false;
- }
-
- break;
- }
- // TODO(ckennelly): Adapt ReadMessageNoVirtualNoRecursionDepth and
- // manage input->IncrementRecursionDepth() here.
- case WireFormatLite::TYPE_MESSAGE | kRepeatedMask: {
- RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset);
- const MessageLite* prototype =
- table.aux[field_number].messages.default_message();
- if (prototype == nullptr) {
- prototype = ImplicitWeakMessage::default_instance();
- }
-
- MessageLite* submsg =
- MergePartialFromCodedStreamHelper::Add(field, prototype);
-
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadMessage(input, submsg))) {
- return false;
- }
-
- break;
- }
- case WireFormatLite::TYPE_MESSAGE | kOneofMask: {
- Arena* const arena = msg->GetArena();
- arc_ui32* oneof_case = Raw<arc_ui32>(msg, table.oneof_case_offset);
- MessageLite** submsg_holder = Raw<MessageLite*>(msg, offset);
- ResetOneofField<ProcessingType_MESSAGE>(
- table, field_number, arena, msg, oneof_case + presence_index,
- offset, nullptr);
- MessageLite* submsg = *submsg_holder;
-
- if (PROTOBUF_PREDICT_FALSE(
- !WireFormatLite::ReadMessage(input, submsg))) {
- return false;
- }
-
- break;
- }
-#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case TYPE_STRING_INLINED: {
- 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;
-
- if (PROTOBUF_PREDICT_FALSE(
- (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR,
- true, StringType_INLINED>(
- input, msg, arena, has_bits, presence_index, offset,
- default_ptr, field_name)))) {
- return false;
- }
- break;
- }
-#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- case TYPE_MAP: {
- if (PROTOBUF_PREDICT_FALSE(!(*table.aux[field_number].maps.parse_map)(
- input, Raw<void>(msg, offset)))) {
- return false;
- }
- break;
- }
- case 0: {
- // Done.
- input->SetLastTag(tag);
- return true;
- }
- default:
- PROTOBUF_ASSUME(false);
- }
- } else if (data->packed_wiretype == static_cast<unsigned char>(wire_type)) {
- // Non-packable fields have their packed_wiretype masked with
- // kNotPackedMask, which is impossible to match here.
- GOOGLE_DCHECK(processing_type & kRepeatedMask);
- GOOGLE_DCHECK_NE(processing_type, kRepeatedMask);
- GOOGLE_DCHECK_EQ(0, processing_type & kOneofMask);
-
- GOOGLE_DCHECK_NE(TYPE_BYTES_INLINED | kRepeatedMask, processing_type);
- GOOGLE_DCHECK_NE(TYPE_STRING_INLINED | kRepeatedMask, processing_type);
-
- // Mask out kRepeatedMask bit, allowing the jump table to be smaller.
- switch (static_cast<WireFormatLite::FieldType>(processing_type ^
- kRepeatedMask)) {
-#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \
- case WireFormatLite::TYPE_##TYPE: { \
- RepeatedField<CPPTYPE>* values = Raw<RepeatedField<CPPTYPE>>(msg, offset); \
- if (PROTOBUF_PREDICT_FALSE( \
- (!WireFormatLite::ReadPackedPrimitive< \
- CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \
- return false; \
- } \
- break; \
- }
-
- HANDLE_PACKED_TYPE(INT32, arc_i32, Int32)
- HANDLE_PACKED_TYPE(INT64, arc_i64, Int64)
- HANDLE_PACKED_TYPE(SINT32, arc_i32, Int32)
- HANDLE_PACKED_TYPE(SINT64, arc_i64, Int64)
- HANDLE_PACKED_TYPE(UINT32, arc_ui32, UInt32)
- HANDLE_PACKED_TYPE(UINT64, arc_ui64, UInt64)
-
- HANDLE_PACKED_TYPE(FIXED32, arc_ui32, UInt32)
- HANDLE_PACKED_TYPE(FIXED64, arc_ui64, UInt64)
- HANDLE_PACKED_TYPE(SFIXED32, arc_i32, Int32)
- HANDLE_PACKED_TYPE(SFIXED64, arc_i64, Int64)
-
- HANDLE_PACKED_TYPE(FLOAT, float, Float)
- HANDLE_PACKED_TYPE(DOUBLE, double, Double)
-
- HANDLE_PACKED_TYPE(BOOL, bool, Bool)
-#undef HANDLE_PACKED_TYPE
- case WireFormatLite::TYPE_ENUM: {
- // To avoid unnecessarily calling MutableUnknownFields (which mutates
- // InternalMetadata) when all inputs in the repeated series
- // are valid, we implement our own parser rather than call
- // WireFormat::ReadPackedEnumPreserveUnknowns.
- arc_ui32 length;
- if (PROTOBUF_PREDICT_FALSE(!input->ReadVarint32(&length))) {
- return false;
- }
-
- AuxiliaryParseTableField::EnumValidator validator =
- table.aux[field_number].enums.validator;
- RepeatedField<int>* values = Raw<RepeatedField<int>>(msg, offset);
-
- io::CodedInputStream::Limit limit = input->PushLimit(length);
- while (input->BytesUntilLimit() > 0) {
- int value;
- if (PROTOBUF_PREDICT_FALSE(
- (!WireFormatLite::ReadPrimitive<
- int, WireFormatLite::TYPE_ENUM>(input, &value)))) {
- return false;
- }
-
- if (validator == nullptr || validator(value)) {
- values->Add(value);
- } else {
- // TODO(ckennelly): Consider caching here.
- UnknownFieldHandler::Varint(msg, table, tag, value);
- }
- }
- input->PopLimit(limit);
-
- break;
- }
- case WireFormatLite::TYPE_STRING:
- case WireFormatLite::TYPE_GROUP:
- case WireFormatLite::TYPE_MESSAGE:
- case WireFormatLite::TYPE_BYTES:
- GOOGLE_DCHECK(false);
- return false;
- default:
- PROTOBUF_ASSUME(false);
- }
- } else {
- if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) {
- // Must be the end of the message.
- input->SetLastTag(tag);
- return true;
- }
-
- // check for possible extensions
- if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) {
- // successfully parsed
- continue;
- }
-
- // process unknown field.
- if (PROTOBUF_PREDICT_FALSE(
- !UnknownFieldHandler::Skip(msg, table, input, tag))) {
- return false;
- }
- }
- }
-} // NOLINT(readability/fn_size)
-
-template <typename UnknownFieldHandler>
-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<UnknownFieldHandler, 0x7F>(
- msg, table, input);
- } else if (table.max_field_number <= (0x3FFF >> 3)) {
- return MergePartialFromCodedStreamInlined<UnknownFieldHandler, 0x3FFF>(
- msg, table, input);
- } else {
- return MergePartialFromCodedStreamInlined<
- UnknownFieldHandler, std::numeric_limits<arc_ui32>::max()>(msg, table,
- input);
- }
-}
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_decl.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_decl.h
index 84c3e715dd..bb42f6fdef 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_decl.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_decl.h
@@ -35,11 +35,13 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
+#include <array>
+#include <cstddef>
#include <cstdint>
#include <type_traits>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
// Must come last:
#include <google/protobuf/port_def.inc>
@@ -51,17 +53,53 @@ namespace internal {
// Additional information about this field:
struct TcFieldData {
constexpr TcFieldData() : data(0) {}
- constexpr TcFieldData(uint16_t coded_tag, uint8_t hasbit_idx, uint16_t offset)
- : data(static_cast<arc_ui64>(offset) << 48 |
- static_cast<arc_ui64>(hasbit_idx) << 16 | coded_tag) {}
+
+ // Fast table entry constructor:
+ constexpr TcFieldData(uint16_t coded_tag, uint8_t hasbit_idx, uint8_t aux_idx,
+ uint16_t offset)
+ : data(arc_ui64{offset} << 48 | //
+ arc_ui64{aux_idx} << 24 | //
+ arc_ui64{hasbit_idx} << 16 | //
+ arc_ui64{coded_tag}) {}
+
+ // Fields used in fast table parsing:
+ //
+ // Bit:
+ // +-----------+-------------------+
+ // |63 .. 32|31 .. 0|
+ // +---------------+---------------+
+ // : . : . : . 16|=======| [16] coded_tag()
+ // : . : . : 24|===| . : [ 8] hasbit_idx()
+ // : . : . 32|===| : . : [ 8] aux_idx()
+ // : . 48:---.---: . : . : [16] (unused)
+ // |=======| . : . : . : [16] offset()
+ // +-----------+-------------------+
+ // |63 .. 32|31 .. 0|
+ // +---------------+---------------+
template <typename TagType = uint16_t>
TagType coded_tag() const {
return static_cast<TagType>(data);
}
uint8_t hasbit_idx() const { return static_cast<uint8_t>(data >> 16); }
+ uint8_t aux_idx() const { return static_cast<uint8_t>(data >> 24); }
uint16_t offset() const { return static_cast<uint16_t>(data >> 48); }
+ // Fields used in mini table parsing:
+ //
+ // Bit:
+ // +-----------+-------------------+
+ // |63 .. 32|31 .. 0|
+ // +---------------+---------------+
+ // : . : . |===============| [32] tag() (decoded)
+ // |===============| . : . : [32] entry_offset()
+ // +-----------+-------------------+
+ // |63 .. 32|31 .. 0|
+ // +---------------+---------------+
+
+ arc_ui32 tag() const { return static_cast<arc_ui32>(data); }
+ arc_ui32 entry_offset() const { return static_cast<arc_ui32>(data >> 32); }
+
arc_ui64 data;
};
@@ -70,6 +108,12 @@ struct TcParseTableBase;
// TailCallParseFunc is the function pointer type used in the tailcall table.
typedef const char* (*TailCallParseFunc)(PROTOBUF_TC_PARAM_DECL);
+namespace field_layout {
+struct Offset {
+ arc_ui32 off;
+};
+} // namespace field_layout
+
#if defined(_MSC_VER) && !defined(_WIN64)
#pragma warning(push)
// TcParseTableBase is intentionally overaligned on 32 bit targets.
@@ -83,14 +127,49 @@ struct alignas(arc_ui64) TcParseTableBase {
uint16_t extension_offset;
arc_ui32 extension_range_low;
arc_ui32 extension_range_high;
+ arc_ui32 max_field_number;
uint8_t fast_idx_mask;
- uint8_t reserved;
- uint16_t num_fields;
+ uint16_t lookup_table_offset;
+ arc_ui32 skipmap32;
+ arc_ui32 field_entries_offset;
+ uint16_t num_field_entries;
+
+ uint16_t num_aux_entries;
+ arc_ui32 aux_offset;
+
const MessageLite* default_instance;
// Handler for fields which are not handled by table dispatch.
TailCallParseFunc fallback;
+ // This constructor exactly follows the field layout, so it's technically
+ // not necessary. However, it makes it much much easier to add or re-arrange
+ // fields, because it can be overloaded with an additional constructor,
+ // temporarily allowing both old and new protocol buffer headers to be
+ // compiled.
+ constexpr TcParseTableBase(
+ uint16_t has_bits_offset, uint16_t extension_offset,
+ arc_ui32 extension_range_low, arc_ui32 extension_range_high,
+ arc_ui32 max_field_number, uint8_t fast_idx_mask,
+ uint16_t lookup_table_offset, arc_ui32 skipmap32,
+ arc_ui32 field_entries_offset, uint16_t num_field_entries,
+ uint16_t num_aux_entries, arc_ui32 aux_offset,
+ const MessageLite* default_instance, TailCallParseFunc fallback)
+ : has_bits_offset(has_bits_offset),
+ extension_offset(extension_offset),
+ extension_range_low(extension_range_low),
+ extension_range_high(extension_range_high),
+ max_field_number(max_field_number),
+ fast_idx_mask(fast_idx_mask),
+ lookup_table_offset(lookup_table_offset),
+ skipmap32(skipmap32),
+ field_entries_offset(field_entries_offset),
+ num_field_entries(num_field_entries),
+ num_aux_entries(num_aux_entries),
+ aux_offset(aux_offset),
+ default_instance(default_instance),
+ fallback(fallback) {}
+
// Table entry for fast-path tailcall dispatch handling.
struct FastFieldEntry {
// Target function for dispatch:
@@ -102,6 +181,59 @@ struct alignas(arc_ui64) TcParseTableBase {
const FastFieldEntry* fast_entry(size_t idx) const {
return reinterpret_cast<const FastFieldEntry*>(this + 1) + idx;
}
+
+ // Returns a begin iterator (pointer) to the start of the field lookup table.
+ const uint16_t* field_lookup_begin() const {
+ return reinterpret_cast<const uint16_t*>(reinterpret_cast<uintptr_t>(this) +
+ lookup_table_offset);
+ }
+
+ // Field entry for all fields.
+ struct FieldEntry {
+ arc_ui32 offset; // offset in the message object
+ arc_i32 has_idx; // has-bit index
+ uint16_t aux_idx; // index for `field_aux`.
+ uint16_t type_card; // `FieldType` and `Cardinality` (see _impl.h)
+ };
+
+ // Returns a begin iterator (pointer) to the start of the field entries array.
+ const FieldEntry* field_entries_begin() const {
+ return reinterpret_cast<const FieldEntry*>(
+ reinterpret_cast<uintptr_t>(this) + field_entries_offset);
+ }
+
+ // Auxiliary entries for field types that need extra information.
+ union FieldAux {
+ constexpr FieldAux() : message_default(nullptr) {}
+ constexpr FieldAux(bool (*enum_validator)(int))
+ : enum_validator(enum_validator) {}
+ constexpr FieldAux(field_layout::Offset off) : offset(off.off) {}
+ constexpr FieldAux(int16_t range_start, uint16_t range_length)
+ : enum_range{range_start, range_length} {}
+ constexpr FieldAux(const MessageLite* msg) : message_default(msg) {}
+ bool (*enum_validator)(int);
+ struct {
+ int16_t start; // minimum enum number (if it fits)
+ uint16_t length; // length of range (i.e., max = start + length - 1)
+ } enum_range;
+ arc_ui32 offset;
+ const MessageLite* message_default;
+ };
+ const FieldAux* field_aux(arc_ui32 idx) const {
+ return reinterpret_cast<const FieldAux*>(reinterpret_cast<uintptr_t>(this) +
+ aux_offset) +
+ idx;
+ }
+ const FieldAux* field_aux(const FieldEntry* entry) const {
+ return field_aux(entry->aux_idx);
+ }
+
+ // Field name data
+ const char* name_data() const {
+ return reinterpret_cast<const char*>(reinterpret_cast<uintptr_t>(this) +
+ aux_offset +
+ num_aux_entries * sizeof(FieldAux));
+ }
};
#if defined(_MSC_VER) && !defined(_WIN64)
@@ -109,9 +241,13 @@ struct alignas(arc_ui64) TcParseTableBase {
#endif
static_assert(sizeof(TcParseTableBase::FastFieldEntry) <= 16,
+ "Fast field entry is too big.");
+static_assert(sizeof(TcParseTableBase::FieldEntry) <= 16,
"Field entry is too big.");
-template <size_t kFastTableSizeLog2>
+template <size_t kFastTableSizeLog2, size_t kNumFieldEntries = 0,
+ size_t kNumFieldAux = 0, size_t kNameTableSize = 0,
+ size_t kFieldLookupSize = 2>
struct TcParseTable {
TcParseTableBase header;
@@ -119,15 +255,52 @@ struct TcParseTable {
//
// Fields are indexed by the lowest bits of their field number. The field
// number is masked to fit inside the table. Note that the parsing logic
- // generally calls `TailCallParseTableBase::table()` instead of accessing
+ // generally calls `TailCallParseTableBase::fast_entry()` instead of accessing
// this field directly.
- TcParseTableBase::FastFieldEntry entries[(1 << kFastTableSizeLog2)];
+ std::array<TcParseTableBase::FastFieldEntry, (1 << kFastTableSizeLog2)>
+ fast_entries;
+
+ // Just big enough to find all the field entries.
+ std::array<uint16_t, kFieldLookupSize> field_lookup_table;
+ // Entries for all fields:
+ std::array<TcParseTableBase::FieldEntry, kNumFieldEntries> field_entries;
+ std::array<TcParseTableBase::FieldAux, kNumFieldAux> aux_entries;
+ std::array<char, kNameTableSize> field_names;
+};
+
+// Partial specialization: if there are no aux entries, there will be no array.
+// In C++, arrays cannot have length 0, but (C++11) std::array<T, 0> is valid.
+// However, different implementations have different sizeof(std::array<T, 0>).
+// Skipping the member makes offset computations portable.
+template <size_t kFastTableSizeLog2, size_t kNumFieldEntries,
+ size_t kNameTableSize, size_t kFieldLookupSize>
+struct TcParseTable<kFastTableSizeLog2, kNumFieldEntries, 0, kNameTableSize,
+ kFieldLookupSize> {
+ TcParseTableBase header;
+ std::array<TcParseTableBase::FastFieldEntry, (1 << kFastTableSizeLog2)>
+ fast_entries;
+ std::array<uint16_t, kFieldLookupSize> field_lookup_table;
+ std::array<TcParseTableBase::FieldEntry, kNumFieldEntries> field_entries;
+ std::array<char, kNameTableSize> field_names;
+};
+
+// Partial specialization: if there are no fields at all, then we can save space
+// by skipping the field numbers and entries.
+template <size_t kNameTableSize, size_t kFieldLookupSize>
+struct TcParseTable<0, 0, 0, kNameTableSize, kFieldLookupSize> {
+ TcParseTableBase header;
+ // N.B.: the fast entries are sized by log2, so 2**0 fields = 1 entry.
+ // The fast parsing loop will always use this entry, so it must be present.
+ std::array<TcParseTableBase::FastFieldEntry, 1> fast_entries;
+ std::array<uint16_t, kFieldLookupSize> field_lookup_table;
+ std::array<char, kNameTableSize> field_names;
};
static_assert(std::is_standard_layout<TcParseTable<1>>::value,
"TcParseTable must be standard layout.");
-static_assert(offsetof(TcParseTable<1>, entries) == sizeof(TcParseTableBase),
+static_assert(offsetof(TcParseTable<1>, fast_entries) ==
+ sizeof(TcParseTableBase),
"Table entries must be laid out after TcParseTableBase.");
} // namespace internal
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_full.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_full.cc
index 44dcddc796..b77bb8d8e3 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_full.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_full.cc
@@ -30,10 +30,10 @@
#include <cstdint>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_tctable_impl.h>
#include <google/protobuf/message.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/unknown_field_set.h>
// clang-format off
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.h
index 11c5c8660c..d3929c82ed 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.h
@@ -34,12 +34,12 @@
#include <cstdint>
#include <type_traits>
-#include <google/protobuf/parse_context.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_tctable_decl.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/port.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
// Must come last:
@@ -53,6 +53,189 @@ class UnknownFieldSet;
namespace internal {
+// Field layout enums.
+//
+// Structural information about fields is packed into a 16-bit value. The enum
+// types below represent bitwise fields, along with their respective widths,
+// shifts, and masks.
+//
+// Bit:
+// +-----------------------+-----------------------+
+// |15 .. 8|7 .. 0|
+// +-----------------------+-----------------------+
+// : . : . : . : . : . : . : 3|========| [3] FieldType
+// : : : : : : 5|=====| : : [2] FieldCardinality
+// : . : . : . : . 8|========| : . : . : [3] FieldRep
+// : : : 10|=====| : : : : [2] TransformValidation
+// : . : .12|=====| . : . : . : . : . : [2] FormatDiscriminator
+// +-----------------------+-----------------------+
+// |15 .. 8|7 .. 0|
+// +-----------------------+-----------------------+
+//
+namespace field_layout {
+// clang-format off
+
+// Field kind (3 bits):
+// These values broadly represent a wire type and an in-memory storage class.
+enum FieldKind : uint16_t {
+ kFkShift = 0,
+ kFkBits = 3,
+ kFkMask = ((1 << kFkBits) - 1) << kFkShift,
+
+ kFkNone = 0,
+ kFkVarint, // WT=0 rep=8,32,64 bits
+ kFkPackedVarint, // WT=2 rep=8,32,64 bits
+ kFkFixed, // WT=1,5 rep=32,64 bits
+ kFkPackedFixed, // WT=2 rep=32,64 bits
+ kFkString, // WT=2 rep=various
+ kFkMessage, // WT=2,3,4 rep=MessageLite*
+ // Maps are a special case of Message, but use different parsing logic.
+ kFkMap, // WT=2 rep=Map(Lite)<various, various>
+};
+
+static_assert(kFkMap < (1 << kFkBits), "too many types");
+
+// Cardinality (2 bits):
+// These values determine how many values a field can have and its presence.
+// Packed fields are represented in FieldType.
+enum Cardinality : uint16_t {
+ kFcShift = kFkShift + kFkBits,
+ kFcBits = 2,
+ kFcMask = ((1 << kFcBits) - 1) << kFcShift,
+
+ kFcSingular = 0,
+ kFcOptional = 1 << kFcShift,
+ kFcRepeated = 2 << kFcShift,
+ kFcOneof = 3 << kFcShift,
+};
+
+// Field representation (3 bits):
+// These values are the specific refinements of storage classes in FieldType.
+enum FieldRep : uint16_t {
+ kRepShift = kFcShift + kFcBits,
+ kRepBits = 3,
+ kRepMask = ((1 << kRepBits) - 1) << kRepShift,
+
+ // Numeric types (used for optional and repeated fields):
+ kRep8Bits = 0,
+ kRep32Bits = 2 << kRepShift,
+ kRep64Bits = 3 << kRepShift,
+ // String types:
+ kRepAString = 0, // ArenaStringPtr
+ kRepIString = 1 << kRepShift, // InlinedString
+ kRepCord = 2 << kRepShift, // absl::Cord
+ kRepSPiece = 3 << kRepShift, // StringPieceField
+ kRepSString = 4 << kRepShift, // TProtoStringType*
+ // Message types (WT=2 unless otherwise noted):
+ kRepMessage = 0, // MessageLite*
+ kRepGroup = 1 << kRepShift, // MessageLite* (WT=3,4)
+ kRepLazy = 2 << kRepShift, // LazyField*
+ kRepIWeak = 3 << kRepShift, // ImplicitWeak
+};
+
+// Transform/validation (2 bits):
+// These values determine transforms or validation to/from wire format.
+enum TransformValidation : uint16_t {
+ kTvShift = kRepShift + kRepBits,
+ kTvBits = 2,
+ kTvMask = ((1 << kTvBits) - 1) << kTvShift,
+
+ // Varint fields:
+ kTvZigZag = 1 << kTvShift,
+ kTvEnum = 2 << kTvShift, // validate using generated _IsValid()
+ kTvRange = 3 << kTvShift, // validate using FieldAux::enum_range
+ // String fields:
+ kTvUtf8Debug = 1 << kTvShift, // proto2
+ kTvUtf8 = 2 << kTvShift, // proto3
+};
+
+static_assert((kTvEnum & kTvRange) != 0,
+ "enum validation types must share a bit");
+static_assert((kTvEnum & kTvRange & kTvZigZag) == 0,
+ "zigzag encoding is not enum validation");
+
+// Format discriminators (2 bits):
+enum FormatDiscriminator : uint16_t {
+ kFmtShift = kTvShift + kTvBits,
+ kFmtBits = 2,
+ kFmtMask = ((1 << kFmtBits) - 1) << kFmtShift,
+
+ // Numeric:
+ kFmtUnsigned = 1 << kFmtShift, // fixed, varint
+ kFmtSigned = 2 << kFmtShift, // fixed, varint
+ kFmtFloating = 3 << kFmtShift, // fixed
+ kFmtEnum = 3 << kFmtShift, // varint
+ // Strings:
+ kFmtUtf8 = 1 << kFmtShift, // string (proto3, enforce_utf8=true)
+ kFmtUtf8Escape = 2 << kFmtShift, // string (proto2, enforce_utf8=false)
+ // Bytes:
+ kFmtArray = 1 << kFmtShift, // bytes
+ // Messages:
+ kFmtShow = 1 << kFmtShift, // message, map
+};
+
+// Update this assertion (and comments above) when adding or removing bits:
+static_assert(kFmtShift + kFmtBits == 12, "number of bits changed");
+
+// This assertion should not change unless the storage width changes:
+static_assert(kFmtShift + kFmtBits <= 16, "too many bits");
+
+// Convenience aliases (16 bits, with format):
+enum FieldType : uint16_t {
+ // Numeric types:
+ kBool = kFkVarint | kRep8Bits,
+
+ kFixed32 = kFkFixed | kRep32Bits | kFmtUnsigned,
+ kUInt32 = kFkVarint | kRep32Bits | kFmtUnsigned,
+ kSFixed32 = kFkFixed | kRep32Bits | kFmtSigned,
+ kInt32 = kFkVarint | kRep32Bits | kFmtSigned,
+ kSInt32 = kFkVarint | kRep32Bits | kFmtSigned | kTvZigZag,
+ kFloat = kFkFixed | kRep32Bits | kFmtFloating,
+ kEnum = kFkVarint | kRep32Bits | kFmtEnum | kTvEnum,
+ kEnumRange = kFkVarint | kRep32Bits | kFmtEnum | kTvRange,
+ kOpenEnum = kFkVarint | kRep32Bits | kFmtEnum,
+
+ kFixed64 = kFkFixed | kRep64Bits | kFmtUnsigned,
+ kUInt64 = kFkVarint | kRep64Bits | kFmtUnsigned,
+ kSFixed64 = kFkFixed | kRep64Bits | kFmtSigned,
+ kInt64 = kFkVarint | kRep64Bits | kFmtSigned,
+ kSInt64 = kFkVarint | kRep64Bits | kFmtSigned | kTvZigZag,
+ kDouble = kFkFixed | kRep64Bits | kFmtFloating,
+
+ kPackedBool = kFkPackedVarint | kRep8Bits,
+
+ kPackedFixed32 = kFkPackedFixed | kRep32Bits | kFmtUnsigned,
+ kPackedUInt32 = kFkPackedVarint | kRep32Bits | kFmtUnsigned,
+ kPackedSFixed32 = kFkPackedFixed | kRep32Bits | kFmtSigned,
+ kPackedInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned,
+ kPackedSInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned | kTvZigZag,
+ kPackedFloat = kFkPackedFixed | kRep32Bits | kFmtFloating,
+ kPackedEnum = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvEnum,
+ kPackedEnumRange = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvRange,
+ kPackedOpenEnum = kFkPackedVarint | kRep32Bits | kFmtEnum,
+
+ kPackedFixed64 = kFkPackedFixed | kRep64Bits | kFmtUnsigned,
+ kPackedUInt64 = kFkPackedVarint | kRep64Bits | kFmtUnsigned,
+ kPackedSFixed64 = kFkPackedFixed | kRep64Bits | kFmtSigned,
+ kPackedInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned,
+ kPackedSInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned | kTvZigZag,
+ kPackedDouble = kFkPackedFixed | kRep64Bits | kFmtFloating,
+
+ // String types:
+ kBytes = kFkString | kFmtArray,
+ kRawString = kFkString | kFmtUtf8 | kTvUtf8Debug,
+ kUtf8String = kFkString | kFmtUtf8 | kTvUtf8,
+
+ // Message types:
+ kMessage = kFkMessage,
+
+ // Map types:
+ kMap = kFkMap,
+};
+
+// clang-format on
+} // namespace field_layout
+
// PROTOBUF_TC_PARAM_DECL are the parameters for tailcall functions, it is
// defined in port_def.inc.
//
@@ -63,36 +246,6 @@ namespace internal {
// PROTOBUF_TC_PARAM_PASS passes values to match PROTOBUF_TC_PARAM_DECL.
#define PROTOBUF_TC_PARAM_PASS msg, ptr, ctx, table, hasbits, data
-// PROTOBUF_TC_PARSE_* decide which function is used to parse message-typed
-// fields. The guard macros are defined in port_def.inc.
-#if PROTOBUF_TC_STATIC_PARSE_SINGULAR1
-#define PROTOBUF_TC_PARSE_SINGULAR1(MESSAGE) MESSAGE::Tct_ParseS1
-#else
-#define PROTOBUF_TC_PARSE_SINGULAR1(MESSAGE) \
- ::google::protobuf::internal::TcParser::SingularParseMessage<MESSAGE, uint8_t>
-#endif // PROTOBUF_TC_STATIC_PARSE_SINGULAR1
-
-#if PROTOBUF_TC_STATIC_PARSE_SINGULAR2
-#define PROTOBUF_TC_PARSE_SINGULAR2(MESSAGE) MESSAGE::Tct_ParseS2
-#else
-#define PROTOBUF_TC_PARSE_SINGULAR2(MESSAGE) \
- ::google::protobuf::internal::TcParser::SingularParseMessage<MESSAGE, uint16_t>
-#endif // PROTOBUF_TC_STATIC_PARSE_SINGULAR2
-
-#if PROTOBUF_TC_STATIC_PARSE_REPEATED1
-#define PROTOBUF_TC_PARSE_REPEATED1(MESSAGE) MESSAGE::Tct_ParseR1
-#else
-#define PROTOBUF_TC_PARSE_REPEATED1(MESSAGE) \
- ::google::protobuf::internal::TcParser::RepeatedParseMessage<MESSAGE, uint8_t>
-#endif // PROTOBUF_TC_STATIC_PARSE_REPEATED1
-
-#if PROTOBUF_TC_STATIC_PARSE_REPEATED2
-#define PROTOBUF_TC_PARSE_REPEATED2(MESSAGE) MESSAGE::Tct_ParseR2
-#else
-#define PROTOBUF_TC_PARSE_REPEATED2(MESSAGE) \
- ::google::protobuf::internal::TcParser::RepeatedParseMessage<MESSAGE, uint16_t>
-#endif // PROTOBUF_TC_STATIC_PARSE_REPEATED2
-
#ifndef NDEBUG
template <size_t align>
#ifndef _MSC_VER
@@ -107,109 +260,137 @@ extern template void AlignFail<8>(uintptr_t);
#endif
// TcParser implements most of the parsing logic for tailcall tables.
-class TcParser final {
+class PROTOBUF_EXPORT TcParser final {
public:
static const char* GenericFallback(PROTOBUF_TC_PARAM_DECL);
static const char* GenericFallbackLite(PROTOBUF_TC_PARAM_DECL);
- // Dispatch to the designated parse function
- inline PROTOBUF_ALWAYS_INLINE static const char* TagDispatch(
- PROTOBUF_TC_PARAM_DECL) {
- const auto coded_tag = UnalignedLoad<uint16_t>(ptr);
- const size_t idx = coded_tag & table->fast_idx_mask;
- PROTOBUF_ASSUME((idx & 7) == 0);
- auto* fast_entry = table->fast_entry(idx >> 3);
- data = fast_entry->bits;
- data.data ^= coded_tag;
- PROTOBUF_MUSTTAIL return fast_entry->target(PROTOBUF_TC_PARAM_PASS);
- }
-
- // We can only safely call from field to next field if the call is optimized
- // to a proper tail call. Otherwise we blow through stack. Clang and gcc
- // reliably do this optimization in opt mode, but do not perform this in debug
- // mode. Luckily the structure of the algorithm is such that it's always
- // possible to just return and use the enclosing parse loop as a trampoline.
- static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL) {
- constexpr bool always_return = !PROTOBUF_TAILCALL;
- if (always_return || !ctx->DataAvailable(ptr)) {
- PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
- }
- PROTOBUF_MUSTTAIL return TagDispatch(PROTOBUF_TC_PARAM_PASS);
- }
-
static const char* ParseLoop(MessageLite* msg, const char* ptr,
ParseContext* ctx,
- const TcParseTableBase* table) {
- ScopedArenaSwap saved(msg, ctx);
- const arc_ui32 has_bits_offset = table->has_bits_offset;
- while (!ctx->Done(&ptr)) {
- arc_ui64 hasbits = 0;
- if (has_bits_offset) hasbits = RefAt<arc_ui32>(msg, has_bits_offset);
- ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {});
- if (ptr == nullptr) break;
- if (ctx->LastTag() != 1) break; // Ended on terminating tag
- }
- return ptr;
- }
+ const TcParseTableBase* table);
+
+ // Functions referenced by generated fast tables (numeric types):
+ // F: fixed V: varint Z: zigzag
+ // 8/32/64: storage type width (bits)
+ // S: singular R: repeated P: packed
+ // 1/2: tag length (bytes)
+
+ // Fixed:
+ static const char* FastF32S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF32S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF32R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF32R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF32P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF32P2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF64S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF64S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF64R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF64R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF64P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastF64P2(PROTOBUF_TC_PARAM_DECL);
+
+ // Varint:
+ static const char* FastV8S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV8S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV8R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV8R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV8P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV8P2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV32S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV32S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV32R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV32R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV32P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV32P2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV64S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV64S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV64R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV64R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV64P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastV64P2(PROTOBUF_TC_PARAM_DECL);
+
+ // Varint (with zigzag):
+ static const char* FastZ32S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ32S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ32R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ32R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ32P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ32P2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ64S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ64S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ64R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ64R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ64P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastZ64P2(PROTOBUF_TC_PARAM_DECL);
+
+ // Functions referenced by generated fast tables (closed enum):
+ // E: closed enum (N.B.: open enums use V32, above)
+ // r: enum range v: enum validator (_IsValid function)
+ // S: singular R: repeated
+ // 1/2: tag length (bytes)
+ static const char* FastErS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastErS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastErR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastErR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEvS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEvS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEvR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEvR2(PROTOBUF_TC_PARAM_DECL);
+
+ // Functions referenced by generated fast tables (string types):
+ // B: bytes S: string U: UTF-8 string
+ // (empty): ArenaStringPtr i: InlinedString
+ // S: singular R: repeated
+ // 1/2: tag length (bytes)
+ static const char* FastBS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastBS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastBR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastBR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastSS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastSS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastSR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastSR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUR2(PROTOBUF_TC_PARAM_DECL);
+
+ static const char* FastBiS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastBiS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastSiS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastSiS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUiS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUiS2(PROTOBUF_TC_PARAM_DECL);
+
+ // Functions referenced by generated fast tables (message types):
+ // M: message G: group
+ // S: singular R: repeated
+ // 1/2: tag length (bytes)
+ static const char* FastMS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGR2(PROTOBUF_TC_PARAM_DECL);
- template <typename FieldType, typename TagType>
- PROTOBUF_NOINLINE static const char* SingularParseMessage(
- PROTOBUF_TC_PARAM_DECL) {
- if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
- }
- ptr += sizeof(TagType);
- hasbits |= (arc_ui64{1} << data.hasbit_idx());
- auto& field = RefAt<FieldType*>(msg, data.offset());
- if (field == nullptr) {
- auto arena = ctx->data().arena;
- if (Arena::is_arena_constructable<FieldType>::value) {
- field = Arena::CreateMessage<FieldType>(arena);
- } else {
- field = Arena::Create<FieldType>(arena);
- }
- }
- SyncHasbits(msg, hasbits, table);
- return ctx->ParseMessage(field, ptr);
- }
-
- template <typename FieldType, typename TagType>
- PROTOBUF_NOINLINE static const char* RepeatedParseMessage(
- PROTOBUF_TC_PARAM_DECL) {
- if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ template <typename T>
+ static inline T& RefAt(void* x, size_t offset) {
+ T* target = reinterpret_cast<T*>(static_cast<char*>(x) + offset);
+#ifndef NDEBUG
+ if (PROTOBUF_PREDICT_FALSE(
+ reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) {
+ AlignFail<alignof(T)>(reinterpret_cast<uintptr_t>(target));
}
- ptr += sizeof(TagType);
- auto& field = RefAt<RepeatedPtrField<FieldType>>(msg, data.offset());
- SyncHasbits(msg, hasbits, table);
- ptr = ctx->ParseMessage(field.Add(), ptr);
- return ptr;
+#endif
+ return *target;
}
- template <typename LayoutType, typename TagType>
- static const char* SingularFixed(PROTOBUF_TC_PARAM_DECL);
- template <typename LayoutType, typename TagType>
- static const char* RepeatedFixed(PROTOBUF_TC_PARAM_DECL);
- template <typename LayoutType, typename TagType>
- static const char* PackedFixed(PROTOBUF_TC_PARAM_DECL);
-
- enum VarintDecode { kNoConversion = 0, kZigZag = 1 };
- template <typename FieldType, typename TagType, VarintDecode zigzag>
- static const char* SingularVarint(PROTOBUF_TC_PARAM_DECL);
- template <typename FieldType, typename TagType, VarintDecode zigzag>
- static const char* RepeatedVarint(PROTOBUF_TC_PARAM_DECL);
- template <typename FieldType, typename TagType, VarintDecode zigzag>
- static const char* PackedVarint(PROTOBUF_TC_PARAM_DECL);
-
- enum Utf8Type { kNoUtf8 = 0, kUtf8 = 1, kUtf8ValidateOnly = 2 };
- template <typename TagType, Utf8Type utf8>
- static const char* SingularString(PROTOBUF_TC_PARAM_DECL);
- template <typename TagType, Utf8Type utf8>
- static const char* RepeatedString(PROTOBUF_TC_PARAM_DECL);
-
template <typename T>
- static inline T& RefAt(void* x, size_t offset) {
- T* target = reinterpret_cast<T*>(static_cast<char*>(x) + offset);
+ static inline const T& RefAt(const void* x, size_t offset) {
+ const T* target =
+ reinterpret_cast<const T*>(static_cast<const char*>(x) + offset);
#ifndef NDEBUG
if (PROTOBUF_PREDICT_FALSE(
reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) {
@@ -219,6 +400,25 @@ class TcParser final {
return *target;
}
+ // Mini parsing:
+ //
+ // This function parses a field from incoming data based on metadata stored in
+ // the message definition. If the field is not defined in the message, it is
+ // stored in either the ExtensionSet (if applicable) or the UnknownFieldSet.
+ //
+ // NOTE: Currently, this function only calls the table-level fallback
+ // function, so it should only be called as the fallback from fast table
+ // parsing.
+ static const char* MiniParse(PROTOBUF_TC_PARAM_DECL);
+
+ private:
+ friend class GeneratedTcTableLiteTest;
+
+ template <typename TagType, bool group_coding>
+ static inline const char* SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType, bool group_coding>
+ static inline const char* RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
+
static inline PROTOBUF_ALWAYS_INLINE void SyncHasbits(
MessageLite* msg, arc_ui64 hasbits, const TcParseTableBase* table) {
const arc_ui32 has_bits_offset = table->has_bits_offset;
@@ -229,37 +429,14 @@ class TcParser final {
}
}
- protected:
- static inline PROTOBUF_ALWAYS_INLINE const char* ToParseLoop(
- PROTOBUF_TC_PARAM_DECL) {
- (void)data;
- (void)ctx;
- SyncHasbits(msg, hasbits, table);
- return ptr;
- }
+ static const char* TagDispatch(PROTOBUF_TC_PARAM_DECL);
+ static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL);
+ static const char* ToParseLoop(PROTOBUF_TC_PARAM_DECL);
+ static const char* Error(PROTOBUF_TC_PARAM_DECL);
- static inline PROTOBUF_ALWAYS_INLINE const char* Error(
- PROTOBUF_TC_PARAM_DECL) {
- (void)data;
- (void)ctx;
- (void)ptr;
- SyncHasbits(msg, hasbits, table);
- return nullptr;
- }
-
- class ScopedArenaSwap final {
- public:
- ScopedArenaSwap(MessageLite* msg, ParseContext* ctx)
- : ctx_(ctx), saved_(ctx->data().arena) {
- ctx_->data().arena = msg->GetArenaForAllocation();
- }
- ScopedArenaSwap(const ScopedArenaSwap&) = delete;
- ~ScopedArenaSwap() { ctx_->data().arena = saved_; }
+ static const char* FastUnknownEnumFallback(PROTOBUF_TC_PARAM_DECL);
- private:
- ParseContext* const ctx_;
- Arena* const saved_;
- };
+ class ScopedArenaSwap;
template <class MessageBaseT, class UnknownFieldsT>
static const char* GenericFallbackImpl(PROTOBUF_TC_PARAM_DECL) {
@@ -267,14 +444,12 @@ class TcParser final {
if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr /* NOLINT */
SyncHasbits(msg, hasbits, table);
- arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
+ arc_ui32 tag = data.tag();
if ((tag & 7) == WireFormatLite::WIRETYPE_END_GROUP || tag == 0) {
ctx->SetLastTag(tag);
return ptr;
}
- (void)data;
arc_ui32 num = tag >> 3;
if (table->extension_range_low <= num &&
num <= table->extension_range_high) {
@@ -288,10 +463,79 @@ class TcParser final {
ptr, ctx);
#undef CHK_
}
-};
-// Declare helper functions:
-#include <google/protobuf/generated_message_tctable_impl.inc>
+ // Note: `inline` is needed on template function declarations below to avoid
+ // -Wattributes diagnostic in GCC.
+
+ // Implementations for fast fixed field parsing functions:
+ template <typename LayoutType, typename TagType>
+ static inline const char* SingularFixed(PROTOBUF_TC_PARAM_DECL);
+ template <typename LayoutType, typename TagType>
+ static inline const char* RepeatedFixed(PROTOBUF_TC_PARAM_DECL);
+ template <typename LayoutType, typename TagType>
+ static inline const char* PackedFixed(PROTOBUF_TC_PARAM_DECL);
+
+ // Implementations for fast varint field parsing functions:
+ template <typename FieldType, typename TagType, bool zigzag = false>
+ static inline const char* SingularVarint(PROTOBUF_TC_PARAM_DECL);
+ template <typename FieldType, typename TagType, bool zigzag = false>
+ static inline const char* RepeatedVarint(PROTOBUF_TC_PARAM_DECL);
+ template <typename FieldType, typename TagType, bool zigzag = false>
+ static inline const char* PackedVarint(PROTOBUF_TC_PARAM_DECL);
+
+ // Helper for ints > 127:
+ template <typename FieldType, typename TagType, bool zigzag = false>
+ static const char* SingularVarBigint(PROTOBUF_TC_PARAM_DECL);
+
+ // Implementations for fast enum field parsing functions:
+ template <typename TagType, uint16_t xform_val>
+ static inline const char* SingularEnum(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType, uint16_t xform_val>
+ static inline const char* RepeatedEnum(PROTOBUF_TC_PARAM_DECL);
+
+ // Implementations for fast string field parsing functions:
+ enum Utf8Type { kNoUtf8 = 0, kUtf8 = 1, kUtf8ValidateOnly = 2 };
+ template <typename TagType, Utf8Type utf8>
+ static inline const char* SingularString(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType, Utf8Type utf8>
+ static inline const char* RepeatedString(PROTOBUF_TC_PARAM_DECL);
+
+ // Mini field lookup:
+ static const TcParseTableBase::FieldEntry* FindFieldEntry(
+ const TcParseTableBase* table, arc_ui32 field_num);
+ static StringPiece MessageName(const TcParseTableBase* table);
+ static StringPiece FieldName(const TcParseTableBase* table,
+ const TcParseTableBase::FieldEntry*);
+ static bool ChangeOneof(const TcParseTableBase* table,
+ const TcParseTableBase::FieldEntry& entry,
+ arc_ui32 field_num, ParseContext* ctx,
+ MessageLite* msg);
+
+ // UTF-8 validation:
+ static void ReportFastUtf8Error(arc_ui32 decoded_tag,
+ const TcParseTableBase* table);
+ static bool MpVerifyUtf8(StringPiece wire_bytes,
+ const TcParseTableBase* table,
+ const TcParseTableBase::FieldEntry& entry,
+ uint16_t xform_val);
+
+ // For FindFieldEntry tests:
+ friend class FindFieldEntryTest;
+ static constexpr const arc_ui32 kMtSmallScanSize = 4;
+
+ // Mini parsing:
+ static const char* MpVarint(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpPackedVarint(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpFixed(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpPackedFixed(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpString(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpRepeatedString(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpMessage(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpMap(PROTOBUF_TC_PARAM_DECL);
+};
} // namespace internal
} // namespace protobuf
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.inc b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.inc
deleted file mode 100644
index a02e65e2c0..0000000000
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.inc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// clang-format off
-#ifdef PROTOBUF_TCT_SOURCE
-#define PROTOBUF_TCT_EXTERN
-#else
-#define PROTOBUF_TCT_EXTERN extern
-#endif
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<arc_ui64, uint8_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<arc_ui64, uint8_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<arc_ui64, uint8_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<arc_ui32, uint8_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<arc_ui32, uint8_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<arc_ui32, uint8_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_ui64, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_ui64, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_ui64, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_ui32, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_ui32, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_ui32, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_i64, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_i64, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_i64, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_i32, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_i32, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_i32, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<bool, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<bool, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<bool, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<arc_ui64, uint16_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<arc_ui64, uint16_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<arc_ui64, uint16_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<arc_ui32, uint16_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<arc_ui32, uint16_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<arc_ui32, uint16_t>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_ui64, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_ui64, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_ui64, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_ui32, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_ui32, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_ui32, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_i64, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_i64, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_i64, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<arc_i32, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<arc_i32, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<arc_i32, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<bool, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<bool, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<bool, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL);
-PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL);
-#undef PROTOBUF_TCT_EXTERN
-// clang-format on
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_lite.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_lite.cc
index 35071abd76..d3f97fd9f3 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_lite.cc
@@ -29,12 +29,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdint>
+#include <numeric>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_tctable_decl.h>
#include <google/protobuf/generated_message_tctable_impl.h>
+#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
// clang-format off
@@ -45,6 +47,12 @@ namespace google {
namespace protobuf {
namespace internal {
+using FieldEntry = TcParseTableBase::FieldEntry;
+
+//////////////////////////////////////////////////////////////////////////////
+// Template instantiations:
+//////////////////////////////////////////////////////////////////////////////
+
#ifndef NDEBUG
template void AlignFail<4>(uintptr_t);
template void AlignFail<8>(uintptr_t);
@@ -54,6 +62,285 @@ const char* TcParser::GenericFallbackLite(PROTOBUF_TC_PARAM_DECL) {
return GenericFallbackImpl<MessageLite, TProtoStringType>(PROTOBUF_TC_PARAM_PASS);
}
+//////////////////////////////////////////////////////////////////////////////
+// Core fast parsing implementation:
+//////////////////////////////////////////////////////////////////////////////
+
+class TcParser::ScopedArenaSwap final {
+ public:
+ ScopedArenaSwap(MessageLite* msg, ParseContext* ctx)
+ : ctx_(ctx), saved_(ctx->data().arena) {
+ ctx_->data().arena = msg->GetArenaForAllocation();
+ }
+ ScopedArenaSwap(const ScopedArenaSwap&) = delete;
+ ~ScopedArenaSwap() { ctx_->data().arena = saved_; }
+
+ private:
+ ParseContext* const ctx_;
+ Arena* const saved_;
+};
+
+PROTOBUF_NOINLINE const char* TcParser::ParseLoop(
+ MessageLite* msg, const char* ptr, ParseContext* ctx,
+ const TcParseTableBase* table) {
+ ScopedArenaSwap saved(msg, ctx);
+ const arc_ui32 has_bits_offset = table->has_bits_offset;
+ while (!ctx->Done(&ptr)) {
+ arc_ui64 hasbits = 0;
+ if (has_bits_offset) hasbits = RefAt<arc_ui32>(msg, has_bits_offset);
+ ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {});
+ if (ptr == nullptr) break;
+ if (ctx->LastTag() != 1) break; // Ended on terminating tag
+ }
+ return ptr;
+}
+
+ // Dispatch to the designated parse function
+inline PROTOBUF_ALWAYS_INLINE const char* TcParser::TagDispatch(
+ PROTOBUF_TC_PARAM_DECL) {
+ const auto coded_tag = UnalignedLoad<uint16_t>(ptr);
+ const size_t idx = coded_tag & table->fast_idx_mask;
+ PROTOBUF_ASSUME((idx & 7) == 0);
+ auto* fast_entry = table->fast_entry(idx >> 3);
+ data = fast_entry->bits;
+ data.data ^= coded_tag;
+ PROTOBUF_MUSTTAIL return fast_entry->target(PROTOBUF_TC_PARAM_PASS);
+}
+
+// We can only safely call from field to next field if the call is optimized
+// to a proper tail call. Otherwise we blow through stack. Clang and gcc
+// reliably do this optimization in opt mode, but do not perform this in debug
+// mode. Luckily the structure of the algorithm is such that it's always
+// possible to just return and use the enclosing parse loop as a trampoline.
+inline PROTOBUF_ALWAYS_INLINE const char* TcParser::ToTagDispatch(
+ PROTOBUF_TC_PARAM_DECL) {
+ constexpr bool always_return = !PROTOBUF_TAILCALL;
+ if (always_return || !ctx->DataAvailable(ptr)) {
+ PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
+ }
+ PROTOBUF_MUSTTAIL return TagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+inline PROTOBUF_ALWAYS_INLINE const char* TcParser::ToParseLoop(
+ PROTOBUF_TC_PARAM_DECL) {
+ (void)data;
+ (void)ctx;
+ SyncHasbits(msg, hasbits, table);
+ return ptr;
+}
+
+inline PROTOBUF_ALWAYS_INLINE const char* TcParser::Error(
+ PROTOBUF_TC_PARAM_DECL) {
+ (void)data;
+ (void)ctx;
+ (void)ptr;
+ SyncHasbits(msg, hasbits, table);
+ return nullptr;
+}
+
+// On the fast path, a (matching) 1-byte tag already has the decoded value.
+static arc_ui32 FastDecodeTag(uint8_t coded_tag) {
+ return coded_tag;
+}
+
+// On the fast path, a (matching) 2-byte tag always needs to be decoded.
+static arc_ui32 FastDecodeTag(uint16_t coded_tag) {
+ arc_ui32 result = coded_tag;
+ result += static_cast<int8_t>(coded_tag);
+ return result >> 1;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Core mini parsing implementation:
+//////////////////////////////////////////////////////////////////////////////
+
+// Field lookup table layout:
+//
+// Because it consists of a series of variable-length segments, the lookuup
+// table is organized within an array of uint16_t, and each element is either
+// a uint16_t or a arc_ui32 stored little-endian as a pair of uint16_t.
+//
+// Its fundamental building block maps 16 contiguously ascending field numbers
+// to their locations within the field entry table:
+
+struct SkipEntry16 {
+ uint16_t skipmap;
+ uint16_t field_entry_offset;
+};
+
+// The skipmap is a bitfield of which of those field numbers do NOT have a
+// field entry. The lowest bit of the skipmap corresponds to the lowest of
+// the 16 field numbers, so if a proto had only fields 1, 2, 3, and 7, the
+// skipmap would contain 0b11111111'10111000.
+//
+// The field lookup table begins with a single 32-bit skipmap that maps the
+// field numbers 1 through 32. This is because the majority of proto
+// messages only contain fields numbered 1 to 32.
+//
+// The rest of the lookup table is a repeated series of
+// { 32-bit field #, #SkipEntry16s, {SkipEntry16...} }
+// That is, the next thing is a pair of uint16_t that form the next
+// lowest field number that the lookup table handles. If this number is -1,
+// that is the end of the table. Then there is a uint16_t that is
+// the number of contiguous SkipEntry16 entries that follow, and then of
+// course the SkipEntry16s themselves.
+
+// Originally developed and tested at https://godbolt.org/z/vbc7enYcf
+
+// Returns the address of the field for `tag` in the table's field entries.
+// Returns nullptr if the field was not found.
+const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
+ const TcParseTableBase* table, arc_ui32 field_num) {
+ const FieldEntry* const field_entries = table->field_entries_begin();
+
+ arc_ui32 fstart = 1;
+ arc_ui32 adj_fnum = field_num - fstart;
+
+ if (PROTOBUF_PREDICT_TRUE(adj_fnum < 32)) {
+ arc_ui32 skipmap = table->skipmap32;
+ arc_ui32 skipbit = 1 << adj_fnum;
+ if (PROTOBUF_PREDICT_FALSE(skipmap & skipbit)) return nullptr;
+ skipmap &= skipbit - 1;
+#if (__GNUC__ || __clang__) && __POPCNT__
+ // Note: here and below, skipmap typically has very few set bits
+ // (31 in the worst case, but usually zero) so a loop isn't that
+ // bad, and a compiler-generated popcount is typically only
+ // worthwhile if the processor itself has hardware popcount support.
+ adj_fnum -= __builtin_popcount(skipmap);
+#else
+ while (skipmap) {
+ --adj_fnum;
+ skipmap &= skipmap - 1;
+ }
+#endif
+ auto* entry = field_entries + adj_fnum;
+ PROTOBUF_ASSUME(entry != nullptr);
+ return entry;
+ }
+ const uint16_t* lookup_table = table->field_lookup_begin();
+ for (;;) {
+#ifdef PROTOBUF_LITTLE_ENDIAN
+ memcpy(&fstart, lookup_table, sizeof(fstart));
+#else
+ fstart = lookup_table[0] | (lookup_table[1] << 16);
+#endif
+ lookup_table += sizeof(fstart) / sizeof(*lookup_table);
+ arc_ui32 num_skip_entries = *lookup_table++;
+ if (field_num < fstart) return nullptr;
+ adj_fnum = field_num - fstart;
+ arc_ui32 skip_num = adj_fnum / 16;
+ if (PROTOBUF_PREDICT_TRUE(skip_num < num_skip_entries)) {
+ // for each group of 16 fields we have:
+ // a bitmap of 16 bits
+ // a 16-bit field-entry offset for the first of them.
+ auto* skip_data = lookup_table + (adj_fnum / 16) * (sizeof(SkipEntry16) /
+ sizeof(uint16_t));
+ SkipEntry16 se = {skip_data[0], skip_data[1]};
+ adj_fnum &= 15;
+ arc_ui32 skipmap = se.skipmap;
+ uint16_t skipbit = 1 << adj_fnum;
+ if (PROTOBUF_PREDICT_FALSE(skipmap & skipbit)) return nullptr;
+ skipmap &= skipbit - 1;
+ adj_fnum += se.field_entry_offset;
+#if (__GNUC__ || __clang__) && __POPCNT__
+ adj_fnum -= __builtin_popcount(skipmap);
+#else
+ while (skipmap) {
+ --adj_fnum;
+ skipmap &= skipmap - 1;
+ }
+#endif
+ auto* entry = field_entries + adj_fnum;
+ PROTOBUF_ASSUME(entry != nullptr);
+ return entry;
+ }
+ lookup_table +=
+ num_skip_entries * (sizeof(SkipEntry16) / sizeof(*lookup_table));
+ }
+}
+
+// Field names are stored in a format of:
+//
+// 1) A table of name sizes, one byte each, from 1 to 255 per name.
+// `entries` is the size of this first table.
+// 1a) padding bytes, so the table of name sizes is a multiple of
+// eight bytes in length. They are zero.
+//
+// 2) All the names, concatenated, with neither separation nor termination.
+//
+// This is designed to be compact but not particularly fast to retrieve.
+// In particular, it takes O(n) to retrieve the name of the n'th field,
+// which is usually fine because most protos have fewer than 10 fields.
+static StringPiece FindName(const char* name_data, size_t entries,
+ size_t index) {
+ // The compiler unrolls these... if this isn't fast enough,
+ // there's an AVX version at https://godbolt.org/z/eojrjqzfr
+ // ARM-compatible version at https://godbolt.org/z/n5YT5Ee85
+
+ // The field name sizes are padded up to a multiple of 8, so we
+ // must pad them here.
+ size_t num_sizes = (entries + 7) & -8;
+ auto* uint8s = reinterpret_cast<const uint8_t*>(name_data);
+ size_t pos = std::accumulate(uint8s, uint8s + index, num_sizes);
+ size_t size = name_data[index];
+ auto* start = &name_data[pos];
+ return {start, size};
+}
+
+StringPiece TcParser::MessageName(const TcParseTableBase* table) {
+ return FindName(table->name_data(), table->num_field_entries + 1, 0);
+}
+
+StringPiece TcParser::FieldName(const TcParseTableBase* table,
+ const FieldEntry* field_entry) {
+ const FieldEntry* const field_entries = table->field_entries_begin();
+ auto field_index = static_cast<size_t>(field_entry - field_entries);
+ return FindName(table->name_data(), table->num_field_entries + 1,
+ field_index + 1);
+}
+
+const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {
+ arc_ui32 tag;
+ ptr = ReadTag(ptr, &tag);
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr;
+
+ auto* entry = FindFieldEntry(table, tag >> 3);
+ if (entry == nullptr) {
+ data.data = tag;
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ // The handler may need the tag and the entry to resolve fallback logic. Both
+ // of these are 32 bits, so pack them into (the 64-bit) `data`. Since we can't
+ // pack the entry pointer itself, just pack its offset from `table`.
+ arc_ui64 entry_offset = reinterpret_cast<const char*>(entry) -
+ reinterpret_cast<const char*>(table);
+ data.data = entry_offset << 32 | tag;
+
+ using field_layout::FieldKind;
+ auto field_type = entry->type_card & FieldKind::kFkMask;
+ switch (field_type) {
+ case FieldKind::kFkNone:
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkVarint:
+ PROTOBUF_MUSTTAIL return MpVarint(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkPackedVarint:
+ PROTOBUF_MUSTTAIL return MpPackedVarint(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkFixed:
+ PROTOBUF_MUSTTAIL return MpFixed(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkPackedFixed:
+ PROTOBUF_MUSTTAIL return MpPackedFixed(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkString:
+ PROTOBUF_MUSTTAIL return MpString(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkMessage:
+ PROTOBUF_MUSTTAIL return MpMessage(PROTOBUF_TC_PARAM_PASS);
+ case FieldKind::kFkMap:
+ PROTOBUF_MUSTTAIL return MpMap(PROTOBUF_TC_PARAM_PASS);
+ default:
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+}
+
namespace {
// Offset returns the address `offset` bytes after `base`.
@@ -72,13 +359,100 @@ inline PROTOBUF_ALWAYS_INLINE void InvertPacked(TcFieldData& data) {
} // namespace
//////////////////////////////////////////////////////////////////////////////
+// Message fields
+//////////////////////////////////////////////////////////////////////////////
+
+template <typename TagType, bool group_coding>
+inline PROTOBUF_ALWAYS_INLINE
+const char* TcParser::SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ auto saved_tag = UnalignedLoad<TagType>(ptr);
+ ptr += sizeof(TagType);
+ hasbits |= (arc_ui64{1} << data.hasbit_idx());
+ auto& field = RefAt<MessageLite*>(msg, data.offset());
+ if (field == nullptr) {
+ const MessageLite* default_instance =
+ table->field_aux(data.aux_idx())->message_default;
+ field = default_instance->New(ctx->data().arena);
+ }
+ SyncHasbits(msg, hasbits, table);
+ if (group_coding) {
+ return ctx->ParseGroup(field, ptr, FastDecodeTag(saved_tag));
+ }
+ return ctx->ParseMessage(field, ptr);
+}
+
+const char* TcParser::FastMS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastMS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastGS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastGS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, bool group_coding>
+inline PROTOBUF_ALWAYS_INLINE
+const char* TcParser::RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ auto saved_tag = UnalignedLoad<TagType>(ptr);
+ ptr += sizeof(TagType);
+ SyncHasbits(msg, hasbits, table);
+ const MessageLite* default_instance =
+ table->field_aux(data.aux_idx())->message_default;
+ auto& field = RefAt<RepeatedPtrFieldBase>(msg, data.offset());
+ MessageLite* submsg =
+ field.Add<GenericTypeHandler<MessageLite>>(default_instance);
+ if (group_coding) {
+ return ctx->ParseGroup(submsg, ptr, FastDecodeTag(saved_tag));
+ }
+ return ctx->ParseMessage(submsg, ptr);
+}
+
+const char* TcParser::FastMR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastMR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastGR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastGR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+//////////////////////////////////////////////////////////////////////////////
// Fixed fields
//////////////////////////////////////////////////////////////////////////////
template <typename LayoutType, typename TagType>
-const char* TcParser::SingularFixed(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularFixed(
+ PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
ptr += sizeof(TagType); // Consume tag
hasbits |= (arc_ui64{1} << data.hasbit_idx());
@@ -87,8 +461,26 @@ const char* TcParser::SingularFixed(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
+const char* TcParser::FastF32S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularFixed<arc_ui32, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF32S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularFixed<arc_ui32, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF64S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularFixed<arc_ui64, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF64S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularFixed<arc_ui64, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
template <typename LayoutType, typename TagType>
-const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedFixed(
+ PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
// Check if the field can be parsed as packed repeated:
constexpr WireFormatLite::WireType fallback_wt =
@@ -98,7 +490,7 @@ const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
if (data.coded_tag<TagType>() == 0) {
return PackedFixed<LayoutType, TagType>(PROTOBUF_TC_PARAM_PASS);
} else {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
}
auto& field = RefAt<RepeatedField<LayoutType>>(msg, data.offset());
@@ -118,18 +510,40 @@ const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
+const char* TcParser::FastF32R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedFixed<arc_ui32, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF32R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedFixed<arc_ui32, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF64R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedFixed<arc_ui64, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF64R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedFixed<arc_ui64, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+// Note: some versions of GCC will fail with error "function not inlinable" if
+// corecursive functions are both marked with PROTOBUF_ALWAYS_INLINE (Clang
+// accepts this). We can still apply the attribute to one of the two functions,
+// just not both (so we do mark the Repeated variant as always inlined). This
+// also applies to PackedVarint, below.
template <typename LayoutType, typename TagType>
const char* TcParser::PackedFixed(PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
// Try parsing as non-packed repeated:
constexpr WireFormatLite::WireType fallback_wt =
sizeof(LayoutType) == 4 ? WireFormatLite::WIRETYPE_FIXED32
- : WireFormatLite::WIRETYPE_FIXED64;
+ : WireFormatLite::WIRETYPE_FIXED64;
InvertPacked<fallback_wt>(data);
if (data.coded_tag<TagType>() == 0) {
return RepeatedFixed<LayoutType, TagType>(PROTOBUF_TC_PARAM_PASS);
} else {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
}
ptr += sizeof(TagType);
@@ -143,6 +557,23 @@ const char* TcParser::PackedFixed(PROTOBUF_TC_PARAM_DECL) {
static_cast<RepeatedField<LayoutType>*>(&field));
}
+const char* TcParser::FastF32P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedFixed<arc_ui32, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF32P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedFixed<arc_ui32, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF64P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedFixed<arc_ui64, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastF64P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedFixed<arc_ui64, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
//////////////////////////////////////////////////////////////////////////////
// Varint fields
//////////////////////////////////////////////////////////////////////////////
@@ -276,36 +707,80 @@ inline PROTOBUF_ALWAYS_INLINE const char* ParseVarint(const char* p,
}
}
-template <typename FieldType,
- TcParser::VarintDecode = TcParser::VarintDecode::kNoConversion>
-FieldType ZigZagDecodeHelper(arc_ui64 value) {
+template <typename FieldType, bool zigzag = false>
+inline FieldType ZigZagDecodeHelper(arc_ui64 value) {
return static_cast<FieldType>(value);
}
template <>
-arc_i32 ZigZagDecodeHelper<arc_i32, TcParser::VarintDecode::kZigZag>(
- arc_ui64 value) {
+inline arc_i32 ZigZagDecodeHelper<arc_i32, true>(arc_ui64 value) {
return WireFormatLite::ZigZagDecode32(value);
}
template <>
-arc_i64 ZigZagDecodeHelper<arc_i64, TcParser::VarintDecode::kZigZag>(
- arc_ui64 value) {
+inline arc_i64 ZigZagDecodeHelper<arc_i64, true>(arc_ui64 value) {
return WireFormatLite::ZigZagDecode64(value);
}
+bool EnumIsValidAux(arc_i32 val, uint16_t xform_val,
+ TcParseTableBase::FieldAux aux) {
+ if (xform_val == field_layout::kTvRange) {
+ auto lo = aux.enum_range.start;
+ return lo <= val && val < (lo + aux.enum_range.length);
+ }
+ return aux.enum_validator(val);
+}
+
} // namespace
-template <typename FieldType, typename TagType, TcParser::VarintDecode zigzag>
-const char* TcParser::SingularVarint(PROTOBUF_TC_PARAM_DECL) {
+template <typename FieldType, typename TagType, bool zigzag>
+PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularVarint(
+ PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
ptr += sizeof(TagType); // Consume tag
hasbits |= (arc_ui64{1} << data.hasbit_idx());
+
+ // clang isn't smart enough to be able to only conditionally save
+ // registers to the stack, so we turn the integer-greater-than-128
+ // case into a separate routine.
+ if (PROTOBUF_PREDICT_FALSE(static_cast<int8_t>(*ptr) < 0)) {
+ PROTOBUF_MUSTTAIL return SingularVarBigint<FieldType, TagType, zigzag>(
+ PROTOBUF_TC_PARAM_PASS);
+ }
+
+ RefAt<FieldType>(msg, data.offset()) =
+ ZigZagDecodeHelper<FieldType, zigzag>(static_cast<uint8_t>(*ptr++));
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename FieldType, typename TagType, bool zigzag>
+PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint(
+ PROTOBUF_TC_PARAM_DECL) {
+ // For some reason clang wants to save 5 registers to the stack here,
+ // but we only need four for this code, so save the data we don't need
+ // to the stack. Happily, saving them this way uses regular store
+ // instructions rather than PUSH/POP, which saves time at the cost of greater
+ // code size, but for this heavily-used piece of code, that's fine.
+ struct Spill {
+ arc_ui64 field_data;
+ ::google::protobuf::MessageLite* msg;
+ const ::google::protobuf::internal::TcParseTableBase* table;
+ arc_ui64 hasbits;
+ };
+ volatile Spill spill = {data.data, msg, table, hasbits};
+
arc_ui64 tmp;
+ PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0);
ptr = ParseVarint(ptr, &tmp);
- if (ptr == nullptr) {
+
+ data.data = spill.field_data;
+ msg = spill.msg;
+ table = spill.table;
+ hasbits = spill.hasbits;
+
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
return Error(PROTOBUF_TC_PARAM_PASS);
}
RefAt<FieldType>(msg, data.offset()) =
@@ -313,15 +788,58 @@ const char* TcParser::SingularVarint(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-template <typename FieldType, typename TagType, TcParser::VarintDecode zigzag>
-PROTOBUF_NOINLINE const char* TcParser::RepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
+const char* TcParser::FastV8S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<bool, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV8S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<bool, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV32S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_ui32, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV32S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_ui32, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV64S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_ui64, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV64S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_ui64, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastZ32S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_i32, uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ32S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_i32, uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ64S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_i64, uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ64S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularVarint<arc_i64, uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename FieldType, typename TagType, bool zigzag>
+PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedVarint(
+ PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
// Try parsing as non-packed repeated:
InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data);
if (data.coded_tag<TagType>() == 0) {
return PackedVarint<FieldType, TagType, zigzag>(PROTOBUF_TC_PARAM_PASS);
} else {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
}
auto& field = RefAt<RepeatedField<FieldType>>(msg, data.offset());
@@ -341,14 +859,57 @@ PROTOBUF_NOINLINE const char* TcParser::RepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-template <typename FieldType, typename TagType, TcParser::VarintDecode zigzag>
-PROTOBUF_NOINLINE const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) {
+const char* TcParser::FastV8R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<bool, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV8R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<bool, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV32R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_ui32, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV32R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_ui32, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV64R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_ui64, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV64R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_ui64, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastZ32R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_i32, uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ32R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_i32, uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ64R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_i64, uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ64R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedVarint<arc_i64, uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+// See comment on PackedFixed for why this is not PROTOBUF_ALWAYS_INLINE.
+template <typename FieldType, typename TagType, bool zigzag>
+const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data);
if (data.coded_tag<TagType>() == 0) {
return RepeatedVarint<FieldType, TagType, zigzag>(PROTOBUF_TC_PARAM_PASS);
} else {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
}
ptr += sizeof(TagType);
@@ -371,14 +932,181 @@ PROTOBUF_NOINLINE const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) {
});
}
+const char* TcParser::FastV8P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<bool, uint8_t>(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV8P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<bool, uint16_t>(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV32P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_ui32, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV32P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_ui32, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV64P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_ui64, uint8_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastV64P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_ui64, uint16_t>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastZ32P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_i32, uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ32P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_i32, uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ64P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_i64, uint8_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastZ64P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedVarint<arc_i64, uint16_t, true>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Enum fields
+//////////////////////////////////////////////////////////////////////////////
+
+PROTOBUF_NOINLINE const char* TcParser::FastUnknownEnumFallback(
+ PROTOBUF_TC_PARAM_DECL) {
+ (void)msg;
+ (void)ctx;
+ (void)hasbits;
+
+ // If we know we want to put this field directly into the unknown field set,
+ // then we can skip the call to MiniParse and directly call table->fallback.
+ // However, we first have to update `data` to contain the decoded tag.
+ arc_ui32 tag;
+ ptr = ReadTag(ptr, &tag);
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ data.data = tag;
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, uint16_t xform_val>
+PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularEnum(
+ PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ const char* ptr2 = ptr; // Save for unknown enum case
+ ptr += sizeof(TagType); // Consume tag
+ arc_ui64 tmp;
+ ptr = ParseVarint(ptr, &tmp);
+ if (ptr == nullptr) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ const TcParseTableBase::FieldAux aux = *table->field_aux(data.aux_idx());
+ if (PROTOBUF_PREDICT_FALSE(
+ !EnumIsValidAux(static_cast<arc_i32>(tmp), xform_val, aux))) {
+ ptr = ptr2;
+ PROTOBUF_MUSTTAIL return FastUnknownEnumFallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ hasbits |= (arc_ui64{1} << data.hasbit_idx());
+ RefAt<arc_i32>(msg, data.offset()) = tmp;
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastErS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnum<uint8_t, field_layout::kTvRange>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastErS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnum<uint16_t, field_layout::kTvRange>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastEvS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnum<uint8_t, field_layout::kTvEnum>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastEvS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnum<uint16_t, field_layout::kTvEnum>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, uint16_t xform_val>
+PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedEnum(
+ PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data);
+ if (data.coded_tag<TagType>() == 0) {
+ // Packed parsing is handled by generated fallback.
+ PROTOBUF_MUSTTAIL return FastUnknownEnumFallback(PROTOBUF_TC_PARAM_PASS);
+ } else {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ }
+ auto& field = RefAt<RepeatedField<arc_i32>>(msg, data.offset());
+ auto expected_tag = UnalignedLoad<TagType>(ptr);
+ const TcParseTableBase::FieldAux aux = *table->field_aux(data.aux_idx());
+ do {
+ const char* ptr2 = ptr; // save for unknown enum case
+ ptr += sizeof(TagType);
+ arc_ui64 tmp;
+ ptr = ParseVarint(ptr, &tmp);
+ if (ptr == nullptr) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (PROTOBUF_PREDICT_FALSE(
+ !EnumIsValidAux(static_cast<arc_i32>(tmp), xform_val, aux))) {
+ // We can avoid duplicate work in MiniParse by directly calling
+ // table->fallback.
+ ptr = ptr2;
+ PROTOBUF_MUSTTAIL return FastUnknownEnumFallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ field.Add(static_cast<arc_i32>(tmp));
+ if (!ctx->DataAvailable(ptr)) {
+ break;
+ }
+ } while (UnalignedLoad<TagType>(ptr) == expected_tag);
+ return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::FastErR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnum<uint8_t, field_layout::kTvRange>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastErR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnum<uint16_t, field_layout::kTvRange>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastEvR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnum<uint8_t, field_layout::kTvEnum>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastEvR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnum<uint16_t, field_layout::kTvEnum>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
//////////////////////////////////////////////////////////////////////////////
// String/bytes fields
//////////////////////////////////////////////////////////////////////////////
// Defined in wire_format_lite.cc
-void PrintUTF8ErrorLog(const char* field_name, const char* operation_str,
+void PrintUTF8ErrorLog(StringPiece message_name,
+ StringPiece field_name, const char* operation_str,
bool emit_stacktrace);
+void TcParser::ReportFastUtf8Error(arc_ui32 decoded_tag,
+ const TcParseTableBase* table) {
+ arc_ui32 field_num = decoded_tag >> 3;
+ const auto* entry = FindFieldEntry(table, field_num);
+ PrintUTF8ErrorLog(MessageName(table), FieldName(table, entry), "parsing",
+ false);
+}
+
namespace {
PROTOBUF_NOINLINE
@@ -386,17 +1114,18 @@ const char* SingularStringParserFallback(ArenaStringPtr* s, const char* ptr,
EpsCopyInputStream* stream) {
int size = ReadSize(&ptr);
if (!ptr) return nullptr;
- return stream->ReadString(
- ptr, size, s->MutableNoArenaNoDefault(&GetEmptyStringAlreadyInited()));
+ return stream->ReadString(ptr, size, s->MutableNoCopy(nullptr));
}
} // namespace
template <typename TagType, TcParser::Utf8Type utf8>
-const char* TcParser::SingularString(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
+ PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
+ auto saved_tag = UnalignedLoad<TagType>(ptr);
ptr += sizeof(TagType);
hasbits |= (arc_ui64{1} << data.hasbit_idx());
auto& field = RefAt<ArenaStringPtr>(msg, data.offset());
@@ -417,16 +1146,63 @@ const char* TcParser::SingularString(PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(field.Get()))) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
- PrintUTF8ErrorLog("unknown", "parsing", false);
+ ReportFastUtf8Error(FastDecodeTag(saved_tag), table);
return utf8 == kUtf8 ? Error(PROTOBUF_TC_PARAM_PASS)
: ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
}
+const char* TcParser::FastBS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint8_t, kNoUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastBS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint16_t, kNoUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastSS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint8_t, kUtf8ValidateOnly>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastSS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint16_t, kUtf8ValidateOnly>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint8_t, kUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint16_t, kUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+// Inlined string variants:
+
+const char* TcParser::FastBiS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastBiS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastSiS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastSiS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUiS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUiS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+
template <typename TagType, TcParser::Utf8Type utf8>
-const char* TcParser::RepeatedString(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString(
+ PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
- return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
auto expected_tag = UnalignedLoad<TagType>(ptr);
auto& field = RefAt<RepeatedPtrField<TProtoStringType>>(msg, data.offset());
@@ -437,19 +1213,647 @@ const char* TcParser::RepeatedString(PROTOBUF_TC_PARAM_DECL) {
if (ptr == nullptr) {
return Error(PROTOBUF_TC_PARAM_PASS);
}
- if (utf8 != kNoUtf8) {
- if (PROTOBUF_PREDICT_FALSE(!IsStructurallyValidUTF8(*str))) {
- PrintUTF8ErrorLog("unknown", "parsing", false);
+ switch (utf8) {
+ case kNoUtf8:
+#ifdef NDEBUG
+ case kUtf8ValidateOnly:
+#endif
+ break;
+ default:
+ if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(*str))) {
+ break;
+ }
+ ReportFastUtf8Error(FastDecodeTag(expected_tag), table);
if (utf8 == kUtf8) return Error(PROTOBUF_TC_PARAM_PASS);
- }
+ break;
}
if (!ctx->DataAvailable(ptr)) break;
} while (UnalignedLoad<TagType>(ptr) == expected_tag);
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-#define PROTOBUF_TCT_SOURCE
-#include <google/protobuf/generated_message_tctable_impl.inc>
+const char* TcParser::FastBR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kNoUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastBR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kNoUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastSR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kUtf8ValidateOnly>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastSR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kUtf8ValidateOnly>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kUtf8>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Mini parsing
+//////////////////////////////////////////////////////////////////////////////
+
+namespace {
+inline void SetHas(const TcParseTableBase* table, const FieldEntry& entry,
+ MessageLite* msg, arc_ui64& hasbits) {
+ arc_i32 has_idx = entry.has_idx;
+ if (has_idx < 32) {
+ hasbits |= arc_ui64{1} << has_idx;
+ } else {
+ auto* hasblocks = &TcParser::RefAt<arc_ui32>(msg, table->has_bits_offset);
+#if defined(__x86_64__) && defined(__GNUC__)
+ asm("bts %1, %0\n" : "+m"(*hasblocks) : "r"(has_idx));
+#else
+ auto& hasblock = hasblocks[has_idx / 32];
+ hasblock |= arc_ui32{1} << (has_idx % 32);
+#endif
+ }
+}
+} // namespace
+
+// Destroys any existing oneof union member (if necessary). Returns true if the
+// caller is responsible for initializing the object, or false if the field
+// already has the desired case.
+bool TcParser::ChangeOneof(const TcParseTableBase* table,
+ const TcParseTableBase::FieldEntry& entry,
+ arc_ui32 field_num, ParseContext* ctx,
+ MessageLite* msg) {
+ // The _oneof_case_ array offset is stored in the first aux entry.
+ arc_ui32 oneof_case_offset = table->field_aux(0u)->offset;
+ // The _oneof_case_ array index is stored in the has-bit index.
+ arc_ui32* oneof_case =
+ &TcParser::RefAt<arc_ui32>(msg, oneof_case_offset) + entry.has_idx;
+ arc_ui32 current_case = *oneof_case;
+ *oneof_case = field_num;
+
+ if (current_case == 0) {
+ // If the member is empty, we don't have anything to clear. Caller is
+ // responsible for creating a new member object.
+ return true;
+ }
+ if (current_case == field_num) {
+ // If the member is already active, then it should be merged. We're done.
+ return false;
+ }
+ // Look up the value that is already stored, and dispose of it if necessary.
+ const FieldEntry* current_entry = FindFieldEntry(table, current_case);
+ uint16_t current_kind = current_entry->type_card & field_layout::kFkMask;
+ uint16_t current_rep = current_entry->type_card & field_layout::kRepMask;
+ if (current_kind == field_layout::kFkString) {
+ switch (current_rep) {
+ case field_layout::kRepAString: {
+ auto& field = RefAt<ArenaStringPtr>(msg, current_entry->offset);
+ field.Destroy();
+ break;
+ }
+ case field_layout::kRepSString:
+ case field_layout::kRepIString:
+ default:
+ GOOGLE_LOG(DFATAL) << "string rep not handled: "
+ << (current_rep >> field_layout::kRepShift);
+ return true;
+ }
+ } else if (current_kind == field_layout::kFkMessage) {
+ switch (current_rep) {
+ case field_layout::kRepMessage:
+ case field_layout::kRepGroup:
+ case field_layout::kRepIWeak: {
+ auto& field = RefAt<MessageLite*>(msg, current_entry->offset);
+ if (!ctx->data().arena) {
+ delete field;
+ }
+ break;
+ }
+ default:
+ GOOGLE_LOG(DFATAL) << "message rep not handled: "
+ << (current_rep >> field_layout::kRepShift);
+ break;
+ }
+ }
+ return true;
+}
+
+const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ const uint16_t card = type_card & field_layout::kFcMask;
+
+ // Check for repeated parsing (wiretype fallback is handled there):
+ if (card == field_layout::kFcRepeated) {
+ PROTOBUF_MUSTTAIL return MpRepeatedFixed(PROTOBUF_TC_PARAM_PASS);
+ }
+ // Check for mismatched wiretype:
+ const uint16_t rep = type_card & field_layout::kRepMask;
+ const arc_ui32 decoded_wiretype = data.tag() & 7;
+ if (rep == field_layout::kRep64Bits) {
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED64) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ } else {
+ GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ }
+ // Set the field present:
+ if (card == field_layout::kFcOptional) {
+ SetHas(table, entry, msg, hasbits);
+ } else if (card == field_layout::kFcOneof) {
+ ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
+ }
+ // Copy the value:
+ if (rep == field_layout::kRep64Bits) {
+ std::memcpy(Offset(msg, entry.offset), ptr, sizeof(arc_ui64));
+ ptr += sizeof(arc_ui64);
+ } else {
+ std::memcpy(Offset(msg, entry.offset), ptr, sizeof(arc_ui32));
+ ptr += sizeof(arc_ui32);
+ }
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const arc_ui32 decoded_tag = data.tag();
+ const arc_ui32 decoded_wiretype = decoded_tag & 7;
+
+ // Check for packed repeated fallback:
+ if (decoded_wiretype == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ PROTOBUF_MUSTTAIL return MpPackedFixed(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ const uint16_t type_card = entry.type_card;
+ const uint16_t rep = type_card & field_layout::kRepMask;
+ if (rep == field_layout::kRep64Bits) {
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED64) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ auto& field = RefAt<RepeatedField<arc_ui64>>(msg, entry.offset);
+ constexpr auto size = sizeof(arc_ui64);
+ const char* ptr2 = ptr;
+ arc_ui32 next_tag;
+ do {
+ ptr = ptr2;
+ std::memcpy(field.Add(), ptr, size);
+ ptr += size;
+ if (!ctx->DataAvailable(ptr)) break;
+ ptr2 = ReadTag(ptr, &next_tag);
+ } while (next_tag == decoded_tag);
+ } else {
+ GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ auto& field = RefAt<RepeatedField<arc_ui32>>(msg, entry.offset);
+ constexpr auto size = sizeof(arc_ui32);
+ const char* ptr2 = ptr;
+ arc_ui32 next_tag;
+ do {
+ ptr = ptr2;
+ std::memcpy(field.Add(), ptr, size);
+ ptr += size;
+ if (!ctx->DataAvailable(ptr)) break;
+ ptr2 = ReadTag(ptr, &next_tag);
+ } while (next_tag == decoded_tag);
+ }
+
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ const arc_ui32 decoded_wiretype = data.tag() & 7;
+
+ // Check for non-packed repeated fallback:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ PROTOBUF_MUSTTAIL return MpRepeatedFixed(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ // Since ctx->ReadPackedFixed does not use TailCall<> or Return<>, sync any
+ // pending hasbits now:
+ SyncHasbits(msg, hasbits, table);
+
+ int size = ReadSize(&ptr);
+ uint16_t rep = type_card & field_layout::kRepMask;
+ if (rep == field_layout::kRep64Bits) {
+ auto& field = RefAt<RepeatedField<arc_ui64>>(msg, entry.offset);
+ ptr = ctx->ReadPackedFixed(ptr, size, &field);
+ } else {
+ GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
+ auto& field = RefAt<RepeatedField<arc_ui32>>(msg, entry.offset);
+ ptr = ctx->ReadPackedFixed(ptr, size, &field);
+ }
+
+ if (ptr == nullptr) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ const uint16_t card = type_card & field_layout::kFcMask;
+
+ // Check for repeated parsing:
+ if (card == field_layout::kFcRepeated) {
+ PROTOBUF_MUSTTAIL return MpRepeatedVarint(PROTOBUF_TC_PARAM_PASS);
+ }
+ // Check for wire type mismatch:
+ if ((data.tag() & 7) != WireFormatLite::WIRETYPE_VARINT) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ const uint16_t xform_val = type_card & field_layout::kTvMask;
+ const bool is_zigzag = xform_val == field_layout::kTvZigZag;
+ const bool is_validated_enum = xform_val & field_layout::kTvEnum;
+
+ // Parse the value:
+ const char* ptr2 = ptr; // save for unknown enum case
+ arc_ui64 tmp;
+ ptr = ParseVarint(ptr, &tmp);
+ if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+
+ // Transform and/or validate the value
+ uint16_t rep = type_card & field_layout::kRepMask;
+ if (rep == field_layout::kRep64Bits) {
+ if (is_zigzag) {
+ tmp = WireFormatLite::ZigZagDecode64(tmp);
+ }
+ } else if (rep == field_layout::kRep32Bits) {
+ if (is_validated_enum) {
+ if (!EnumIsValidAux(tmp, xform_val, *table->field_aux(&entry))) {
+ ptr = ptr2;
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ } else if (is_zigzag) {
+ tmp = WireFormatLite::ZigZagDecode32(static_cast<arc_ui32>(tmp));
+ }
+ }
+
+ // Mark the field as present:
+ const bool is_oneof = card == field_layout::kFcOneof;
+ if (card == field_layout::kFcOptional) {
+ SetHas(table, entry, msg, hasbits);
+ } else if (is_oneof) {
+ ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
+ }
+
+ if (rep == field_layout::kRep64Bits) {
+ RefAt<arc_ui64>(msg, entry.offset) = tmp;
+ } else if (rep == field_layout::kRep32Bits) {
+ RefAt<arc_ui32>(msg, entry.offset) = static_cast<arc_ui32>(tmp);
+ } else {
+ GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
+ RefAt<bool>(msg, entry.offset) = static_cast<bool>(tmp);
+ }
+
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ auto type_card = entry.type_card;
+ const arc_ui32 decoded_tag = data.tag();
+ auto decoded_wiretype = decoded_tag & 7;
+
+ // Check for packed repeated fallback:
+ if (decoded_wiretype == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ PROTOBUF_MUSTTAIL return MpPackedVarint(PROTOBUF_TC_PARAM_PASS);
+ }
+ // Check for wire type mismatch:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_VARINT) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ uint16_t xform_val = (type_card & field_layout::kTvMask);
+ const bool is_zigzag = xform_val == field_layout::kTvZigZag;
+ const bool is_validated_enum = xform_val & field_layout::kTvEnum;
+
+ uint16_t rep = type_card & field_layout::kRepMask;
+ if (rep == field_layout::kRep64Bits) {
+ auto& field = RefAt<RepeatedField<arc_ui64>>(msg, entry.offset);
+ const char* ptr2 = ptr;
+ arc_ui32 next_tag;
+ do {
+ arc_ui64 tmp;
+ ptr = ParseVarint(ptr2, &tmp);
+ if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+ field.Add(is_zigzag ? WireFormatLite::ZigZagDecode64(tmp) : tmp);
+ if (!ctx->DataAvailable(ptr)) break;
+ ptr2 = ReadTag(ptr, &next_tag);
+ } while (next_tag == decoded_tag);
+ } else if (rep == field_layout::kRep32Bits) {
+ auto& field = RefAt<RepeatedField<arc_ui32>>(msg, entry.offset);
+ const char* ptr2 = ptr;
+ arc_ui32 next_tag;
+ do {
+ arc_ui64 tmp;
+ ptr = ParseVarint(ptr2, &tmp);
+ if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+ if (is_validated_enum) {
+ if (!EnumIsValidAux(tmp, xform_val, *table->field_aux(&entry))) {
+ ptr = ptr2;
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ } else if (is_zigzag) {
+ tmp = WireFormatLite::ZigZagDecode32(tmp);
+ }
+ field.Add(tmp);
+ if (!ctx->DataAvailable(ptr)) break;
+ ptr2 = ReadTag(ptr, &next_tag);
+ } while (next_tag == decoded_tag);
+ } else {
+ GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
+ auto& field = RefAt<RepeatedField<bool>>(msg, entry.offset);
+ const char* ptr2 = ptr;
+ arc_ui32 next_tag;
+ do {
+ arc_ui64 tmp;
+ ptr = ParseVarint(ptr2, &tmp);
+ if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+ field.Add(static_cast<bool>(tmp));
+ if (!ctx->DataAvailable(ptr)) break;
+ ptr2 = ReadTag(ptr, &next_tag);
+ } while (next_tag == decoded_tag);
+ }
+
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ auto type_card = entry.type_card;
+ auto decoded_wiretype = data.tag() & 7;
+
+ // Check for non-packed repeated fallback:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ PROTOBUF_MUSTTAIL return MpRepeatedVarint(PROTOBUF_TC_PARAM_PASS);
+ }
+ uint16_t xform_val = (type_card & field_layout::kTvMask);
+ const bool is_zigzag = xform_val == field_layout::kTvZigZag;
+ const bool is_validated_enum = xform_val & field_layout::kTvEnum;
+ if (is_validated_enum) {
+ // TODO(b/206890171): handle enums
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ // Since ctx->ReadPackedFixed does not use TailCall<> or Return<>, sync any
+ // pending hasbits now:
+ SyncHasbits(msg, hasbits, table);
+
+ uint16_t rep = type_card & field_layout::kRepMask;
+ if (rep == field_layout::kRep64Bits) {
+ auto* field = &RefAt<RepeatedField<arc_ui64>>(msg, entry.offset);
+ return ctx->ReadPackedVarint(ptr, [field, is_zigzag](arc_ui64 value) {
+ field->Add(is_zigzag ? WireFormatLite::ZigZagDecode64(value) : value);
+ });
+ } else if (rep == field_layout::kRep32Bits) {
+ auto* field = &RefAt<RepeatedField<arc_ui32>>(msg, entry.offset);
+ return ctx->ReadPackedVarint(ptr, [field, is_zigzag](arc_ui64 value) {
+ field->Add(is_zigzag ? WireFormatLite::ZigZagDecode32(
+ static_cast<arc_ui32>(value))
+ : value);
+ });
+ } else {
+ GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
+ auto* field = &RefAt<RepeatedField<bool>>(msg, entry.offset);
+ return ctx->ReadPackedVarint(
+ ptr, [field](arc_ui64 value) { field->Add(value); });
+ }
+
+ return Error(PROTOBUF_TC_PARAM_PASS);
+}
+
+bool TcParser::MpVerifyUtf8(StringPiece wire_bytes,
+ const TcParseTableBase* table,
+ const FieldEntry& entry, uint16_t xform_val) {
+ if (xform_val == field_layout::kTvUtf8) {
+ if (!IsStructurallyValidUTF8(wire_bytes)) {
+ PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing",
+ false);
+ return false;
+ }
+ return true;
+ }
+#ifndef NDEBUG
+ if (xform_val == field_layout::kTvUtf8Debug) {
+ if (!IsStructurallyValidUTF8(wire_bytes)) {
+ PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing",
+ false);
+ }
+ }
+#endif // NDEBUG
+ return true;
+}
+
+const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ const uint16_t card = type_card & field_layout::kFcMask;
+ const arc_ui32 decoded_wiretype = data.tag() & 7;
+
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (card == field_layout::kFcRepeated) {
+ PROTOBUF_MUSTTAIL return MpRepeatedString(PROTOBUF_TC_PARAM_PASS);
+ }
+ const uint16_t xform_val = type_card & field_layout::kTvMask;
+ const uint16_t rep = type_card & field_layout::kRepMask;
+ if (rep == field_layout::kRepIString) {
+ // TODO(b/198211897): support InilnedStringField.
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ // Mark the field as present:
+ const bool is_oneof = card == field_layout::kFcOneof;
+ bool need_init = false;
+ if (card == field_layout::kFcOptional) {
+ SetHas(table, entry, msg, hasbits);
+ } else if (is_oneof) {
+ need_init = ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
+ }
+
+ bool is_valid = false;
+ Arena* arena = ctx->data().arena;
+ switch (rep) {
+ case field_layout::kRepAString: {
+ auto& field = RefAt<ArenaStringPtr>(msg, entry.offset);
+ if (need_init) field.InitDefault();
+ if (arena) {
+ ptr = ctx->ReadArenaString(ptr, &field, arena);
+ } else {
+ TProtoStringType* str = field.MutableNoCopy(nullptr);
+ ptr = InlineGreedyStringParser(str, ptr, ctx);
+ }
+ if (!ptr) break;
+ is_valid = MpVerifyUtf8(field.Get(), table, entry, xform_val);
+ break;
+ }
+
+ case field_layout::kRepIString: {
+ break;
+ }
+ }
+
+ if (ptr == nullptr || !is_valid) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ const arc_ui32 decoded_tag = data.tag();
+ const arc_ui32 decoded_wiretype = decoded_tag & 7;
+
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ const uint16_t rep = type_card & field_layout::kRepMask;
+ const uint16_t xform_val = type_card & field_layout::kTvMask;
+ switch (rep) {
+ case field_layout::kRepSString: {
+ auto& field = RefAt<RepeatedPtrField<TProtoStringType>>(msg, entry.offset);
+ const char* ptr2 = ptr;
+ arc_ui32 next_tag;
+ do {
+ ptr = ptr2;
+ TProtoStringType* str = field.Add();
+ ptr = InlineGreedyStringParser(str, ptr, ctx);
+ if (PROTOBUF_PREDICT_FALSE(
+ ptr == nullptr ||
+ !MpVerifyUtf8(*str, table, entry, xform_val))) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (!ctx->DataAvailable(ptr)) break;
+ ptr2 = ReadTag(ptr, &next_tag);
+ } while (next_tag == decoded_tag);
+ break;
+ }
+
+#ifndef NDEBUG
+ default:
+ GOOGLE_LOG(FATAL) << "Unsupported repeated string rep: " << rep;
+ break;
+#endif
+ }
+
+ return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
+}
+
+const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ const uint16_t card = type_card & field_layout::kFcMask;
+
+ // Check for repeated parsing:
+ if (card == field_layout::kFcRepeated) {
+ PROTOBUF_MUSTTAIL return MpRepeatedMessage(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ const arc_ui32 decoded_tag = data.tag();
+ const arc_ui32 decoded_wiretype = decoded_tag & 7;
+ const uint16_t rep = type_card & field_layout::kRepMask;
+ const bool is_group = rep == field_layout::kRepGroup;
+
+ // Validate wiretype:
+ switch (rep) {
+ case field_layout::kRepMessage:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ goto fallback;
+ }
+ break;
+ case field_layout::kRepGroup:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_START_GROUP) {
+ goto fallback;
+ }
+ break;
+ default: {
+ fallback:
+ // Lazy and implicit weak fields are handled by generated code:
+ // TODO(b/210762816): support these.
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ }
+
+ const bool is_oneof = card == field_layout::kFcOneof;
+ bool need_init = false;
+ if (card == field_layout::kFcOptional) {
+ SetHas(table, entry, msg, hasbits);
+ } else if (is_oneof) {
+ need_init = ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
+ }
+ MessageLite*& field = RefAt<MessageLite*>(msg, entry.offset);
+ if (need_init || field == nullptr) {
+ const MessageLite* default_instance =
+ table->field_aux(&entry)->message_default;
+ field = default_instance->New(ctx->data().arena);
+ }
+ SyncHasbits(msg, hasbits, table);
+ if (is_group) {
+ return ctx->ParseGroup(field, ptr, decoded_tag);
+ }
+ return ctx->ParseMessage(field, ptr);
+}
+
+const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ const uint16_t type_card = entry.type_card;
+ GOOGLE_DCHECK_EQ(type_card & field_layout::kFcMask,
+ static_cast<uint16_t>(field_layout::kFcRepeated));
+ const arc_ui32 decoded_tag = data.tag();
+ const arc_ui32 decoded_wiretype = decoded_tag & 7;
+ const uint16_t rep = type_card & field_layout::kRepMask;
+ const bool is_group = rep == field_layout::kRepGroup;
+
+ // Validate wiretype:
+ switch (rep) {
+ case field_layout::kRepMessage:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ goto fallback;
+ }
+ break;
+ case field_layout::kRepGroup:
+ if (decoded_wiretype != WireFormatLite::WIRETYPE_START_GROUP) {
+ goto fallback;
+ }
+ break;
+ default: {
+ fallback:
+ // Lazy and implicit weak fields are handled by generated code:
+ // TODO(b/210762816): support these.
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ }
+ }
+
+ SyncHasbits(msg, hasbits, table);
+ const MessageLite* default_instance =
+ table->field_aux(&entry)->message_default;
+ auto& field = RefAt<RepeatedPtrFieldBase>(msg, entry.offset);
+ MessageLite* value =
+ field.Add<GenericTypeHandler<MessageLite>>(default_instance);
+ if (is_group) {
+ return ctx->ParseGroup(value, ptr, decoded_tag);
+ }
+ return ctx->ParseMessage(value, ptr);
+}
+
+const char* TcParser::MpMap(PROTOBUF_TC_PARAM_DECL) {
+ const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
+ (void)entry;
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+}
} // namespace internal
} // namespace protobuf
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc
index 8db97d66ae..3062860a99 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc
@@ -42,7 +42,6 @@
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/extension_set.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/repeated_field.h>
@@ -66,7 +65,7 @@ void DestroyString(const void* s) {
}
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
- PROTOBUF_ATTRIBUTE_INIT_PRIORITY ExplicitlyConstructed<TProtoStringType>
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExplicitlyConstructedArenaString
fixed_address_empty_string{}; // NOLINT
@@ -87,7 +86,7 @@ void InitProtobufDefaultsSlow() {
// Force the initialization of the empty string.
// Normally, registration would do it, but we don't have any guarantee that
// there is any object with reflection.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static std::true_type init_empty_string =
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 static std::true_type init_empty_string =
(InitProtobufDefaultsSlow(), std::true_type{});
size_t StringSpaceUsedExcludingSelfLong(const TProtoStringType& str) {
@@ -253,11 +252,6 @@ template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_BYTES>
: PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {};
-
-template <>
-struct PrimitiveTypeHelper<FieldMetadata::kInlinedType>
- : PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {};
-
// We want to serialize to both CodedOutputStream and directly into byte arrays
// without duplicating the code. In fact we might want extra output channels in
// the future.
@@ -313,133 +307,6 @@ void SerializeMessageNoTable(const MessageLite* msg, ArrayOutput* output) {
output->ptr += o.ByteCount();
}
-// Helper to branch to fast path if possible
-void SerializeMessageDispatch(const MessageLite& msg,
- const FieldMetadata* field_table, int num_fields,
- arc_i32 /*cached_size*/,
- io::CodedOutputStream* output) {
- const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg);
- SerializeInternal(base, field_table, num_fields, output);
-}
-
-// Helper to branch to fast path if possible
-void SerializeMessageDispatch(const MessageLite& msg,
- const FieldMetadata* field_table, int num_fields,
- arc_i32 /*cached_size*/, ArrayOutput* output) {
- const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg);
- output->ptr = SerializeInternalToArray(base, field_table, num_fields,
- output->is_deterministic, output->ptr);
-}
-
-// Serializing messages is special as it's not a primitive type and needs an
-// explicit overload for each output type.
-template <typename O>
-void SerializeMessageTo(const MessageLite* msg, const void* table_ptr,
- O* output) {
- const SerializationTable* table =
- static_cast<const SerializationTable*>(table_ptr);
- if (!table) {
- // Proto1
- WriteLengthTo(msg->GetCachedSize(), output);
- SerializeMessageNoTable(msg, output);
- return;
- }
- const FieldMetadata* field_table = table->field_table;
- const uint8_t* base = reinterpret_cast<const uint8_t*>(msg);
- int cached_size =
- *reinterpret_cast<const arc_i32*>(base + field_table->offset);
- WriteLengthTo(cached_size, output);
- int num_fields = table->num_fields - 1;
- SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size,
- output);
-}
-
-// Almost the same as above only it doesn't output the length field.
-template <typename O>
-void SerializeGroupTo(const MessageLite* msg, const void* table_ptr,
- O* output) {
- const SerializationTable* table =
- static_cast<const SerializationTable*>(table_ptr);
- if (!table) {
- // Proto1
- SerializeMessageNoTable(msg, output);
- return;
- }
- const FieldMetadata* field_table = table->field_table;
- const uint8_t* base = reinterpret_cast<const uint8_t*>(msg);
- int cached_size =
- *reinterpret_cast<const arc_i32*>(base + field_table->offset);
- int num_fields = table->num_fields - 1;
- SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size,
- output);
-}
-
-template <int type>
-struct SingularFieldHelper {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- WriteTagTo(md.tag, output);
- SerializeTo<type>(field, output);
- }
-};
-
-template <>
-struct SingularFieldHelper<WireFormatLite::TYPE_STRING> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- WriteTagTo(md.tag, output);
- SerializeTo<WireFormatLite::TYPE_STRING>(&Get<ArenaStringPtr>(field).Get(),
- output);
- }
-};
-
-template <>
-struct SingularFieldHelper<WireFormatLite::TYPE_BYTES>
- : SingularFieldHelper<WireFormatLite::TYPE_STRING> {};
-
-template <>
-struct SingularFieldHelper<WireFormatLite::TYPE_GROUP> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- WriteTagTo(md.tag, output);
- SerializeGroupTo(Get<const MessageLite*>(field),
- static_cast<const SerializationTable*>(md.ptr), output);
- WriteTagTo(md.tag + 1, output);
- }
-};
-
-template <>
-struct SingularFieldHelper<WireFormatLite::TYPE_MESSAGE> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- WriteTagTo(md.tag, output);
- SerializeMessageTo(Get<const MessageLite*>(field),
- static_cast<const SerializationTable*>(md.ptr), output);
- }
-};
-
-template <>
-struct SingularFieldHelper<FieldMetadata::kInlinedType> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- WriteTagTo(md.tag, output);
- SerializeTo<FieldMetadata::kInlinedType>(&Get<TProtoStringType>(field), output);
- }
-};
-
-template <int type>
-struct RepeatedFieldHelper {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- typedef typename PrimitiveTypeHelper<type>::Type T;
- const RepeatedField<T>& array = Get<RepeatedField<T> >(field);
- for (int i = 0; i < array.size(); i++) {
- WriteTagTo(md.tag, output);
- SerializeTo<type>(&array[i], output);
- }
- }
-};
-
// We need to use a helper class to get access to the private members
class AccessorHelper {
public:
@@ -449,118 +316,6 @@ class AccessorHelper {
}
};
-template <>
-struct RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- const internal::RepeatedPtrFieldBase& array =
- Get<internal::RepeatedPtrFieldBase>(field);
- for (int i = 0; i < AccessorHelper::Size(array); i++) {
- WriteTagTo(md.tag, output);
- SerializeTo<WireFormatLite::TYPE_STRING>(AccessorHelper::Get(array, i),
- output);
- }
- }
-};
-
-template <>
-struct RepeatedFieldHelper<WireFormatLite::TYPE_BYTES>
- : RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {};
-
-template <>
-struct RepeatedFieldHelper<WireFormatLite::TYPE_GROUP> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- const internal::RepeatedPtrFieldBase& array =
- Get<internal::RepeatedPtrFieldBase>(field);
- for (int i = 0; i < AccessorHelper::Size(array); i++) {
- WriteTagTo(md.tag, output);
- SerializeGroupTo(
- static_cast<const MessageLite*>(AccessorHelper::Get(array, i)),
- static_cast<const SerializationTable*>(md.ptr), output);
- WriteTagTo(md.tag + 1, output);
- }
- }
-};
-
-template <>
-struct RepeatedFieldHelper<WireFormatLite::TYPE_MESSAGE> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- const internal::RepeatedPtrFieldBase& array =
- Get<internal::RepeatedPtrFieldBase>(field);
- for (int i = 0; i < AccessorHelper::Size(array); i++) {
- WriteTagTo(md.tag, output);
- SerializeMessageTo(
- static_cast<const MessageLite*>(AccessorHelper::Get(array, i)),
- md.ptr, output);
- }
- }
-};
-
-
-template <>
-struct RepeatedFieldHelper<FieldMetadata::kInlinedType>
- : RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {};
-
-template <int type>
-struct PackedFieldHelper {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- typedef typename PrimitiveTypeHelper<type>::Type T;
- const RepeatedField<T>& array = Get<RepeatedField<T> >(field);
- if (array.empty()) return;
- WriteTagTo(md.tag, output);
- int cached_size =
- Get<int>(static_cast<const uint8_t*>(field) + sizeof(RepeatedField<T>));
- WriteLengthTo(cached_size, output);
- for (int i = 0; i < array.size(); i++) {
- SerializeTo<type>(&array[i], output);
- }
- }
-};
-
-template <>
-struct PackedFieldHelper<WireFormatLite::TYPE_STRING> {
- template <typename O>
- static void Serialize(const void* /*field*/, const FieldMetadata& md,
- O* /*output*/) {
- GOOGLE_LOG(FATAL) << "Not implemented field number " << md.tag << " with type "
- << md.type;
- }
-};
-
-template <>
-struct PackedFieldHelper<WireFormatLite::TYPE_BYTES>
- : PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
-template <>
-struct PackedFieldHelper<WireFormatLite::TYPE_GROUP>
- : PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
-template <>
-struct PackedFieldHelper<WireFormatLite::TYPE_MESSAGE>
- : PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
-template <>
-struct PackedFieldHelper<FieldMetadata::kInlinedType>
- : PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
-
-template <int type>
-struct OneOfFieldHelper {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- SingularFieldHelper<type>::Serialize(field, md, output);
- }
-};
-
-
-template <>
-struct OneOfFieldHelper<FieldMetadata::kInlinedType> {
- template <typename O>
- static void Serialize(const void* field, const FieldMetadata& md, O* output) {
- SingularFieldHelper<FieldMetadata::kInlinedType>::Serialize(
- Get<const TProtoStringType*>(field), md, output);
- }
-};
-
void SerializeNotImplemented(int field) {
GOOGLE_LOG(FATAL) << "Not implemented field number " << field;
}
@@ -569,11 +324,6 @@ void SerializeNotImplemented(int field) {
#define SERIALIZE_TABLE_OP(type, type_class) \
((type - 1) + static_cast<int>(type_class) * FieldMetadata::kNumTypes)
-int FieldMetadata::CalculateType(int type,
- FieldMetadata::FieldTypeClass type_class) {
- return SERIALIZE_TABLE_OP(type, type_class);
-}
-
template <int type>
bool IsNull(const void* ptr) {
return *static_cast<const typename PrimitiveTypeHelper<type>::Type*>(ptr) ==
@@ -600,125 +350,6 @@ bool IsNull<WireFormatLite::TYPE_MESSAGE>(const void* ptr) {
return Get<const MessageLite*>(ptr) == nullptr;
}
-
-template <>
-bool IsNull<FieldMetadata::kInlinedType>(const void* ptr) {
- return static_cast<const TProtoStringType*>(ptr)->empty();
-}
-
-#define SERIALIZERS_FOR_TYPE(type) \
- case SERIALIZE_TABLE_OP(type, FieldMetadata::kPresence): \
- if (!IsPresent(base, field_metadata.has_offset)) continue; \
- SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \
- break; \
- case SERIALIZE_TABLE_OP(type, FieldMetadata::kNoPresence): \
- if (IsNull<type>(ptr)) continue; \
- SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \
- break; \
- case SERIALIZE_TABLE_OP(type, FieldMetadata::kRepeated): \
- RepeatedFieldHelper<type>::Serialize(ptr, field_metadata, output); \
- break; \
- case SERIALIZE_TABLE_OP(type, FieldMetadata::kPacked): \
- PackedFieldHelper<type>::Serialize(ptr, field_metadata, output); \
- break; \
- case SERIALIZE_TABLE_OP(type, FieldMetadata::kOneOf): \
- if (!IsOneofPresent(base, field_metadata.has_offset, field_metadata.tag)) \
- continue; \
- OneOfFieldHelper<type>::Serialize(ptr, field_metadata, output); \
- break
-
-void SerializeInternal(const uint8_t* base,
- const FieldMetadata* field_metadata_table,
- arc_i32 num_fields, io::CodedOutputStream* output) {
- SpecialSerializer func = nullptr;
- for (int i = 0; i < num_fields; i++) {
- const FieldMetadata& field_metadata = field_metadata_table[i];
- const uint8_t* ptr = base + field_metadata.offset;
- switch (field_metadata.type) {
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64);
- SERIALIZERS_FOR_TYPE(FieldMetadata::kInlinedType);
-
- // Special cases
- case FieldMetadata::kSpecial:
- func = reinterpret_cast<SpecialSerializer>(
- const_cast<void*>(field_metadata.ptr));
- func(base, field_metadata.offset, field_metadata.tag,
- field_metadata.has_offset, output);
- break;
- default:
- // __builtin_unreachable()
- SerializeNotImplemented(field_metadata.type);
- }
- }
-}
-
-uint8_t* SerializeInternalToArray(const uint8_t* base,
- const FieldMetadata* field_metadata_table,
- arc_i32 num_fields, bool is_deterministic,
- uint8_t* buffer) {
- ArrayOutput array_output = {buffer, is_deterministic};
- ArrayOutput* output = &array_output;
- SpecialSerializer func = nullptr;
- for (int i = 0; i < num_fields; i++) {
- const FieldMetadata& field_metadata = field_metadata_table[i];
- const uint8_t* ptr = base + field_metadata.offset;
- switch (field_metadata.type) {
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32);
- SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64);
- SERIALIZERS_FOR_TYPE(FieldMetadata::kInlinedType);
- // Special cases
- case FieldMetadata::kSpecial: {
- io::ArrayOutputStream array_stream(array_output.ptr, INT_MAX);
- io::CodedOutputStream output_stream(&array_stream);
- output_stream.SetSerializationDeterministic(is_deterministic);
- func = reinterpret_cast<SpecialSerializer>(
- const_cast<void*>(field_metadata.ptr));
- func(base, field_metadata.offset, field_metadata.tag,
- field_metadata.has_offset, &output_stream);
- array_output.ptr += output_stream.ByteCount();
- } break;
- default:
- // __builtin_unreachable()
- SerializeNotImplemented(field_metadata.type);
- }
- }
- return array_output.ptr;
-}
-#undef SERIALIZERS_FOR_TYPE
-
void ExtensionSerializer(const MessageLite* extendee, const uint8_t* ptr,
arc_ui32 offset, arc_ui32 tag, arc_ui32 has_offset,
io::CodedOutputStream* output) {
@@ -758,8 +389,7 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) {
MessageLite* GetOwnedMessageInternal(Arena* message_arena,
MessageLite* submessage,
Arena* submessage_arena) {
- GOOGLE_DCHECK(Arena::InternalHelper<MessageLite>::GetOwningArena(submessage) ==
- submessage_arena);
+ GOOGLE_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena);
GOOGLE_DCHECK(message_arena != submessage_arena);
GOOGLE_DCHECK_EQ(submessage_arena, nullptr);
if (message_arena != nullptr && submessage_arena == nullptr) {
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h
index c751ddbd7b..db57979829 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h
@@ -46,17 +46,18 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/once.h> // Add direct dep on port for pb.cc
+#include <google/protobuf/port.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/any.h>
#include <google/protobuf/has_bits.h>
#include <google/protobuf/implicit_weak_message.h>
#include <google/protobuf/message_lite.h>
-#include <google/protobuf/stubs/once.h> // Add direct dep on port for pb.cc
-#include <google/protobuf/port.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/casts.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
diff --git a/contrib/libs/protobuf/src/google/protobuf/has_bits.h b/contrib/libs/protobuf/src/google/protobuf/has_bits.h
index 9cff105307..6185d04e00 100644
--- a/contrib/libs/protobuf/src/google/protobuf/has_bits.h
+++ b/contrib/libs/protobuf/src/google/protobuf/has_bits.h
@@ -34,6 +34,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
diff --git a/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc b/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc
index 528cf95d41..27ed6b65d2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc
@@ -30,34 +30,39 @@
#include <google/protobuf/implicit_weak_message.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
+PROTOBUF_PRAGMA_INIT_SEG
+
namespace google {
namespace protobuf {
namespace internal {
const char* ImplicitWeakMessage::_InternalParse(const char* ptr,
ParseContext* ctx) {
- return ctx->AppendString(ptr, &data_);
+ return ctx->AppendString(ptr, data_);
}
-ExplicitlyConstructed<ImplicitWeakMessage>
- implicit_weak_message_default_instance;
-internal::once_flag implicit_weak_message_once_init_;
+struct ImplicitWeakMessageDefaultType {
+ constexpr ImplicitWeakMessageDefaultType()
+ : instance(ConstantInitialized{}) {}
+ ~ImplicitWeakMessageDefaultType() {}
+ union {
+ ImplicitWeakMessage instance;
+ };
+};
-void InitImplicitWeakMessageDefaultInstance() {
- implicit_weak_message_default_instance.DefaultConstruct();
-}
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ImplicitWeakMessageDefaultType
+ implicit_weak_message_default_instance;
const ImplicitWeakMessage* ImplicitWeakMessage::default_instance() {
- internal::call_once(implicit_weak_message_once_init_,
- InitImplicitWeakMessageDefaultInstance);
- return &implicit_weak_message_default_instance.get();
+ return reinterpret_cast<ImplicitWeakMessage*>(
+ &implicit_weak_message_default_instance);
}
} // namespace internal
diff --git a/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h b/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h
index 85c6205b7a..393cc136ed 100644
--- a/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h
+++ b/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h
@@ -42,6 +42,7 @@
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
// This file is logically internal-only and should only be used by protobuf
@@ -56,8 +57,17 @@ namespace internal {
// message type does not get linked into the binary.
class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
public:
- ImplicitWeakMessage() {}
- explicit ImplicitWeakMessage(Arena* arena) : MessageLite(arena) {}
+ ImplicitWeakMessage() : data_(new TProtoStringType) {}
+ explicit constexpr ImplicitWeakMessage(ConstantInitialized)
+ : data_(nullptr) {}
+ explicit ImplicitWeakMessage(Arena* arena)
+ : MessageLite(arena), data_(new TProtoStringType) {}
+
+ ~ImplicitWeakMessage() override {
+ // data_ will be null in the default instance, but we can safely call delete
+ // here because the default instance will never be destroyed.
+ delete data_;
+ }
static const ImplicitWeakMessage* default_instance();
@@ -67,33 +77,50 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
return Arena::CreateMessage<ImplicitWeakMessage>(arena);
}
- void Clear() override { data_.clear(); }
+ void Clear() override { data_->clear(); }
bool IsInitialized() const override { return true; }
void CheckTypeAndMergeFrom(const MessageLite& other) override {
- data_.append(static_cast<const ImplicitWeakMessage&>(other).data_);
+ const TProtoStringType* other_data =
+ static_cast<const ImplicitWeakMessage&>(other).data_;
+ if (other_data != nullptr) {
+ data_->append(*other_data);
+ }
}
const char* _InternalParse(const char* ptr, ParseContext* ctx) final;
- size_t ByteSizeLong() const override { return data_.size(); }
+ size_t ByteSizeLong() const override {
+ return data_ == nullptr ? 0 : data_->size();
+ }
uint8_t* _InternalSerialize(uint8_t* target,
io::EpsCopyOutputStream* stream) const final {
- return stream->WriteRaw(data_.data(), static_cast<int>(data_.size()),
+ if (data_ == nullptr) {
+ return target;
+ }
+ return stream->WriteRaw(data_->data(), static_cast<int>(data_->size()),
target);
}
- int GetCachedSize() const override { return static_cast<int>(data_.size()); }
+ int GetCachedSize() const override {
+ return data_ == nullptr ? 0 : static_cast<int>(data_->size());
+ }
typedef void InternalArenaConstructable_;
private:
- TProtoStringType data_;
+ // This TProtoStringType is allocated on the heap, but we use a raw pointer so that
+ // the default instance can be constant-initialized. In the const methods, we
+ // have to handle the possibility of data_ being null.
+ TProtoStringType* data_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage);
};
+struct ImplicitWeakMessageDefaultType;
+extern ImplicitWeakMessageDefaultType implicit_weak_message_default_instance;
+
// A type handler for use with implicit weak repeated message fields.
template <typename ImplicitWeakType>
class ImplicitWeakTypeHandler {
diff --git a/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc b/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc
index d3614c8d74..93e9fb9e90 100644
--- a/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc
@@ -30,11 +30,11 @@
#include <google/protobuf/inlined_string_field.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
// clang-format off
#include <google/protobuf/port_def.inc>
@@ -48,54 +48,62 @@ namespace internal {
TProtoStringType* InlinedStringField::Mutable(const LazyString& /*default_value*/,
Arena* arena, bool donated,
arc_ui32* donating_states,
- arc_ui32 mask) {
+ arc_ui32 mask, MessageLite* msg) {
if (arena == nullptr || !donated) {
return UnsafeMutablePointer();
}
- return MutableSlow(arena, donated, donating_states, mask);
+ return MutableSlow(arena, donated, donating_states, mask, msg);
}
-TProtoStringType* InlinedStringField::Mutable(ArenaStringPtr::EmptyDefault,
- Arena* arena, bool donated,
+TProtoStringType* InlinedStringField::Mutable(Arena* arena, bool donated,
arc_ui32* donating_states,
- arc_ui32 mask) {
+ arc_ui32 mask, MessageLite* msg) {
if (arena == nullptr || !donated) {
return UnsafeMutablePointer();
}
- return MutableSlow(arena, donated, donating_states, mask);
+ return MutableSlow(arena, donated, donating_states, mask, msg);
}
TProtoStringType* InlinedStringField::MutableSlow(::google::protobuf::Arena* arena,
bool donated,
arc_ui32* donating_states,
- arc_ui32 mask) {
+ arc_ui32 mask, MessageLite* msg) {
+ (void)mask;
+ (void)msg;
return UnsafeMutablePointer();
}
void InlinedStringField::SetAllocated(const TProtoStringType* default_value,
TProtoStringType* value, Arena* arena,
bool donated, arc_ui32* donating_states,
- arc_ui32 mask) {
+ arc_ui32 mask, MessageLite* msg) {
+ (void)mask;
+ (void)msg;
SetAllocatedNoArena(default_value, value);
}
-void InlinedStringField::Set(const TProtoStringType* default_value,
- TProtoStringType&& value, Arena* arena, bool donated,
- arc_ui32* donating_states, arc_ui32 mask) {
- SetNoArena(default_value, std::move(value));
+void InlinedStringField::Set(TProtoStringType&& value, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ (void)donating_states;
+ (void)mask;
+ (void)msg;
+ SetNoArena(std::move(value));
}
-TProtoStringType* InlinedStringField::Release(const TProtoStringType* default_value,
- Arena* arena, bool donated) {
- if (arena == nullptr && !donated) {
- return ReleaseNonDefaultNoArena(default_value);
- }
- return ReleaseNonDefault(default_value, arena);
+TProtoStringType* InlinedStringField::Release() {
+ auto* released = new TProtoStringType(std::move(*get_mutable()));
+ get_mutable()->clear();
+ return released;
}
-TProtoStringType* InlinedStringField::ReleaseNonDefault(
- const TProtoStringType* default_value, Arena* arena) {
- return ReleaseNonDefaultNoArena(default_value);
+TProtoStringType* InlinedStringField::Release(Arena* arena, bool donated) {
+ // We can not steal donated arena strings.
+ TProtoStringType* released = (arena != nullptr && donated)
+ ? new TProtoStringType(*get_mutable())
+ : new TProtoStringType(std::move(*get_mutable()));
+ get_mutable()->clear();
+ return released;
}
void InlinedStringField::ClearToDefault(const LazyString& default_value,
diff --git a/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h b/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h
index 40dba70b45..1a7baafdb7 100644
--- a/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h
@@ -36,10 +36,10 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/message_lite.h>
#include <google/protobuf/port.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/message_lite.h>
// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -130,60 +130,45 @@ class PROTOBUF_EXPORT InlinedStringField {
// `donated == ((donating_states & ~mask) != 0)`
//
// This method never changes the `donating_states`.
- void Set(const TProtoStringType* default_value, ConstStringParam value,
- Arena* arena, bool donated, arc_ui32* /*donating_states*/,
- arc_ui32 /*mask*/) {
- (void)arena;
- (void)donated;
- SetNoArena(default_value, value);
- }
+ void Set(ConstStringParam value, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
// Rvalue Set. If this field is donated, this method will undonate this field
// by mutating the `donating_states` according to `mask`.
- void Set(const TProtoStringType* default_value, TProtoStringType&& value, Arena* arena,
- bool donated, arc_ui32* donating_states, arc_ui32 mask);
+ void Set(TProtoStringType&& value, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
- template <typename FirstParam>
- void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena, bool donated,
- arc_ui32* donating_states, arc_ui32 mask) {
- Set(p1, ConstStringParam(str), arena, donated, donating_states, mask);
- }
+ void Set(const char* str, ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
- template <typename FirstParam>
- void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena,
- bool donated, arc_ui32* donating_states, arc_ui32 mask) {
- ConstStringParam sp{str, size}; // for string_view and `const string &`
- Set(p1, sp, arena, donated, donating_states, mask);
- }
+ void Set(const char* str, size_t size, ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
- template <typename FirstParam, typename RefWrappedType>
- void Set(FirstParam p1,
- std::reference_wrapper<RefWrappedType> const_string_ref,
+ template <typename RefWrappedType>
+ void Set(std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
- arc_ui32 mask) {
- Set(p1, const_string_ref.get(), arena, donated, donating_states, mask);
- }
+ arc_ui32 mask, MessageLite* msg);
- template <typename FirstParam, typename SecondParam>
- void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena,
- bool donated, arc_ui32* donating_states, arc_ui32 mask) {
- Set(p1, static_cast<SecondParam&&>(p2), arena, donated, donating_states,
- mask);
- }
+ void SetBytes(ConstStringParam value, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
- template <typename FirstParam>
- void SetBytes(FirstParam p1, const void* str, size_t size,
+ void SetBytes(TProtoStringType&& value, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
+
+ void SetBytes(const char* str, ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
+
+ void SetBytes(const void* p, size_t size, ::google::protobuf::Arena* arena,
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg);
+
+ template <typename RefWrappedType>
+ void SetBytes(std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
- arc_ui32 mask) {
- // Must work whether ConstStringParam is string_view or `const string &`
- ConstStringParam sp{static_cast<const char*>(str), size};
- Set(p1, sp, arena, donated, donating_states, mask);
- }
+ arc_ui32 mask, MessageLite* msg);
- PROTOBUF_NDEBUG_INLINE void SetNoArena(const TProtoStringType* default_value,
- StringPiece value);
- PROTOBUF_NDEBUG_INLINE void SetNoArena(const TProtoStringType* default_value,
- TProtoStringType&& value);
+ PROTOBUF_NDEBUG_INLINE void SetNoArena(StringPiece value);
+ PROTOBUF_NDEBUG_INLINE void SetNoArena(TProtoStringType&& value);
// Basic accessors.
PROTOBUF_NDEBUG_INLINE const TProtoStringType& Get() const { return GetNoArena(); }
@@ -193,20 +178,17 @@ class PROTOBUF_EXPORT InlinedStringField {
// field is donated, this method undonates this field by mutating the
// `donating_states` according to `mask`, and copies the content of the
// original string to the returning string.
+ TProtoStringType* Mutable(Arena* arena, bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg);
TProtoStringType* Mutable(const LazyString& default_value, Arena* arena,
- bool donated, arc_ui32* donating_states, arc_ui32 mask);
- TProtoStringType* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated,
- arc_ui32* donating_states, arc_ui32 mask);
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg);
- // Release returns a TProtoStringType* instance that is heap-allocated and is not
- // Own()'d by any arena. If the field is not set, this returns nullptr. The
- // caller retains ownership. Clears this field back to nullptr state. Used to
- // implement release_<field>() methods on generated classes.
- PROTOBUF_NODISCARD TProtoStringType* Release(const TProtoStringType* default_value,
- Arena* arena, bool donated);
- PROTOBUF_NODISCARD TProtoStringType* ReleaseNonDefault(
- const TProtoStringType* default_value, Arena* arena);
- TProtoStringType* ReleaseNonDefaultNoArena(const TProtoStringType* default_value);
+ // Mutable(nullptr_t) is an overload to explicitly support Mutable(nullptr)
+ // calls used by the internal parser logic. This provides API equivalence with
+ // ArenaStringPtr, while still protecting against calls with arena pointers.
+ TProtoStringType* Mutable(std::nullptr_t);
+ TProtoStringType* MutableNoCopy(std::nullptr_t);
// Takes a TProtoStringType that is heap-allocated, and takes ownership. The
// TProtoStringType's destructor is registered with the arena. Used to implement
@@ -216,20 +198,133 @@ class PROTOBUF_EXPORT InlinedStringField {
// `donating_states` according to `mask`.
void SetAllocated(const TProtoStringType* default_value, TProtoStringType* value,
Arena* arena, bool donated, arc_ui32* donating_states,
- arc_ui32 mask);
+ arc_ui32 mask, MessageLite* msg);
void SetAllocatedNoArena(const TProtoStringType* default_value,
TProtoStringType* value);
- // When one of `this` and `from` is donated and the other is not donated, this
- // method will undonate the donated one and swap the two heap-allocated
- // strings.
- PROTOBUF_NDEBUG_INLINE void Swap(InlinedStringField* from,
- const TProtoStringType* default_value,
- Arena* arena, bool donated,
- bool from_donated, arc_ui32* donating_states,
- arc_ui32* from_donating_states,
- arc_ui32 mask);
+ // Release returns a TProtoStringType* instance that is heap-allocated and is not
+ // Own()'d by any arena. If the field is not set, this returns nullptr. The
+ // caller retains ownership. Clears this field back to nullptr state. Used to
+ // implement release_<field>() methods on generated classes.
+ PROTOBUF_NODISCARD TProtoStringType* Release(Arena* arena, bool donated);
+ PROTOBUF_NODISCARD TProtoStringType* Release();
+
+ // --------------------------------------------------------
+ // Below functions will be removed in subsequent code change
+ // --------------------------------------------------------
+#ifdef DEPRECATED_METHODS_TO_BE_DELETED
+ PROTOBUF_NODISCARD TProtoStringType* Release(const TProtoStringType*, Arena* arena,
+ bool donated) {
+ return Release(arena, donated);
+ }
+
+ PROTOBUF_NODISCARD TProtoStringType* ReleaseNonDefault(const TProtoStringType*,
+ Arena* arena) {
+ return Release();
+ }
+
+ TProtoStringType* ReleaseNonDefaultNoArena(const TProtoStringType* default_value) {
+ return Release();
+ }
+
+ void Set(const TProtoStringType*, ConstStringParam value, Arena* arena,
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ Set(value, arena, donated, donating_states, mask, msg);
+ }
+
+ void Set(const TProtoStringType*, TProtoStringType&& value, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg) {
+ Set(std::move(value), arena, donated, donating_states, mask, msg);
+ }
+
+
+ template <typename FirstParam>
+ void Set(FirstParam, const char* str, ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg) {
+ Set(str, arena, donated, donating_states, mask, msg);
+ }
+
+ template <typename FirstParam>
+ void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena,
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ Set(str, size, arena, donated, donating_states, mask, msg);
+ }
+
+ template <typename FirstParam, typename RefWrappedType>
+ void Set(FirstParam p1,
+ std::reference_wrapper<RefWrappedType> const_string_ref,
+ ::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(const_string_ref, arena, donated, donating_states, mask, msg);
+ }
+
+ void SetBytes(const TProtoStringType*, ConstStringParam value, Arena* arena,
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ Set(value, arena, donated, donating_states, mask, msg);
+ }
+
+
+ void SetBytes(const TProtoStringType*, TProtoStringType&& value, Arena* arena,
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ Set(std::move(value), arena, donated, donating_states, mask, msg);
+ }
+
+ template <typename FirstParam>
+ void SetBytes(FirstParam p1, const char* str, ::google::protobuf::Arena* arena,
+ bool donated, arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ SetBytes(str, arena, donated, donating_states, mask, msg);
+ }
+
+ template <typename FirstParam>
+ void SetBytes(FirstParam p1, const void* p, size_t size,
+ ::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ SetBytes(p, size, arena, donated, donating_states, mask, msg);
+ }
+
+ template <typename FirstParam, typename RefWrappedType>
+ void SetBytes(FirstParam p1,
+ std::reference_wrapper<RefWrappedType> const_string_ref,
+ ::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ SetBytes(const_string_ref.get(), arena, donated, donating_states, mask,
+ msg);
+ }
+
+ void SetNoArena(const TProtoStringType*, StringPiece value) {
+ SetNoArena(value);
+ }
+ void SetNoArena(const TProtoStringType*, TProtoStringType&& value) {
+ SetNoArena(std::move(value));
+ }
+
+ TProtoStringType* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ return Mutable(arena, donated, donating_states, mask, msg);
+ }
+
+ PROTOBUF_NDEBUG_INLINE TProtoStringType* MutableNoArenaNoDefault(
+ const TProtoStringType* /*default_value*/) {
+ return MutableNoCopy(nullptr);
+ }
+
+#endif // DEPRECATED_METHODS_TO_BE_DELETED
+
+ // Arena-safety semantics: this is guarded by the logic in
+ // Swap()/UnsafeArenaSwap() at the message level, so this method is
+ // 'unsafe' if called directly.
+ inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(
+ InlinedStringField* lhs, Arena* lhs_arena, bool lhs_arena_dtor_registered,
+ MessageLite* lhs_msg, //
+ InlinedStringField* rhs, Arena* rhs_arena, bool rhs_arena_dtor_registered,
+ MessageLite* rhs_msg);
// Frees storage (if not on an arena).
PROTOBUF_NDEBUG_INLINE void Destroy(const TProtoStringType* default_value,
@@ -254,17 +349,13 @@ class PROTOBUF_EXPORT InlinedStringField {
void ClearToDefault(const LazyString& default_value, Arena* arena,
bool donated);
- // Returns a mutable pointer, but doesn't initialize the string to the
- // default value.
- PROTOBUF_NDEBUG_INLINE TProtoStringType* MutableNoArenaNoDefault(
- const TProtoStringType* /*default_value*/);
-
// Generated code / reflection only! Returns a mutable pointer to the string.
PROTOBUF_NDEBUG_INLINE TProtoStringType* UnsafeMutablePointer();
// InlinedStringField doesn't have things like the `default_value` pointer in
// ArenaStringPtr.
- bool IsDefault(const TProtoStringType* /*default_value*/) const { return false; }
+ static constexpr bool IsDefault() { return false; }
+ static constexpr bool IsDefault(const TProtoStringType*) { return false; }
private:
void Destruct() { get_mutable()->~TBasicString(); }
@@ -275,7 +366,8 @@ class PROTOBUF_EXPORT InlinedStringField {
alignas(TProtoStringType) char value_[sizeof(TProtoStringType)];
TProtoStringType* MutableSlow(::google::protobuf::Arena* arena, bool donated,
- arc_ui32* donating_states, arc_ui32 mask);
+ arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg);
// When constructed in an Arena, we want our destructor to be skipped.
@@ -297,12 +389,8 @@ inline InlinedStringField::InlinedStringField(
new (get_mutable()) TProtoStringType(default_value);
}
-inline InlinedStringField::InlinedStringField(Arena* arena) {
- Init();
- if (arena != nullptr) {
- arena->OwnDestructor(get_mutable());
- }
-}
+
+inline InlinedStringField::InlinedStringField(Arena* /*arena*/) { Init(); }
inline const TProtoStringType& InlinedStringField::GetNoArena() const {
return *get_const();
@@ -325,56 +413,116 @@ inline void InlinedStringField::DestroyNoArena(const TProtoStringType*) {
this->~InlinedStringField();
}
-inline TProtoStringType* InlinedStringField::ReleaseNonDefaultNoArena(
- const TProtoStringType* /*default_value*/) {
- // Currently, inlined string field can't have non empty default.
- auto* released = new TProtoStringType();
- get_mutable()->swap(*released);
- return released;
-}
-
-inline void InlinedStringField::SetNoArena(const TProtoStringType* /*default_value*/,
- StringPiece value) {
+inline void InlinedStringField::SetNoArena(StringPiece value) {
get_mutable()->assign(value.data(), value.length());
}
-inline void InlinedStringField::SetNoArena(const TProtoStringType* /*default_value*/,
- TProtoStringType&& value) {
+inline void InlinedStringField::SetNoArena(TProtoStringType&& value) {
get_mutable()->assign(std::move(value));
}
-inline void InlinedStringField::Swap(
- InlinedStringField* from, const TProtoStringType* /*default_value*/,
- Arena* arena, bool donated, bool from_donated, arc_ui32* donating_states,
- arc_ui32* from_donating_states, arc_ui32 mask) {
+// Caller should make sure rhs_arena allocated rhs, and lhs_arena allocated lhs.
+inline PROTOBUF_NDEBUG_INLINE void InlinedStringField::InternalSwap(
+ InlinedStringField* lhs, Arena* lhs_arena, bool lhs_arena_dtor_registered,
+ MessageLite* lhs_msg, //
+ InlinedStringField* rhs, Arena* rhs_arena, bool rhs_arena_dtor_registered,
+ MessageLite* rhs_msg) {
#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE
- // If one is donated and the other is not, undonate the donated one.
- if (donated && !from_donated) {
- MutableSlow(arena, donated, donating_states, mask);
- } else if (!donated && from_donated) {
- from->MutableSlow(arena, from_donated, from_donating_states, mask);
+ lhs->get_mutable()->swap(*rhs->get_mutable());
+ if (!lhs_arena_dtor_registered && rhs_arena_dtor_registered) {
+ lhs_msg->OnDemandRegisterArenaDtor(lhs_arena);
+ } else if (lhs_arena_dtor_registered && !rhs_arena_dtor_registered) {
+ rhs_msg->OnDemandRegisterArenaDtor(rhs_arena);
}
- // Then, swap the two undonated strings.
#else
+ (void)lhs_arena;
+ (void)rhs_arena;
+ (void)lhs_arena_dtor_registered;
+ (void)rhs_arena_dtor_registered;
+ (void)lhs_msg;
+ (void)rhs_msg;
+ lhs->get_mutable()->swap(*rhs->get_mutable());
+#endif
+}
+
+inline void InlinedStringField::Set(ConstStringParam value, Arena* arena,
+ bool donated, arc_ui32* /*donating_states*/,
+ arc_ui32 /*mask*/, MessageLite* /*msg*/) {
(void)arena;
(void)donated;
- (void)from_donated;
- (void)donating_states;
- (void)from_donating_states;
- (void)mask;
-#endif
- get_mutable()->swap(*from->get_mutable());
+ SetNoArena(value);
}
-inline TProtoStringType* InlinedStringField::MutableNoArenaNoDefault(
- const TProtoStringType*) {
- return get_mutable();
+inline void InlinedStringField::Set(const char* str, ::google::protobuf::Arena* arena,
+ bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(ConstStringParam(str), arena, donated, donating_states, mask, msg);
+}
+
+inline void InlinedStringField::Set(const char* str, size_t size,
+ ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states, arc_ui32 mask,
+ MessageLite* msg) {
+ Set(ConstStringParam{str, size}, arena, donated, donating_states, mask, msg);
+}
+
+inline void InlinedStringField::SetBytes(ConstStringParam value, Arena* arena,
+ bool donated,
+ arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(value, arena, donated, donating_states, mask, msg);
+}
+
+inline void InlinedStringField::SetBytes(TProtoStringType&& value, Arena* arena,
+ bool donated,
+ arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(std::move(value), arena, donated, donating_states, mask, msg);
+}
+
+inline void InlinedStringField::SetBytes(const char* str,
+ ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(str, arena, donated, donating_states, mask, msg);
+}
+
+inline void InlinedStringField::SetBytes(const void* p, size_t size,
+ ::google::protobuf::Arena* arena, bool donated,
+ arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(static_cast<const char*>(p), size, arena, donated, donating_states, mask,
+ msg);
+}
+
+template <typename RefWrappedType>
+inline void InlinedStringField::Set(
+ std::reference_wrapper<RefWrappedType> const_string_ref,
+ ::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(const_string_ref.get(), arena, donated, donating_states, mask, msg);
+}
+
+template <typename RefWrappedType>
+inline void InlinedStringField::SetBytes(
+ std::reference_wrapper<RefWrappedType> const_string_ref,
+ ::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
+ arc_ui32 mask, MessageLite* msg) {
+ Set(const_string_ref.get(), arena, donated, donating_states, mask, msg);
}
inline TProtoStringType* InlinedStringField::UnsafeMutablePointer() {
return get_mutable();
}
+inline TProtoStringType* InlinedStringField::Mutable(std::nullptr_t) {
+ return get_mutable();
+}
+
+inline TProtoStringType* InlinedStringField::MutableNoCopy(std::nullptr_t) {
+ return get_mutable();
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc b/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc
index c209aeabad..a4fef38d10 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc
@@ -54,6 +54,7 @@
#include <google/protobuf/stubs/stl_util.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -196,7 +197,7 @@ void CodedInputStream::PrintTotalBytesLimitError() {
<< total_bytes_limit_
<< " bytes). To increase the limit (or to disable these "
"warnings), see CodedInputStream::SetTotalBytesLimit() "
- "in third_party/protobuf/src/google/protobuf/io/coded_stream.h.";
+ "in third_party/protobuf/io/coded_stream.h.";
}
bool CodedInputStream::SkipFallback(int count, int original_buffer_size) {
@@ -704,7 +705,7 @@ int EpsCopyOutputStream::Flush(uint8_t* ptr) {
uint8_t* EpsCopyOutputStream::Trim(uint8_t* ptr) {
if (had_error_) return ptr;
int s = Flush(ptr);
- if (s) stream_->BackUp(s);
+ stream_->BackUp(s);
// Reset to initial state (expecting new buffer)
buffer_end_ = end_ = buffer_;
return buffer_;
@@ -929,18 +930,6 @@ uint8_t* EpsCopyOutputStream::WriteStringOutline(arc_ui32 num, const TProtoStrin
std::atomic<bool> CodedOutputStream::default_serialization_deterministic_{
false};
-CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* stream,
- bool do_eager_refresh)
- : impl_(stream, IsDefaultSerializationDeterministic(), &cur_),
- start_count_(stream->ByteCount()) {
- if (do_eager_refresh) {
- void* data;
- int size;
- if (!stream->Next(&data, &size) || size == 0) return;
- cur_ = impl_.SetInitialBuffer(data, size);
- }
-}
-
CodedOutputStream::~CodedOutputStream() { Trim(); }
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h b/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
index 64d4068f5f..839ab42a45 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
@@ -158,6 +158,7 @@
#include <google/protobuf/stubs/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -848,6 +849,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
bool had_error_ = false;
bool aliasing_enabled_ = false; // See EnableAliasing().
bool is_serialization_deterministic_;
+ bool skip_check_consistency = false;
uint8_t* EnsureSpaceFallback(uint8_t* ptr);
inline uint8_t* Next();
@@ -1067,10 +1069,18 @@ inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<8>(const void* data,
// delete coded_output;
class PROTOBUF_EXPORT CodedOutputStream {
public:
- // Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.
- explicit CodedOutputStream(ZeroCopyOutputStream* stream)
- : CodedOutputStream(stream, true) {}
- CodedOutputStream(ZeroCopyOutputStream* stream, bool do_eager_refresh);
+ // Creates a CodedOutputStream that writes to the given `stream`.
+ // The provided stream must publicly derive from `ZeroCopyOutputStream`.
+ template <class Stream, class = typename std::enable_if<std::is_base_of<
+ ZeroCopyOutputStream, Stream>::value>::type>
+ explicit CodedOutputStream(Stream* stream);
+
+ // Creates a CodedOutputStream that writes to the given `stream`, and does
+ // an 'eager initialization' of the internal state if `eager_init` is true.
+ // The provided stream must publicly derive from `ZeroCopyOutputStream`.
+ template <class Stream, class = typename std::enable_if<std::is_base_of<
+ ZeroCopyOutputStream, Stream>::value>::type>
+ CodedOutputStream(Stream* stream, bool eager_init);
// Destroy the CodedOutputStream and position the underlying
// ZeroCopyOutputStream immediately after the last byte written.
@@ -1233,7 +1243,7 @@ class PROTOBUF_EXPORT CodedOutputStream {
// remains live until all of the data has been consumed from the stream.
void EnableAliasing(bool enabled) { impl_.EnableAliasing(enabled); }
- // Indicate to the serializer whether the user wants derministic
+ // Indicate to the serializer whether the user wants deterministic
// serialization. The default when this is not called comes from the global
// default, controlled by SetDefaultSerializationDeterministic.
//
@@ -1276,6 +1286,9 @@ class PROTOBUF_EXPORT CodedOutputStream {
EpsCopyOutputStream* EpsCopy() { return &impl_; }
private:
+ template <class Stream>
+ void InitEagerly(Stream* stream);
+
EpsCopyOutputStream impl_;
uint8_t* cur_;
arc_i64 start_count_;
@@ -1620,6 +1633,31 @@ inline bool CodedInputStream::Skip(int count) {
return SkipFallback(count, original_buffer_size);
}
+template <class Stream, class>
+inline CodedOutputStream::CodedOutputStream(Stream* stream)
+ : impl_(stream, IsDefaultSerializationDeterministic(), &cur_),
+ start_count_(stream->ByteCount()) {
+ InitEagerly(stream);
+}
+
+template <class Stream, class>
+inline CodedOutputStream::CodedOutputStream(Stream* stream, bool eager_init)
+ : impl_(stream, IsDefaultSerializationDeterministic(), &cur_),
+ start_count_(stream->ByteCount()) {
+ if (eager_init) {
+ InitEagerly(stream);
+ }
+}
+
+template <class Stream>
+inline void CodedOutputStream::InitEagerly(Stream* stream) {
+ void* data;
+ int size;
+ if (PROTOBUF_PREDICT_TRUE(stream->Next(&data, &size) && size > 0)) {
+ cur_ = impl_.SetInitialBuffer(data, size);
+ }
+}
+
inline uint8_t* CodedOutputStream::WriteVarint32ToArray(arc_ui32 value,
uint8_t* target) {
return EpsCopyOutputStream::UnsafeVarint(value, target);
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc b/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc
index 05c7772bd5..4b491dd024 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc
@@ -36,6 +36,7 @@
#if HAVE_ZLIB
#include <google/protobuf/io/gzip_stream.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
@@ -70,7 +71,7 @@ GzipInputStream::GzipInputStream(ZeroCopyInputStream* sub_stream, Format format,
output_position_ = output_buffer_;
}
GzipInputStream::~GzipInputStream() {
- operator delete(output_buffer_);
+ internal::SizedDelete(output_buffer_, output_buffer_length_);
zerror_ = inflateEnd(&zcontext_);
}
@@ -244,7 +245,7 @@ void GzipOutputStream::Init(ZeroCopyOutputStream* sub_stream,
GzipOutputStream::~GzipOutputStream() {
Close();
- operator delete(input_buffer_);
+ internal::SizedDelete(input_buffer_, input_buffer_length_);
}
// private
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h b/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h
index 43c740c78d..ba8338da2e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h
@@ -49,6 +49,7 @@
#include <google/protobuf/port.h>
#include <zlib.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -56,7 +57,8 @@ namespace protobuf {
namespace io {
// A ZeroCopyInputStream that reads compressed data through zlib
-class PROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyInputStream {
public:
// Format key for constructor
enum Format {
@@ -104,7 +106,8 @@ class PROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);
};
-class PROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyOutputStream {
public:
// Format key for constructor
enum Format {
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc b/contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc
index 903cb36fc3..e29ac4952e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc
@@ -397,7 +397,8 @@ ExpandWildcardsResult ExpandWildcards(
matched = ExpandWildcardsResult::kSuccess;
string filename;
if (!strings::wcs_to_utf8(metadata.cFileName, &filename)) {
- return ExpandWildcardsResult::kErrorOutputPathConversion;
+ matched = ExpandWildcardsResult::kErrorOutputPathConversion;
+ break;
}
if (dirname.empty()) {
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/io_win32.h b/contrib/libs/protobuf/src/google/protobuf/io/io_win32.h
index 8fb782f753..37572ef068 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/io_win32.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/io_win32.h
@@ -54,6 +54,8 @@
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/port.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
// Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/printer.cc b/contrib/libs/protobuf/src/google/protobuf/io/printer.cc
index 83ed7d1f69..e174a49133 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/printer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/printer.cc
@@ -66,8 +66,11 @@ Printer::Printer(ZeroCopyOutputStream* output, char variable_delimiter,
annotation_collector_(annotation_collector) {}
Printer::~Printer() {
- // Only BackUp() if we have called Next() at least once and never failed.
- if (buffer_size_ > 0 && !failed_) {
+ // Only BackUp() if we invoked Next() at least once, and we have never failed.
+ // Note that we always call `Backup`, i.e. we call BackUp(0) as some output
+ // streams have buffered output, and BackUp() serves as a flush event in such
+ // implementations.
+ if (buffer_ != nullptr && !failed_) {
output_->BackUp(buffer_size_);
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/printer.h b/contrib/libs/protobuf/src/google/protobuf/io/printer.h
index 5407e0e454..f1137fc689 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/printer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/printer.h
@@ -43,6 +43,8 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc
index 1fdb036cc2..cef4ce8fb0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc
@@ -92,8 +92,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/io/strtod.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/stl_util.h>
@@ -681,13 +681,12 @@ bool Tokenizer::Next() {
ConsumeString('\'');
current_.type = TYPE_STRING;
} else {
- // Check if the high order bit is set.
// The tokenizer is used to parse tomita grammars with non-ascii utf8 chars
// if (current_char_ & 0x80) {
// error_collector_->AddError(
// line_, column_,
// StringPrintf("Interpreting non ascii codepoint %d.",
- // static_cast<unsigned char>(current_char_)));
+ // static_cast<unsigned char>(current_char_)));
// }
NextChar();
current_.type = TYPE_SYMBOL;
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h
index de1abdf622..984004e696 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h
@@ -43,6 +43,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.h b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.h
index d3bd6daed3..e2c9737eb6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.h
@@ -111,9 +111,11 @@
#include <string>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -154,6 +156,13 @@ class PROTOBUF_EXPORT ZeroCopyInputStream {
// buffer that goes beyond what you wanted to read, you can use BackUp()
// to return to the point where you intended to finish.
//
+ // This method can be called with `count = 0` to finalize (flush) any
+ // previously returned buffer. For example, a file output stream can
+ // flush buffers returned from a previous call to Next() upon such
+ // BackUp(0) invocations. ZeroCopyOutputStream callers should always
+ // invoke BackUp() after a final Next() call, even if there is no
+ // excess buffer data to be backed up to indicate a flush point.
+ //
// Preconditions:
// * The last method called must have been Next().
// * count must be less than or equal to the size of the last buffer
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h
index 1f4426c628..6ec43b2ee2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h
@@ -48,6 +48,7 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -62,7 +63,8 @@ namespace io {
// The latter will introduce an extra layer of buffering, harming performance.
// Also, it's conceivable that FileInputStream could someday be enhanced
// to use zero-copy file descriptors on OSs which support them.
-class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT FileInputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given Unix file descriptor.
// If a block_size is given, it specifies the number of bytes that
@@ -95,7 +97,8 @@ class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
int64_t ByteCount() const override;
private:
- class PROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
+ class PROTOBUF_EXPORT CopyingFileInputStream PROTOBUF_FUTURE_FINAL
+ : public CopyingInputStream {
public:
CopyingFileInputStream(int file_descriptor);
~CopyingFileInputStream() override;
@@ -139,7 +142,8 @@ class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
// harming performance. Also, it's conceivable that FileOutputStream could
// someday be enhanced to use zero-copy file descriptors on OSs which
// support them.
-class PROTOBUF_EXPORT FileOutputStream : public CopyingOutputStreamAdaptor {
+class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL
+ : public CopyingOutputStreamAdaptor {
public:
// Creates a stream that writes to the given Unix file descriptor.
// If a block_size is given, it specifies the size of the buffers
@@ -168,7 +172,8 @@ class PROTOBUF_EXPORT FileOutputStream : public CopyingOutputStreamAdaptor {
int GetErrno() const { return copying_output_.GetErrno(); }
private:
- class PROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
+ class PROTOBUF_EXPORT CopyingFileOutputStream PROTOBUF_FUTURE_FINAL
+ : public CopyingOutputStream {
public:
CopyingFileOutputStream(int file_descriptor);
~CopyingFileOutputStream() override;
@@ -203,7 +208,8 @@ class PROTOBUF_EXPORT FileOutputStream : public CopyingOutputStreamAdaptor {
//
// Note that for reading files (or anything represented by a file descriptor),
// FileInputStream is more efficient.
-class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given C++ istream.
// If a block_size is given, it specifies the number of bytes that
@@ -218,7 +224,8 @@ class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
int64_t ByteCount() const override;
private:
- class PROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
+ class PROTOBUF_EXPORT CopyingIstreamInputStream PROTOBUF_FUTURE_FINAL
+ : public CopyingInputStream {
public:
CopyingIstreamInputStream(std::istream* input);
~CopyingIstreamInputStream() override;
@@ -246,7 +253,8 @@ class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
//
// Note that for writing files (or anything represented by a file descriptor),
// FileOutputStream is more efficient.
-class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given C++ ostream.
// If a block_size is given, it specifies the size of the buffers
@@ -261,7 +269,7 @@ class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
int64_t ByteCount() const override;
private:
- class PROTOBUF_EXPORT CopyingOstreamOutputStream
+ class PROTOBUF_EXPORT CopyingOstreamOutputStream PROTOBUF_FUTURE_FINAL
: public CopyingOutputStream {
public:
CopyingOstreamOutputStream(std::ostream* output);
@@ -292,7 +300,8 @@ class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
// ConcatenatingInputStream may do odd things. It is suggested that you do
// not use ConcatenatingInputStream on streams that might produce read errors
// other than end-of-stream.
-class PROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ConcatenatingInputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyInputStream {
public:
// All streams passed in as well as the array itself must remain valid
// until the ConcatenatingInputStream is destroyed.
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
index 1325f04e35..29cb50807c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
@@ -124,12 +124,11 @@ bool ArrayOutputStream::Next(void** data, int* size) {
}
void ArrayOutputStream::BackUp(int count) {
- GOOGLE_CHECK_GT(last_returned_size_, 0)
- << "BackUp() can only be called after a successful Next().";
- GOOGLE_CHECK_LE(count, last_returned_size_);
+ GOOGLE_CHECK_LE(count, last_returned_size_)
+ << "BackUp() can not exceed the size of the last Next() call.";
GOOGLE_CHECK_GE(count, 0);
position_ -= count;
- last_returned_size_ = 0; // Don't let caller back up further.
+ last_returned_size_ -= count;
}
int64_t ArrayOutputStream::ByteCount() const { return position_; }
@@ -328,6 +327,10 @@ bool CopyingOutputStreamAdaptor::Next(void** data, int* size) {
}
void CopyingOutputStreamAdaptor::BackUp(int count) {
+ if (count == 0) {
+ Flush();
+ return;
+ }
GOOGLE_CHECK_GE(count, 0);
GOOGLE_CHECK_EQ(buffer_used_, buffer_size_)
<< " BackUp() can only be called after Next().";
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
index b5ccd6c2e1..aff4c5c603 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
@@ -55,6 +55,7 @@
#include <google/protobuf/stubs/stl_util.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -64,7 +65,8 @@ namespace io {
// ===================================================================
// A ZeroCopyInputStream backed by an in-memory array of bytes.
-class PROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ArrayInputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyInputStream {
public:
// Create an InputStream that returns the bytes pointed to by "data".
// "data" remains the property of the caller but must remain valid until
@@ -98,7 +100,8 @@ class PROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
// ===================================================================
// A ZeroCopyOutputStream backed by an in-memory array of bytes.
-class PROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT ArrayOutputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyOutputStream {
public:
// Create an OutputStream that writes to the bytes pointed to by "data".
// "data" remains the property of the caller but must remain valid until
@@ -130,7 +133,8 @@ class PROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
// ===================================================================
// A ZeroCopyOutputStream which appends bytes to a string.
-class PROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT StringOutputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyOutputStream {
public:
// Create a StringOutputStream which appends bytes to the given string.
// The string remains property of the caller, but it is mutated in arbitrary
@@ -346,7 +350,8 @@ class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
// A ZeroCopyInputStream which wraps some other stream and limits it to
// a particular byte count.
-class PROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT LimitingInputStream PROTOBUF_FUTURE_FINAL
+ : public ZeroCopyInputStream {
public:
LimitingInputStream(ZeroCopyInputStream* input, arc_i64 limit);
~LimitingInputStream() override;
diff --git a/contrib/libs/protobuf/src/google/protobuf/map.h b/contrib/libs/protobuf/src/google/protobuf/map.h
index 6b56354e4d..c51a83a1b1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map.h
@@ -37,6 +37,7 @@
#ifndef GOOGLE_PROTOBUF_MAP_H__
#define GOOGLE_PROTOBUF_MAP_H__
+
#include <functional>
#include <initializer_list>
#include <iterator>
@@ -59,12 +60,14 @@
#include <google/protobuf/arena.h>
#include <google/protobuf/generated_enum_util.h>
#include <google/protobuf/map_type_handler.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/stubs/hash.h>
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -116,6 +119,11 @@ class MapAllocator {
MapAllocator(const MapAllocator<X>& allocator) // NOLINT(runtime/explicit)
: arena_(allocator.arena()) {}
+ // MapAllocator does not support alignments beyond 8. Technically we should
+ // support up to std::max_align_t, but this fails with ubsan and tcmalloc
+ // debug allocation logic which assume 8 as default alignment.
+ static_assert(alignof(value_type) <= 8, "");
+
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.
@@ -129,12 +137,7 @@ class MapAllocator {
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
+ internal::SizedDelete(p, n * sizeof(value_type));
}
}
@@ -335,7 +338,7 @@ inline size_t SpaceUsedInValues(const void*) { return 0; }
// std::pair as value_type, we use this class which provides us more control of
// its process of construction and destruction.
template <typename Key, typename T>
-struct MapPair {
+struct PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG MapPair {
using first_type = const Key;
using second_type = T;
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_entry.h b/contrib/libs/protobuf/src/google/protobuf/map_entry.h
index 250dc59384..021a56000c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_entry.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_entry.h
@@ -31,14 +31,15 @@
#ifndef GOOGLE_PROTOBUF_MAP_ENTRY_H__
#define GOOGLE_PROTOBUF_MAP_ENTRY_H__
+#include <google/protobuf/port.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/map_entry_lite.h>
#include <google/protobuf/map_type_handler.h>
-#include <google/protobuf/port.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -93,14 +94,12 @@ template <typename Derived, typename Key, typename Value,
class MapEntry : public MapEntryImpl<Derived, Message, Key, Value,
kKeyFieldType, kValueFieldType> {
public:
- constexpr MapEntry() : _internal_metadata_() {}
+ constexpr MapEntry() {}
explicit MapEntry(Arena* arena)
: MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
- kValueFieldType>(arena),
- _internal_metadata_(arena) {}
- ~MapEntry() {
+ kValueFieldType>(arena) {}
+ ~MapEntry() override {
Message::_internal_metadata_.template Delete<UnknownFieldSet>();
- _internal_metadata_.Delete<UnknownFieldSet>();
}
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
@@ -117,8 +116,6 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value,
return size;
}
- InternalMetadata _internal_metadata_;
-
private:
friend class ::PROTOBUF_NAMESPACE_ID::Arena;
template <typename C, typename K, typename V,
@@ -128,29 +125,6 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value,
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry);
};
-// Specialization for the full runtime
-template <typename Derived, typename Key, typename Value,
- WireFormatLite::FieldType kKeyFieldType,
- WireFormatLite::FieldType kValueFieldType>
-struct MapEntryHelper<
- MapEntry<Derived, Key, Value, kKeyFieldType, kValueFieldType> >
- : MapEntryHelper<
- MapEntryLite<Derived, Key, Value, kKeyFieldType, kValueFieldType> > {
- explicit MapEntryHelper(const MapPair<Key, Value>& map_pair)
- : MapEntryHelper<
- MapEntryLite<Derived, Key, Value, kKeyFieldType, kValueFieldType> >(
- map_pair) {}
-};
-
-template <typename Derived, typename K, typename V,
- WireFormatLite::FieldType key, WireFormatLite::FieldType value>
-struct DeconstructMapEntry<MapEntry<Derived, K, V, key, value> > {
- typedef K Key;
- typedef V Value;
- static constexpr WireFormatLite::FieldType kKeyFieldType = key;
- static constexpr WireFormatLite::FieldType kValueFieldType = value;
-};
-
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h b/contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h
index d9880b2abb..692f42b912 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h
@@ -32,19 +32,23 @@
#define GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
#include <assert.h>
+
+#include <algorithm>
#include <string>
+#include <utility>
#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/map.h>
#include <google/protobuf/map_type_handler.h>
-#include <google/protobuf/port.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -97,44 +101,6 @@ struct MoveHelper<false, false, true, T> { // strings and similar
}
};
-// Functions for operating on a map entry. Does not contain any representation
-// (this class is not intended to be instantiated).
-template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
- WireFormatLite::FieldType kValueFieldType>
-struct MapEntryFuncs {
- typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
- typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;
- static const int kKeyFieldNumber = 1;
- static const int kValueFieldNumber = 2;
-
- static uint8_t* InternalSerialize(int field_number, const Key& key,
- const Value& value, uint8_t* ptr,
- io::EpsCopyOutputStream* stream) {
- ptr = stream->EnsureSpace(ptr);
- ptr = WireFormatLite::WriteTagToArray(
- field_number, WireFormatLite::WIRETYPE_LENGTH_DELIMITED, ptr);
- ptr = io::CodedOutputStream::WriteVarint32ToArray(GetCachedSize(key, value),
- ptr);
-
- ptr = KeyTypeHandler::Write(kKeyFieldNumber, key, ptr, stream);
- return ValueTypeHandler::Write(kValueFieldNumber, value, ptr, stream);
- }
-
- static size_t ByteSizeLong(const Key& key, const Value& value) {
- // Tags for key and value will both be one byte (field numbers 1 and 2).
- size_t inner_length =
- 2 + KeyTypeHandler::ByteSize(key) + ValueTypeHandler::ByteSize(value);
- return inner_length + io::CodedOutputStream::VarintSize32(
- static_cast<arc_ui32>(inner_length));
- }
-
- static int GetCachedSize(const Key& key, const Value& value) {
- // Tags for key and value will both be one byte (field numbers 1 and 2).
- return 2 + KeyTypeHandler::GetCachedSize(key) +
- ValueTypeHandler::GetCachedSize(value);
- }
-};
-
// MapEntryImpl is used to implement parsing and serialization of map entries.
// It uses Curious Recursive Template Pattern (CRTP) to provide the type of
// the eventual code to the template code.
@@ -193,7 +159,7 @@ class MapEntryImpl : public Base {
value_(ValueTypeHandler::Constinit()),
_has_bits_{} {}
- ~MapEntryImpl() {
+ ~MapEntryImpl() override {
if (Base::GetArenaForAllocation() != nullptr) return;
KeyTypeHandler::DeleteNoArena(key_);
ValueTypeHandler::DeleteNoArena(value_);
@@ -329,51 +295,6 @@ class MapEntryImpl : public Base {
delete entry_;
}
- // This does what the typical MergePartialFromCodedStream() is expected to
- // do, with the additional side-effect that if successful (i.e., if true is
- // going to be its return value) it inserts the key-value pair into map_.
- bool MergePartialFromCodedStream(io::CodedInputStream* input) {
- // Look for the expected thing: a key and then a value. If it fails,
- // invoke the enclosing class's MergePartialFromCodedStream, or return
- // false if that would be pointless.
- if (input->ExpectTag(kKeyTag)) {
- if (!KeyTypeHandler::Read(input, &key_)) {
- return false;
- }
- // Peek at the next byte to see if it is kValueTag. If not, bail out.
- const void* data;
- int size;
- input->GetDirectBufferPointerInline(&data, &size);
- // We could use memcmp here, but we don't bother. The tag is one byte.
- static_assert(kTagSize == 1, "tag size must be 1");
- if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) {
- typename Map::size_type map_size = map_->size();
- value_ptr_ = &(*map_)[key_];
- if (PROTOBUF_PREDICT_TRUE(map_size != map_->size())) {
- // We created a new key-value pair. Fill in the value.
- typedef
- typename MapIf<ValueTypeHandler::kIsEnum, int*, Value*>::type T;
- input->Skip(kTagSize); // Skip kValueTag.
- if (!ValueTypeHandler::Read(input,
- reinterpret_cast<T>(value_ptr_))) {
- map_->erase(key_); // Failure! Undo insertion.
- return false;
- }
- if (input->ExpectAtEnd()) return true;
- return ReadBeyondKeyValuePair(input);
- }
- }
- } else {
- key_ = Key();
- }
-
- NewEntry();
- *entry_->mutable_key() = key_;
- const bool result = entry_->MergePartialFromCodedStream(input);
- if (result) UseKeyAndValueFromEntry();
- return result;
- }
-
const char* _InternalParse(const char* ptr, ParseContext* ctx) {
if (PROTOBUF_PREDICT_TRUE(!ctx->Done(&ptr) && *ptr == kKeyTag)) {
ptr = KeyTypeHandler::Read(ptr + 1, ctx, &key_);
@@ -493,7 +414,7 @@ class MapEntryImpl : public Base {
public:
inline Arena* GetArena() const { return Base::GetArena(); }
- public: // Needed for constructing tables
+ protected: // Needed for constructing tables
KeyOnMemory key_;
ValueOnMemory value_;
arc_ui32 _has_bits_[1];
@@ -523,7 +444,7 @@ class MapEntryLite : public MapEntryImpl<T, MessageLite, Key, Value,
SuperType;
constexpr MapEntryLite() {}
explicit MapEntryLite(Arena* arena) : SuperType(arena) {}
- ~MapEntryLite() {
+ ~MapEntryLite() override {
MessageLite::_internal_metadata_.template Delete<TProtoStringType>();
}
void MergeFrom(const MapEntryLite& other) { MergeFromInternal(other); }
@@ -531,118 +452,106 @@ class MapEntryLite : public MapEntryImpl<T, MessageLite, Key, Value,
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite);
};
-// The completely unprincipled and unwieldy use of template parameters in
-// the map code necessitates wrappers to make the code a little bit more
-// manageable.
-template <typename Derived>
-struct DeconstructMapEntry;
-
-template <typename T, typename K, typename V, WireFormatLite::FieldType key,
- WireFormatLite::FieldType value>
-struct DeconstructMapEntry<MapEntryLite<T, K, V, key, value> > {
- typedef K Key;
- typedef V Value;
- static const WireFormatLite::FieldType kKeyFieldType = key;
- static const WireFormatLite::FieldType kValueFieldType = value;
-};
// Helpers for deterministic serialization =============================
-// This struct can be used with any generic sorting algorithm. If the Key
-// type is relatively small and easy to copy then copying Keys into an
-// array of SortItems can be beneficial. Then all the data the sorting
-// algorithm needs to touch is in that one array.
-template <typename Key, typename PtrToKeyValuePair>
-struct SortItem {
- SortItem() {}
- explicit SortItem(PtrToKeyValuePair p) : first(p->first), second(p) {}
-
- Key first;
- PtrToKeyValuePair second;
+// Iterator base for MapSorterFlat and MapSorterPtr.
+template <typename storage_type>
+struct MapSorterIt {
+ storage_type* ptr;
+ MapSorterIt(storage_type* ptr) : ptr(ptr) {}
+ bool operator==(const MapSorterIt& other) const { return ptr == other.ptr; }
+ bool operator!=(const MapSorterIt& other) const { return !(*this == other); }
+ MapSorterIt& operator++() { ++ptr; return *this; }
+ MapSorterIt operator++(int) { auto other = *this; ++ptr; return other; }
+ MapSorterIt operator+(int v) { return MapSorterIt{ptr + v}; }
};
-template <typename T>
-struct CompareByFirstField {
- bool operator()(const T& a, const T& b) const { return a.first < b.first; }
-};
-
-template <typename T>
-struct CompareByDerefFirst {
- bool operator()(const T& a, const T& b) const { return a->first < b->first; }
-};
-
-// Helper for table driven serialization
+// MapSorterFlat stores keys inline with pointers to map entries, so that
+// keys can be compared without indirection. This type is used for maps with
+// keys that are not strings.
+template <typename MapT>
+class MapSorterFlat {
+ public:
+ using value_type = typename MapT::value_type;
+ using storage_type = std::pair<typename MapT::key_type, const value_type*>;
+
+ // This const_iterator dereferenes to the map entry stored in the sorting
+ // array pairs. This is the same interface as the Map::const_iterator type,
+ // and allows generated code to use the same loop body with either form:
+ // for (const auto& entry : map) { ... }
+ // for (const auto& entry : MapSorterFlat(map)) { ... }
+ struct const_iterator : public MapSorterIt<storage_type> {
+ using pointer = const typename MapT::value_type*;
+ using reference = const typename MapT::value_type&;
+ using MapSorterIt<storage_type>::MapSorterIt;
+
+ pointer operator->() const { return this->ptr->second; }
+ reference operator*() const { return *this->operator->(); }
+ };
-template <WireFormatLite::FieldType FieldType>
-struct FromHelper {
- template <typename T>
- static const T& From(const T& x) {
- return x;
+ explicit MapSorterFlat(const MapT& m)
+ : size_(m.size()), items_(size_ ? new storage_type[size_] : nullptr) {
+ if (!size_) return;
+ storage_type* it = &items_[0];
+ for (const auto& entry : m) {
+ *it++ = {entry.first, &entry};
+ }
+ std::sort(&items_[0], &items_[size_],
+ [](const storage_type& a, const storage_type& b) {
+ return a.first < b.first;
+ });
}
-};
+ size_t size() const { return size_; }
+ const_iterator begin() const { return {items_.get()}; }
+ const_iterator end() const { return {items_.get() + size_}; }
-template <>
-struct FromHelper<WireFormatLite::TYPE_STRING> {
- static ArenaStringPtr From(const TProtoStringType& x) {
- ArenaStringPtr res;
- TaggedPtr<TProtoStringType> ptr;
- ptr.Set(const_cast<TProtoStringType*>(&x));
- res.UnsafeSetTaggedPointer(ptr);
- return res;
- }
-};
-template <>
-struct FromHelper<WireFormatLite::TYPE_BYTES> {
- static ArenaStringPtr From(const TProtoStringType& x) {
- ArenaStringPtr res;
- TaggedPtr<TProtoStringType> ptr;
- ptr.Set(const_cast<TProtoStringType*>(&x));
- res.UnsafeSetTaggedPointer(ptr);
- return res;
- }
-};
-template <>
-struct FromHelper<WireFormatLite::TYPE_MESSAGE> {
- template <typename T>
- static T* From(const T& x) {
- return const_cast<T*>(&x);
- }
+ private:
+ size_t size_;
+ std::unique_ptr<storage_type[]> items_;
};
-template <typename MapEntryType>
-struct MapEntryHelper;
-
-template <typename T, typename Key, typename Value,
- WireFormatLite::FieldType kKeyFieldType,
- WireFormatLite::FieldType kValueFieldType>
-struct MapEntryHelper<
- MapEntryLite<T, Key, Value, kKeyFieldType, kValueFieldType> > {
- // Provide utilities to parse/serialize key/value. Provide utilities to
- // manipulate internal stored type.
- typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
- typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;
+// MapSorterPtr stores and sorts pointers to map entries. This type is used for
+// maps with keys that are strings.
+template <typename MapT>
+class MapSorterPtr {
+ public:
+ using value_type = typename MapT::value_type;
+ using storage_type = const typename MapT::value_type*;
+
+ // This const_iterator dereferenes the map entry pointer stored in the sorting
+ // array. This is the same interface as the Map::const_iterator type, and
+ // allows generated code to use the same loop body with either form:
+ // for (const auto& entry : map) { ... }
+ // for (const auto& entry : MapSorterPtr(map)) { ... }
+ struct const_iterator : public MapSorterIt<storage_type> {
+ using pointer = const typename MapT::value_type*;
+ using reference = const typename MapT::value_type&;
+ using MapSorterIt<storage_type>::MapSorterIt;
+
+ pointer operator->() const { return *this->ptr; }
+ reference operator*() const { return *this->operator->(); }
+ };
- // Define internal memory layout. Strings and messages are stored as
- // pointers, while other types are stored as values.
- typedef typename KeyTypeHandler::TypeOnMemory KeyOnMemory;
- typedef typename ValueTypeHandler::TypeOnMemory ValueOnMemory;
+ explicit MapSorterPtr(const MapT& m)
+ : size_(m.size()), items_(size_ ? new storage_type[size_] : nullptr) {
+ if (!size_) return;
+ storage_type* it = &items_[0];
+ for (const auto& entry : m) {
+ *it++ = &entry;
+ }
+ std::sort(&items_[0], &items_[size_],
+ [](const storage_type& a, const storage_type& b) {
+ return a->first < b->first;
+ });
+ }
+ size_t size() const { return size_; }
+ const_iterator begin() const { return {items_.get()}; }
+ const_iterator end() const { return {items_.get() + size_}; }
- explicit MapEntryHelper(const MapPair<Key, Value>& map_pair)
- : _has_bits_(3),
- _cached_size_(2 + KeyTypeHandler::GetCachedSize(map_pair.first) +
- ValueTypeHandler::GetCachedSize(map_pair.second)),
- key_(FromHelper<kKeyFieldType>::From(map_pair.first)),
- value_(FromHelper<kValueFieldType>::From(map_pair.second)) {}
-
- // Purposely not following the style guide naming. These are the names
- // the proto compiler would generate given the map entry descriptor.
- // The proto compiler generates the offsets in this struct as if this was
- // a regular message. This way the table driven code barely notices it's
- // dealing with a map field.
- arc_ui32 _has_bits_; // NOLINT
- arc_ui32 _cached_size_; // NOLINT
- KeyOnMemory key_; // NOLINT
- ValueOnMemory value_; // NOLINT
+ private:
+ size_t size_;
+ std::unique_ptr<storage_type[]> items_;
};
} // namespace internal
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_field.cc b/contrib/libs/protobuf/src/google/protobuf/map_field.cc
index d6534806fe..34df16989f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field.cc
@@ -29,18 +29,23 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <google/protobuf/map_field.h>
-#include <google/protobuf/map_field_inl.h>
#include <vector>
+#include <google/protobuf/map_field_inl.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
namespace internal {
-MapFieldBase::~MapFieldBase() {
- if (repeated_field_ != nullptr && arena_ == nullptr) delete repeated_field_;
+void MapFieldBase::Destruct() {
+ if (arena_ == nullptr) {
+ delete repeated_field_;
+ }
+ repeated_field_ = nullptr;
}
const RepeatedPtrFieldBase& MapFieldBase::GetRepeatedField() const {
@@ -219,13 +224,15 @@ DynamicMapField::DynamicMapField(const Message* default_entry, Arena* arena)
default_entry_(default_entry) {}
DynamicMapField::~DynamicMapField() {
- if (arena_ != nullptr) return;
- // DynamicMapField owns map values. Need to delete them before clearing the
- // map.
- for (auto& kv : map_) {
- kv.second.DeleteData();
+ if (arena_ == nullptr) {
+ // DynamicMapField owns map values. Need to delete them before clearing the
+ // map.
+ for (auto& kv : map_) {
+ kv.second.DeleteData();
+ }
+ map_.clear();
}
- map_.clear();
+ Destruct();
}
int DynamicMapField::size() const { return GetMap().size(); }
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_field.h b/contrib/libs/protobuf/src/google/protobuf/map_field.h
index f5b7c6177a..088388382d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field.h
@@ -35,6 +35,9 @@
#include <functional>
#include <google/protobuf/arena.h>
+#include <google/protobuf/stubs/mutex.h>
+#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/generated_message_util.h>
@@ -42,13 +45,11 @@
#include <google/protobuf/map_field_lite.h>
#include <google/protobuf/map_type_handler.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/stubs/mutex.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/port.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -60,6 +61,13 @@ namespace protobuf {
class DynamicMessage;
class MapIterator;
+// Microsoft compiler complains about non-virtual destructor,
+// even when the destructor is private.
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4265)
+#endif // _MSC_VER
+
#define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
if (type() != EXPECTEDTYPE) { \
GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n" \
@@ -331,15 +339,22 @@ class PROTOBUF_EXPORT MapFieldBase {
// It uses a linker initialized mutex, so it is not compatible with regular
// runtime instances.
// Except in MSVC, where we can't have a constinit mutex.
- explicit constexpr MapFieldBase(ConstantInitialized)
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ constexpr MapFieldBase(ConstantInitialized)
: arena_(nullptr),
repeated_field_(nullptr),
mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED),
state_(STATE_MODIFIED_MAP) {}
explicit MapFieldBase(Arena* arena)
: arena_(arena), repeated_field_(nullptr), state_(STATE_MODIFIED_MAP) {}
- virtual ~MapFieldBase();
+ protected:
+ ~MapFieldBase() { // "protected" stops users from deleting a `MapFieldBase *`
+ GOOGLE_DCHECK(repeated_field_ == nullptr);
+ }
+ void Destruct();
+
+ public:
// Returns reference to internal repeated field. Data written using
// Map's api prior to calling this function is guarantted to be
// included in repeated field.
@@ -484,10 +499,18 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
// This constructor is for constant initialized global instances.
// It uses a linker initialized mutex, so it is not compatible with regular
// runtime instances.
- explicit constexpr TypeDefinedMapFieldBase(ConstantInitialized tag)
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ constexpr TypeDefinedMapFieldBase(ConstantInitialized tag)
: MapFieldBase(tag) {}
explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {}
- ~TypeDefinedMapFieldBase() override {}
+ TypeDefinedMapFieldBase(ArenaInitialized, Arena* arena)
+ : TypeDefinedMapFieldBase(arena) {}
+
+ protected:
+ ~TypeDefinedMapFieldBase() {}
+ using MapFieldBase::Destruct;
+
+ public:
void MapBegin(MapIterator* map_iter) const override;
void MapEnd(MapIterator* map_iter) const override;
bool EqualIterator(const MapIterator& a, const MapIterator& b) const override;
@@ -537,18 +560,24 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType;
public:
- typedef typename Derived::SuperType EntryTypeTrait;
typedef Map<Key, T> MapType;
- MapField() {}
+ MapField() : impl_() {}
+ virtual ~MapField() {} // Destruct() must already have been called!
+ void Destruct() {
+ impl_.Destruct();
+ TypeDefinedMapFieldBase<Key, T>::Destruct();
+ }
// This constructor is for constant initialized global instances.
// It uses a linker initialized mutex, so it is not compatible with regular
// runtime instances.
- explicit constexpr MapField(ConstantInitialized tag)
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ constexpr MapField(ConstantInitialized tag)
: TypeDefinedMapFieldBase<Key, T>(tag), impl_() {}
explicit MapField(Arena* arena)
: TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {}
+ MapField(ArenaInitialized, Arena* arena) : MapField(arena) {}
// Implement MapFieldBase
bool ContainsMapKey(const MapKey& map_key) const override;
@@ -580,16 +609,6 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
// Used in the implementation of parsing. Caller should take the ownership iff
// arena_ is nullptr.
EntryType* NewEntry() const { return impl_.NewEntry(); }
- // Used in the implementation of serializing enum value type. Caller should
- // take the ownership iff arena_ is nullptr.
- EntryType* NewEnumEntryWrapper(const Key& key, const T t) const {
- return impl_.NewEnumEntryWrapper(key, t);
- }
- // Used in the implementation of serializing other value types. Caller should
- // take the ownership iff arena_ is nullptr.
- EntryType* NewEntryWrapper(const Key& key, const T& t) const {
- return impl_.NewEntryWrapper(key, t);
- }
const char* _InternalParse(const char* ptr, ParseContext* ctx) {
return impl_._InternalParse(ptr, ctx);
@@ -646,7 +665,7 @@ class PROTOBUF_EXPORT DynamicMapField
public:
explicit DynamicMapField(const Message* default_entry);
DynamicMapField(const Message* default_entry, Arena* arena);
- ~DynamicMapField() override;
+ virtual ~DynamicMapField();
// Implement MapFieldBase
bool ContainsMapKey(const MapKey& map_key) const override;
@@ -856,8 +875,8 @@ class PROTOBUF_EXPORT MapIterator {
MapIterator(Message* message, const FieldDescriptor* field) {
const Reflection* reflection = message->GetReflection();
map_ = reflection->MutableMapData(message, field);
- key_.SetType(field->message_type()->FindFieldByName("key")->cpp_type());
- value_.SetType(field->message_type()->FindFieldByName("value")->cpp_type());
+ key_.SetType(field->message_type()->map_key()->cpp_type());
+ value_.SetType(field->message_type()->map_value()->cpp_type());
map_->InitializeIterator(this);
}
MapIterator(const MapIterator& other) {
@@ -919,6 +938,10 @@ class PROTOBUF_EXPORT MapIterator {
} // namespace protobuf
} // namespace google
+#ifdef _MSC_VER
+#pragma warning(pop) // restore warning C4265
+#endif // _MSC_VER
+
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_MAP_FIELD_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_field_lite.h b/contrib/libs/protobuf/src/google/protobuf/map_field_lite.h
index c86e4af824..6aa08030f2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field_lite.h
@@ -32,13 +32,15 @@
#define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__
#include <type_traits>
-#include <google/protobuf/parse_context.h>
+
#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/map.h>
#include <google/protobuf/map_entry_lite.h>
-#include <google/protobuf/port.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -49,6 +51,10 @@ namespace google {
namespace protobuf {
namespace internal {
+#ifndef NDEBUG
+void MapFieldLiteNotDestructed(void* map_field_lite);
+#endif
+
// This class provides access to map field using generated api. It is used for
// internal generated message implementation only. Users should never use this
// directly.
@@ -61,12 +67,30 @@ class MapFieldLite {
public:
typedef Map<Key, T> MapType;
- typedef EntryType EntryTypeTrait;
-
- constexpr MapFieldLite() {}
+ constexpr MapFieldLite() : map_() {}
explicit MapFieldLite(Arena* arena) : map_(arena) {}
-
+ MapFieldLite(ArenaInitialized, Arena* arena) : MapFieldLite(arena) {}
+
+#ifdef NDEBUG
+ void Destruct() { map_.~Map(); }
+ ~MapFieldLite() {}
+#else
+ void Destruct() {
+ // We want to destruct the map in such a way that we can verify
+ // that we've done that, but also be sure that we've deallocated
+ // everything (as opposed to leaving an allocation behind with no
+ // data in it, as would happen if a vector was resize'd to zero.
+ // Map::Swap with an empty map accomplishes that.
+ decltype(map_) swapped_map(map_.arena());
+ map_.InternalSwap(swapped_map);
+ }
+ ~MapFieldLite() {
+ if (map_.arena() == nullptr && !map_.empty()) {
+ MapFieldLiteNotDestructed(this);
+ }
+ }
+#endif
// Accessors
const Map<Key, T>& GetMap() const { return map_; }
Map<Key, T>* MutableMap() { return &map_; }
@@ -88,16 +112,6 @@ class MapFieldLite {
EntryType* NewEntry() const {
return Arena::CreateMessage<EntryType>(map_.arena());
}
- // Used in the implementation of serializing enum value type. Caller should
- // take the ownership iff arena_ is nullptr.
- EntryType* NewEnumEntryWrapper(const Key& key, const T t) const {
- return EntryType::EnumWrap(key, t, map_.arena_);
- }
- // Used in the implementation of serializing other value types. Caller should
- // take the ownership iff arena_ is nullptr.
- EntryType* NewEntryWrapper(const Key& key, const T& t) const {
- return EntryType::Wrap(key, t, map_.arena_);
- }
const char* _InternalParse(const char* ptr, ParseContext* ctx) {
typename Derived::template Parser<MapFieldLite, Map<Key, T>> parser(this);
@@ -116,7 +130,11 @@ class MapFieldLite {
private:
typedef void DestructorSkippable_;
- Map<Key, T> map_;
+ // map_ is inside an anonymous union so we can explicitly control its
+ // destruction
+ union {
+ Map<Key, T> map_;
+ };
friend class ::PROTOBUF_NAMESPACE_ID::Arena;
};
@@ -175,6 +193,13 @@ struct MapEntryToMapField<
MapFieldType;
};
+#ifndef NDEBUG
+inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) {
+ bool proper_destruct = false;
+ GOOGLE_CHECK(proper_destruct) << map_field_lite;
+}
+#endif
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_type_handler.h b/contrib/libs/protobuf/src/google/protobuf/map_type_handler.h
index db7f6fdbb3..3cc189416b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_type_handler.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_type_handler.h
@@ -31,9 +31,10 @@
#ifndef GOOGLE_PROTOBUF_MAP_TYPE_HANDLER_H__
#define GOOGLE_PROTOBUF_MAP_TYPE_HANDLER_H__
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
#ifdef SWIG
@@ -322,7 +323,8 @@ inline uint8_t* MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Write(
int field, const MapEntryAccessorType& value, uint8_t* ptr,
io::EpsCopyOutputStream* stream) {
ptr = stream->EnsureSpace(ptr);
- return WireFormatLite::InternalWriteMessage(field, value, ptr, stream);
+ return WireFormatLite::InternalWriteMessage(
+ field, value, value.GetCachedSize(), ptr, stream);
}
#define WRITE_METHOD(FieldType, DeclaredType) \
@@ -578,25 +580,26 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::IsInitialized(
template <typename Type> \
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \
const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \
- to->Set(&internal::GetEmptyStringAlreadyInited(), from, arena); \
+ to->Set(from, arena); \
} \
template <typename Type> \
void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena( \
TypeOnMemory& value) { \
- value.DestroyNoArena(&internal::GetEmptyStringAlreadyInited()); \
+ value.Destroy(); \
} \
template <typename Type> \
constexpr auto \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Constinit() \
->TypeOnMemory { \
- return TypeOnMemory(&internal::fixed_address_empty_string); \
+ return TypeOnMemory(&internal::fixed_address_empty_string, \
+ ConstantInitialized{}); \
} \
template <typename Type> \
inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
Type>::MapEntryAccessorType* \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \
TypeOnMemory* value, Arena* arena) { \
- return value->Mutable(ArenaStringPtr::EmptyDefault{}, arena); \
+ return value->Mutable(arena); \
} \
template <typename Type> \
inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
@@ -684,6 +687,48 @@ PRIMITIVE_HANDLER_FUNCTIONS(SFIXED32)
PRIMITIVE_HANDLER_FUNCTIONS(BOOL)
#undef PRIMITIVE_HANDLER_FUNCTIONS
+// Functions for operating on a map entry using type handlers.
+//
+// Does not contain any representation (this class is not intended to be
+// instantiated).
+template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
+ WireFormatLite::FieldType kValueFieldType>
+struct MapEntryFuncs {
+ typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
+ typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;
+ enum : int {
+ kKeyFieldNumber = 1,
+ kValueFieldNumber = 2
+ };
+
+ static uint8_t* InternalSerialize(int field_number, const Key& key,
+ const Value& value, uint8_t* ptr,
+ io::EpsCopyOutputStream* stream) {
+ ptr = stream->EnsureSpace(ptr);
+ ptr = WireFormatLite::WriteTagToArray(
+ field_number, WireFormatLite::WIRETYPE_LENGTH_DELIMITED, ptr);
+ ptr = io::CodedOutputStream::WriteVarint32ToArray(GetCachedSize(key, value),
+ ptr);
+
+ ptr = KeyTypeHandler::Write(kKeyFieldNumber, key, ptr, stream);
+ return ValueTypeHandler::Write(kValueFieldNumber, value, ptr, stream);
+ }
+
+ static size_t ByteSizeLong(const Key& key, const Value& value) {
+ // Tags for key and value will both be one byte (field numbers 1 and 2).
+ size_t inner_length =
+ 2 + KeyTypeHandler::ByteSize(key) + ValueTypeHandler::ByteSize(value);
+ return inner_length + io::CodedOutputStream::VarintSize32(
+ static_cast<arc_ui32>(inner_length));
+ }
+
+ static int GetCachedSize(const Key& key, const Value& value) {
+ // Tags for key and value will both be one byte (field numbers 1 and 2).
+ return 2 + KeyTypeHandler::GetCachedSize(key) +
+ ValueTypeHandler::GetCachedSize(value);
+ }
+};
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/message.cc b/contrib/libs/protobuf/src/google/protobuf/message.cc
index e049807c23..a2debdf648 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/message.cc
@@ -41,25 +41,26 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/parse_context.h>
-#include <google/protobuf/reflection_internal.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/map_field_inl.h>
+#include <google/protobuf/parse_context.h>
+#include <google/protobuf/reflection_internal.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/stubs/hash.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/message.h b/contrib/libs/protobuf/src/google/protobuf/message.h
index a94688c248..c66d94dd1a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message.h
+++ b/contrib/libs/protobuf/src/google/protobuf/message.h
@@ -110,6 +110,7 @@
#ifndef GOOGLE_PROTOBUF_MESSAGE_H__
#define GOOGLE_PROTOBUF_MESSAGE_H__
+
#include <iosfwd>
#include <string>
#include <type_traits>
@@ -118,18 +119,17 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/json_util.h>
+#include <google/protobuf/messagext.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/map.h> // TODO(b/211442718): cleanup
#include <google/protobuf/message_lite.h>
-#include <google/protobuf/port.h>
-
-#include <google/protobuf/json_util.h>
-#include <google/protobuf/messagext.h>
-#define GOOGLE_PROTOBUF_HAS_ONEOF
-#define GOOGLE_PROTOBUF_HAS_ARENAS
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -147,7 +147,6 @@ class MessageFactory;
// Defined in other files.
class AssignDescriptorsHelper;
class DynamicMessageFactory;
-class DynamicMessageReflectionHelper;
class GeneratedMessageReflectionTestHelper;
class MapKey;
class MapValueConstRef;
@@ -1063,7 +1062,6 @@ class PROTOBUF_EXPORT Reflection final {
friend class ::PROTOBUF_NAMESPACE_ID::MessageLayoutInspector;
friend class ::PROTOBUF_NAMESPACE_ID::AssignDescriptorsHelper;
friend class DynamicMessageFactory;
- friend class DynamicMessageReflectionHelper;
friend class GeneratedMessageReflectionTestHelper;
friend class python::MapReflectionFriend;
friend class python::MessageReflectionFriend;
@@ -1167,7 +1165,7 @@ class PROTOBUF_EXPORT Reflection final {
const internal::ExtensionSet& GetExtensionSet(const Message& message) const;
internal::ExtensionSet* MutableExtensionSet(Message* message) const;
- inline const internal::InternalMetadata& GetInternalMetadata(
+ const internal::InternalMetadata& GetInternalMetadata(
const Message& message) const;
internal::InternalMetadata* MutableInternalMetadata(Message* message) const;
@@ -1186,6 +1184,8 @@ class PROTOBUF_EXPORT Reflection final {
inline arc_ui32* MutableInlinedStringDonatedArray(Message* message) const;
inline bool IsInlinedStringDonated(const Message& message,
const FieldDescriptor* field) const;
+ inline void SwapInlinedStringDonated(Message* lhs, Message* rhs,
+ const FieldDescriptor* field) const;
// Shallow-swap fields listed in fields vector of two messages. It is the
// caller's responsibility to make sure shallow swap is safe.
@@ -1398,11 +1398,11 @@ T* DynamicCastToGenerated(Message* from) {
// Call this function to ensure that this message's reflection is linked into
// the binary:
//
-// google::protobuf::LinkMessageReflection<FooMessage>();
+// google::protobuf::LinkMessageReflection<pkg::FooMessage>();
//
// This will ensure that the following lookup will succeed:
//
-// DescriptorPool::generated_pool()->FindMessageTypeByName("FooMessage");
+// DescriptorPool::generated_pool()->FindMessageTypeByName("pkg.FooMessage");
//
// As a side-effect, it will also guarantee that anything else from the same
// .proto file will also be available for lookup in the generated pool.
diff --git a/contrib/libs/protobuf/src/google/protobuf/message_lite.cc b/contrib/libs/protobuf/src/google/protobuf/message_lite.cc
index f644dd834d..9f6f129c03 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/message_lite.cc
@@ -41,20 +41,19 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/arena.h>
-#include <google/protobuf/generated_message_table_driven.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/stubs/mutex.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -234,7 +233,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input,
if (PROTOBUF_PREDICT_FALSE(!ptr)) return false;
ctx.BackUp(ptr);
if (!ctx.EndedAtEndOfStream()) {
- GOOGLE_DCHECK(ctx.LastTag() != 1); // We can't end on a pushed limit.
+ GOOGLE_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
if (ctx.IsExceedingLimit(ptr)) return false;
input->SetLastTag(ctx.LastTag());
} else {
@@ -537,9 +536,8 @@ TProtoStringType NProtoBuf::MessageLite::SerializeAsStringOrThrow() const {
namespace internal {
-template <>
-MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
- const MessageLite* prototype, Arena* arena) {
+MessageLite* NewFromPrototypeHelper(const MessageLite* prototype,
+ Arena* arena) {
return prototype->New(arena);
}
template <>
@@ -553,6 +551,19 @@ void GenericTypeHandler<TProtoStringType>::Merge(const TProtoStringType& from,
*to = from;
}
+// Non-inline implementations of InternalMetadata routines
+#if defined(NDEBUG) || defined(_MSC_VER)
+// for opt and MSVC builds, the destructor is defined in the header.
+#else
+// This is moved out of the header because the GOOGLE_DCHECK produces a lot of code.
+InternalMetadata::~InternalMetadata() {
+ if (HasMessageOwnedArenaTag()) {
+ GOOGLE_DCHECK(!HasUnknownFieldsTag());
+ delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
+ }
+}
+#endif
+
// Non-inline variants of TProtoStringType specializations for
// various InternalMetadata routines.
template <>
diff --git a/contrib/libs/protobuf/src/google/protobuf/message_lite.h b/contrib/libs/protobuf/src/google/protobuf/message_lite.h
index eb5b156303..97089a25dc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/message_lite.h
@@ -52,12 +52,12 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
-#include <google/protobuf/explicitly_constructed.h>
-#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/port.h>
#include <google/protobuf/stubs/strutil.h>
-
+#include <google/protobuf/explicitly_constructed.h>
+#include <google/protobuf/metadata_lite.h>
+#include <google/protobuf/stubs/hash.h> // TODO(b/211442718): cleanup
// clang-format off
#include <google/protobuf/port_def.inc>
@@ -89,12 +89,6 @@ namespace internal {
class SwapFieldHelper;
-// Tag type used to invoke the constinit constructor overload of some classes.
-// Such constructors are internal implementation details of the library.
-struct ConstantInitialized {
- explicit ConstantInitialized() = default;
-};
-
// See parse_context.h for explanation
class ParseContext;
@@ -136,8 +130,9 @@ inline int ToIntSize(size_t size) {
}
// Default empty string object. Don't use this directly. Instead, call
-// GetEmptyString() to get the reference.
-PROTOBUF_EXPORT extern ExplicitlyConstructed<TProtoStringType>
+// GetEmptyString() to get the reference. This empty string is aligned with a
+// minimum alignment of 8 bytes to match the requirement of ArenaStringPtr.
+PROTOBUF_EXPORT extern ExplicitlyConstructedArenaString
fixed_address_empty_string;
@@ -193,8 +188,8 @@ class PROTOBUF_EXPORT MessageLite {
// if arena is a nullptr.
virtual MessageLite* New(Arena* arena) const = 0;
- // Same as GetOwningArena.
- Arena* GetArena() const { return GetOwningArena(); }
+ // Returns user-owned arena; nullptr if it's message owned.
+ Arena* GetArena() const { return _internal_metadata_.user_arena(); }
// Clear all fields of the message and set them to their default values.
// Clear() avoids freeing memory, assuming that any memory allocated
@@ -428,6 +423,8 @@ class PROTOBUF_EXPORT MessageLite {
return nullptr;
}
+ virtual void OnDemandRegisterArenaDtor(Arena* /*arena*/) {}
+
protected:
template <typename T>
static T* CreateMaybeMessage(Arena* arena) {
@@ -486,9 +483,6 @@ class PROTOBUF_EXPORT MessageLite {
#endif
private:
- // TODO(gerbens) make this a pure abstract function
- virtual const void* InternalGetTable() const { return nullptr; }
-
friend class FastReflectionMessageMutator;
friend class FastReflectionStringSetter;
friend class Message;
diff --git a/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h b/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h
index d180bcda91..fad103588e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h
@@ -36,6 +36,7 @@
#include <google/protobuf/arena.h>
#include <google/protobuf/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -69,11 +70,15 @@ class InternalMetadata {
GOOGLE_DCHECK(!is_message_owned || arena != nullptr);
}
+#if defined(NDEBUG) || defined(_MSC_VER)
~InternalMetadata() {
if (HasMessageOwnedArenaTag()) {
- delete arena();
+ delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
}
}
+#else
+ ~InternalMetadata();
+#endif
template <typename T>
void Delete() {
@@ -83,10 +88,31 @@ class InternalMetadata {
}
}
+ // DeleteReturnArena will delete the unknown fields only if they weren't
+ // allocated on an arena. Then it updates the flags so that if you call
+ // have_unknown_fields(), it will return false. Finally, it returns the
+ // current value of arena(). It is designed to be used as part of a
+ // Message class's destructor call, so that when control eventually gets
+ // to ~InternalMetadata(), we don't need to check for have_unknown_fields()
+ // again.
+ template <typename T>
+ Arena* DeleteReturnArena() {
+ if (have_unknown_fields()) {
+ return DeleteOutOfLineHelper<T>();
+ } else {
+ return PtrValue<Arena>();
+ }
+ }
+
PROTOBUF_NDEBUG_INLINE Arena* owning_arena() const {
return HasMessageOwnedArenaTag() ? nullptr : arena();
}
+ PROTOBUF_NDEBUG_INLINE Arena* user_arena() const {
+ Arena* a = arena();
+ return a && !a->IsMessageOwned() ? a : nullptr;
+ }
+
PROTOBUF_NDEBUG_INLINE Arena* arena() const {
if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
return PtrValue<ContainerBase>()->arena;
@@ -187,9 +213,18 @@ class InternalMetadata {
};
template <typename T>
- PROTOBUF_NOINLINE void DeleteOutOfLineHelper() {
- if (arena() == nullptr) {
+ PROTOBUF_NOINLINE Arena* DeleteOutOfLineHelper() {
+ if (auto* a = arena()) {
+ // Subtle: we want to preserve the message-owned arena flag, while at the
+ // same time replacing the pointer to Container<T> with a pointer to the
+ // arena.
+ intptr_t message_owned_arena_tag = ptr_ & kMessageOwnedArenaTagMask;
+ ptr_ = reinterpret_cast<intptr_t>(a) | message_owned_arena_tag;
+ return a;
+ } else {
delete PtrValue<Container<T>>();
+ ptr_ = 0;
+ return nullptr;
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/parse_context.cc b/contrib/libs/protobuf/src/google/protobuf/parse_context.cc
index a1995b6c1e..4d0779d763 100644
--- a/contrib/libs/protobuf/src/google/protobuf/parse_context.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/parse_context.cc
@@ -30,15 +30,15 @@
#include <google/protobuf/parse_context.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/wire_format_lite.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -50,8 +50,8 @@ namespace {
// Only call if at start of tag.
bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) {
constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes;
- GOOGLE_DCHECK(overrun >= 0);
- GOOGLE_DCHECK(overrun <= kSlopBytes);
+ GOOGLE_DCHECK_GE(overrun, 0);
+ GOOGLE_DCHECK_LE(overrun, kSlopBytes);
auto ptr = begin + overrun;
auto end = begin + kSlopBytes;
while (ptr < end) {
@@ -180,17 +180,17 @@ std::pair<const char*, bool> EpsCopyInputStream::DoneFallback(int overrun,
// if (ptr < limit_end_) return {ptr, false};
GOOGLE_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_));
// At this point we know the following assertion holds.
- GOOGLE_DCHECK(limit_ > 0);
+ GOOGLE_DCHECK_GT(limit_, 0);
GOOGLE_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0
const char* p;
do {
// We are past the end of buffer_end_, in the slop region.
- GOOGLE_DCHECK(overrun >= 0);
+ GOOGLE_DCHECK_GE(overrun, 0);
p = NextBuffer(overrun, depth);
if (p == nullptr) {
// We are at the end of the stream
if (PROTOBUF_PREDICT_FALSE(overrun != 0)) return {nullptr, true};
- GOOGLE_DCHECK(limit_ > 0);
+ GOOGLE_DCHECK_GT(limit_, 0);
limit_end_ = buffer_end_;
// Distinguish ending on a pushed limit or ending on end-of-stream.
SetEndOfStream();
@@ -388,12 +388,13 @@ const char* StringParser(const char* begin, const char* end, void* object,
}
// Defined in wire_format_lite.cc
-void PrintUTF8ErrorLog(const char* field_name, const char* operation_str,
+void PrintUTF8ErrorLog(StringPiece message_name,
+ StringPiece field_name, const char* operation_str,
bool emit_stacktrace);
bool VerifyUTF8(StringPiece str, const char* field_name) {
if (!IsStructurallyValidUTF8(str)) {
- PrintUTF8ErrorLog(field_name, "parsing", false);
+ PrintUTF8ErrorLog("", field_name, "parsing", false);
return false;
}
return true;
diff --git a/contrib/libs/protobuf/src/google/protobuf/parse_context.h b/contrib/libs/protobuf/src/google/protobuf/parse_context.h
index 32c72f9c64..3e1bab30bd 100644
--- a/contrib/libs/protobuf/src/google/protobuf/parse_context.h
+++ b/contrib/libs/protobuf/src/google/protobuf/parse_context.h
@@ -38,15 +38,16 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/port.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/implicit_weak_message.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/port.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/strutil.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -197,6 +198,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
return ptr > limit_end_ &&
(next_chunk_ == nullptr || ptr - buffer_end_ > limit_);
}
+ bool AliasingEnabled() const { return aliasing_ != kNoAliasing; }
int BytesUntilLimit(const char* ptr) const {
return limit_ + static_cast<int>(buffer_end_ - ptr);
}
@@ -372,6 +374,9 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
friend class ImplicitWeakMessage;
};
+using LazyEagerVerifyFnType = const char* (*)(const char* ptr,
+ ParseContext* ctx);
+
// ParseContext holds all data that is global to the entire parse. Most
// importantly it contains the input stream, but also recursion depth and also
// stores the end group tag, in case a parser ended on a endgroup, to verify
@@ -401,6 +406,18 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
const char* ParseMessage(MessageLite* msg, const char* ptr);
+ // Spawns a child parsing context that inherits key properties. New context
+ // inherits the following:
+ // --depth_, data_, check_required_fields_, lazy_parse_mode_
+ // The spanwed context always disables aliasing (different input).
+ template <typename... T>
+ ParseContext Spawn(const char** start, T&&... args) {
+ ParseContext spawned(depth_, false, start, std::forward<T>(args)...);
+ // Transfer key context states.
+ spawned.data_ = data_;
+ return spawned;
+ }
+
// This overload supports those few cases where ParseMessage is called
// on a class that is not actually a proto message.
// TODO(jorg): Eliminate this use case.
@@ -789,7 +806,7 @@ inline bool VerifyUTF8(const TProtoStringType* s, const char* field_name) {
}
// All the string parsers with or without UTF checking and for all CTypes.
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* InlineGreedyStringParser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* InlineGreedyStringParser(
TProtoStringType* s, const char* ptr, ParseContext* ctx);
@@ -861,19 +878,19 @@ PROTOBUF_NODISCARD const char* WireFormatParser(T& field_parser,
// corresponding field
// These are packed varints
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedInt32Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedInt32Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedUInt32Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedUInt32Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedInt64Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedInt64Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedUInt64Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedUInt64Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSInt32Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSInt32Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSInt64Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSInt64Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedEnumParser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedEnumParser(
void* object, const char* ptr, ParseContext* ctx);
template <typename T>
@@ -907,28 +924,28 @@ PROTOBUF_NODISCARD const char* PackedEnumParserArg(
});
}
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedBoolParser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedBoolParser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFixed32Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFixed32Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSFixed32Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSFixed32Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFixed64Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFixed64Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSFixed64Parser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSFixed64Parser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFloatParser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFloatParser(
void* object, const char* ptr, ParseContext* ctx);
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedDoubleParser(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedDoubleParser(
void* object, const char* ptr, ParseContext* ctx);
// This is the only recursive parser.
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* UnknownGroupLiteParse(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownGroupLiteParse(
TProtoStringType* unknown, const char* ptr, ParseContext* ctx);
// This is a helper to for the UnknownGroupLiteParse but is actually also
// useful in the generated code. It uses overload on TProtoStringType* vs
// UnknownFieldSet* to make the generated code isomorphic between full and lite.
-PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* UnknownFieldParse(
+PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownFieldParse(
arc_ui32 tag, TProtoStringType* unknown, const char* ptr, ParseContext* ctx);
} // namespace internal
diff --git a/contrib/libs/protobuf/src/google/protobuf/port.h b/contrib/libs/protobuf/src/google/protobuf/port.h
index 4c09eb1dbe..09e82c46ec 100644
--- a/contrib/libs/protobuf/src/google/protobuf/port.h
+++ b/contrib/libs/protobuf/src/google/protobuf/port.h
@@ -36,5 +36,49 @@
#ifndef GOOGLE_PROTOBUF_PORT_H__
#define GOOGLE_PROTOBUF_PORT_H__
+#include <cstddef>
+#include <new>
+
+
+namespace google {
+namespace protobuf {
+namespace internal {
+inline void SizedDelete(void* p, size_t size) {
+#if defined(__cpp_sized_deallocation)
+ ::operator delete(p, size);
+#else
+ // Avoid -Wunused-parameter
+ (void)size;
+ ::operator delete(p);
+#endif
+}
+inline void SizedArrayDelete(void* p, size_t size) {
+#if defined(__cpp_sized_deallocation)
+ ::operator delete[](p, size);
+#else
+ // Avoid -Wunused-parameter
+ (void)size;
+ ::operator delete[](p);
+#endif
+}
+
+// Tag type used to invoke the constinit constructor overload of classes
+// such as ArenaStringPtr and MapFieldBase. Such constructors are internal
+// implementation details of the library.
+struct ConstantInitialized {
+ explicit ConstantInitialized() = default;
+};
+
+// Tag type used to invoke the arena constructor overload of classes such
+// as ExtensionSet and MapFieldLite in aggregate initialization. These
+// classes typically don't have move/copy constructors, which rules out
+// explicit initialization in pre-C++17.
+struct ArenaInitialized {
+ explicit ArenaInitialized() = default;
+};
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
#endif // GOOGLE_PROTOBUF_PORT_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/port_def.inc b/contrib/libs/protobuf/src/google/protobuf/port_def.inc
index 5706dc22d5..a8f868114c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/port_def.inc
+++ b/contrib/libs/protobuf/src/google/protobuf/port_def.inc
@@ -148,22 +148,26 @@
// Future versions of protobuf will include breaking changes to some APIs.
// This macro can be set to enable these API changes ahead of time, so that
// user code can be updated before upgrading versions of protobuf.
+// PROTOBUF_FUTURE_FINAL is used on classes that are historically not marked as
+// final, but that may be marked final in future (breaking) releases.
// #define PROTOBUF_FUTURE_BREAKING_CHANGES 1
+// #define PROTOBUF_FUTURE_FINAL final
+#define PROTOBUF_FUTURE_FINAL
#ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined
#endif
-#define PROTOBUF_VERSION 3019000
+#define PROTOBUF_VERSION 3020002
#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
#endif
-#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3019000
+#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3020000
#ifdef PROTOBUF_MIN_PROTOC_VERSION
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined
#endif
-#define PROTOBUF_MIN_PROTOC_VERSION 3019000
+#define PROTOBUF_MIN_PROTOC_VERSION 3020000
#ifdef PROTOBUF_VERSION_SUFFIX
#error PROTOBUF_VERSION_SUFFIX was previously defined
@@ -229,11 +233,14 @@
#ifdef PROTOBUF_TAILCALL
#error PROTOBUF_TAILCALL was previously defined
#endif
-#if __has_cpp_attribute(clang::musttail) && \
- !defined(__arm__) && !defined(_ARCH_PPC) && !defined(__wasm__)
+#if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
+ !defined(_ARCH_PPC) && !defined(__wasm__) && \
+ !(defined(_MSC_VER) && defined(_M_IX86))
# ifndef PROTO2_OPENSOURCE
// Compilation fails on ARM32: b/195943306
// Compilation fails on powerpc64le: b/187985113
+// Compilation fails on X86 Windows:
+// https://github.com/llvm/llvm-project/issues/53271
# endif
#define PROTOBUF_MUSTTAIL [[clang::musttail]]
#define PROTOBUF_TAILCALL true
@@ -343,17 +350,25 @@
// The minimum library version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3019000
+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3020000
#ifdef PROTOBUF_RTTI
#error PROTOBUF_RTTI was previously defined
#endif
#if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
+// A user-provided definition GOOGLE_PROTOBUF_NO_RTTI=1 disables RTTI.
#define PROTOBUF_RTTI 0
+#elif defined(__cpp_rtti)
+// https://en.cppreference.com/w/cpp/feature_test
+#define PROTOBUF_RTTI 1
#elif __has_feature(cxx_rtti)
+// https://clang.llvm.org/docs/LanguageExtensions.html#c-rtti
#define PROTOBUF_RTTI 1
-#elif defined(__cxx_rtti)
-// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98
+#elif defined(__GXX_RTTI)
+// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
+#define PROTOBUF_RTTI 1
+#elif defined(_CPPRTTI)
+// https://docs.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
#define PROTOBUF_RTTI 1
#else
#define PROTOBUF_RTTI 0
@@ -426,7 +441,7 @@
# else
# define PROTOC_EXPORT __declspec(dllimport)
# endif // defined(LIBPROTOC_EXPORTS)
-#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS)
+#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOC_EXPORTS)
# define PROTOC_EXPORT __attribute__((visibility("default")))
#else
# define PROTOC_EXPORT
@@ -446,7 +461,7 @@
#ifdef PROTOBUF_NODISCARD
#error PROTOBUF_NODISCARD was previously defined
#endif
-#if __has_cpp_attribute(nodiscard)
+#if __has_cpp_attribute(nodiscard) && PROTOBUF_CPLUSPLUS_MIN(201703L)
#define PROTOBUF_NODISCARD [[nodiscard]]
#elif __has_attribute(warn_unused_result) || PROTOBUF_GNUC_MIN(4, 8)
#define PROTOBUF_NODISCARD __attribute__((warn_unused_result))
@@ -454,6 +469,13 @@
#define PROTOBUF_NODISCARD
#endif
+// Enable all stable experiments if this flag is set. This allows us to group
+// all of these experiments under a single build flag, which can be enabled in
+// the protobuf.stable-experiments TAP project.
+#ifdef PROTOBUF_ENABLE_STABLE_EXPERIMENTS
+#define PROTOBUF_FORCE_MESSAGE_OWNED_ARENA
+#endif // !PROTOBUF_ENABLE_STABLE_EXPERIMENTS
+
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
#error PROTOBUF_FORCE_COPY_IN_RELEASE was previously defined
#endif
@@ -561,16 +583,24 @@
#ifdef PROTOBUF_CONSTINIT
#error PROTOBUF_CONSTINIT was previously defined
#endif
-#if defined(__cpp_constinit) && !PROTOBUF_GNUC_MIN(3, 0) && !defined(_MSC_VER)
-// Our use of constinit does not yet work with GCC:
-// https://github.com/protocolbuffers/protobuf/issues/8310
-// Does not work yet with Visual Studio 2019 Update 16.10
+#if defined(__cpp_constinit)
#define PROTOBUF_CONSTINIT constinit
-#elif !defined(_MSC_VER) && \
- __has_cpp_attribute(clang::require_constant_initialization)
+#define PROTOBUF_CONSTEXPR constexpr
+// Some older Clang versions incorrectly raise an error about
+// constant-initializing weak default instance pointers. Versions 12.0 and
+// higher seem to work, except that XCode 12.5.1 shows the error even though it
+// uses Clang 12.0.5.
+#elif __has_cpp_attribute(clang::require_constant_initialization) && \
+ ((defined(__APPLE__) && __clang_major__ >= 13) || \
+ (!defined(__APPLE__) && __clang_major__ >= 12))
#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
+#define PROTOBUF_CONSTEXPR constexpr
+#elif PROTOBUF_GNUC_MIN(12, 0)
+#define PROTOBUF_CONSTINIT __constinit
+#define PROTOBUF_CONSTEXPR constexpr
#else
#define PROTOBUF_CONSTINIT
+#define PROTOBUF_CONSTEXPR inline
#endif
// Some globals with an empty non-trivial destructor are annotated with
@@ -585,26 +615,49 @@
#define PROTOBUF_ATTRIBUTE_NO_DESTROY
#endif
+// Force clang to always emit complete debug info for a type.
+// Clang uses constructor homing to determine when to emit debug info for a
+// type. If the constructor of a type is never used, which can happen in some
+// cases where member variables are constructed in place for optimization
+// purposes (see b/208803175 for an example), the type will have incomplete
+// debug info unless this attribute is used.
+#ifdef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
+#error PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG was previously defined
+#endif
+#if __has_cpp_attribute(clang::standalone_debug)
+#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG [[clang::standalone_debug]]
+#else
+#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
+#endif
+
// Protobuf extensions and reflection require registration of the protos linked
// in the binary. Not until everything is registered does the runtime have a
// complete view on all protos. When code is using reflection or extensions
// in between registration calls this can lead to surprising behavior. By
// having the registration run first we mitigate this scenario.
-// Highest priority is 101. We use 102 to allow code that really wants to
-// higher priority to still beat us.
-#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY
-#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY was previously defined
-#endif
-#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && !((defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)))
-#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102))))
+// Highest priority is 101. We use 102 for registration, to allow code that
+// really wants to higher priority to still beat us. Some initialization happens
+// at higher priority, though, since it is needed before registration.
+#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
+#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 was previously defined
+#endif
+#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
+#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 was previously defined
+#endif
+#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && \
+ !((defined(sun) || defined(__sun)) && \
+ (defined(__SVR4) || defined(__svr4__)))
+#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 __attribute__((init_priority((101))))
+#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 __attribute__((init_priority((102))))
#else
-#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY
+#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
+#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
#endif
#ifdef PROTOBUF_PRAGMA_INIT_SEG
#error PROTOBUF_PRAGMA_INIT_SEG was previously defined
#endif
-#if _MSC_VER
+#ifdef _MSC_VER
#define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib))
#else
#define PROTOBUF_PRAGMA_INIT_SEG
@@ -666,19 +719,6 @@
#endif
#if defined(PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER)
#define PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED 1
-// Selectively use static member functions instead of templates:
-#ifndef PROTOBUF_TC_STATIC_PARSE_SINGULAR1
-# define PROTOBUF_TC_STATIC_PARSE_SINGULAR1 1
-#endif
-#ifndef PROTOBUF_TC_STATIC_PARSE_SINGULAR2
-# define PROTOBUF_TC_STATIC_PARSE_SINGULAR2 0
-#endif
-#ifndef PROTOBUF_TC_STATIC_PARSE_REPEATED1
-# define PROTOBUF_TC_STATIC_PARSE_REPEATED1 0
-#endif
-#ifndef PROTOBUF_TC_STATIC_PARSE_REPEATED2
-# define PROTOBUF_TC_STATIC_PARSE_REPEATED2 0
-#endif
#endif
#define PROTOBUF_TC_PARAM_DECL \
@@ -699,6 +739,8 @@
#define PROTOBUF_UNUSED
#endif
+// ThreadSafeArenaz is turned off completely in opensource builds.
+
// Windows declares several inconvenient macro names. We #undef them and then
// restore them in port_undef.inc.
#ifdef _MSC_VER
@@ -746,12 +788,25 @@
#undef SERVICE_DISABLED
#pragma push_macro("SEVERITY_ERROR")
#undef SEVERITY_ERROR
+#pragma push_macro("STATUS_PENDING")
+#undef STATUS_PENDING
#pragma push_macro("STRICT")
#undef STRICT
#pragma push_macro("timezone")
#undef timezone
#endif // _MSC_VER
+#ifdef __APPLE__
+// Inconvenient macro names from usr/include/math.h in some macOS SDKs.
+#pragma push_macro("DOMAIN")
+#undef DOMAIN
+// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs.
+#pragma push_macro("TRUE")
+#undef TRUE
+#pragma push_macro("FALSE")
+#undef FALSE
+#endif // __APPLE__
+
#if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
// Don't let Objective-C Macros interfere with proto identifiers with the same
// name.
@@ -764,16 +819,18 @@
// 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"
+#pragma clang diagnostic ignored "-Wunused-parameter"
#elif PROTOBUF_GNUC_MIN(3, 0)
// 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"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
// Silence some MSVC warnings in all our code.
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(push)
// For non-trivial unions
#pragma warning(disable : 4582)
diff --git a/contrib/libs/protobuf/src/google/protobuf/port_undef.inc b/contrib/libs/protobuf/src/google/protobuf/port_undef.inc
index c410730ef1..156559e531 100644
--- a/contrib/libs/protobuf/src/google/protobuf/port_undef.inc
+++ b/contrib/libs/protobuf/src/google/protobuf/port_undef.inc
@@ -76,22 +76,22 @@
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE
#undef PROTOBUF_ALIGNAS
#undef PROTOBUF_FINAL
+#undef PROTOBUF_FUTURE_FINAL
#undef PROTOBUF_THREAD_LOCAL
#undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
#undef PROTOBUF_CONSTINIT
+#undef PROTOBUF_CONSTEXPR
#undef PROTOBUF_ATTRIBUTE_WEAK
#undef PROTOBUF_HAVE_ATTRIBUTE_WEAK
#undef PROTOBUF_ATTRIBUTE_NO_DESTROY
-#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY
+#undef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
+#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
+#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
#undef PROTOBUF_PRAGMA_INIT_SEG
#undef PROTOBUF_ASAN
#undef PROTOBUF_MSAN
#undef PROTOBUF_TSAN
#undef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED
-#undef PROTOBUF_TC_STATIC_PARSE_SINGULAR1
-#undef PROTOBUF_TC_STATIC_PARSE_SINGULAR2
-#undef PROTOBUF_TC_STATIC_PARSE_REPEATED1
-#undef PROTOBUF_TC_STATIC_PARSE_REPEATED2
#undef PROTOBUF_TC_PARAM_DECL
#undef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED
#undef PROTOBUF_LOCKS_EXCLUDED
@@ -127,9 +127,16 @@
#pragma pop_macro("SERVICE_DISABLED")
#pragma pop_macro("SEVERITY_ERROR")
#pragma pop_macro("STRICT")
+#pragma pop_macro("STATUS_PENDING")
#pragma pop_macro("timezone")
#endif
+#ifdef __APPLE__
+#pragma pop_macro("DOMAIN")
+#pragma pop_macro("TRUE")
+#pragma pop_macro("FALSE")
+#endif // __APPLE__
+
#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
#pragma pop_macro("DEBUG")
#endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
@@ -141,6 +148,6 @@
#endif
// Pop the warning(push) from port_def.inc
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(pop)
#endif
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection.h b/contrib/libs/protobuf/src/google/protobuf/reflection.h
index 859724aab2..fa141b8a66 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection.h
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection.h
@@ -33,6 +33,7 @@
#ifndef GOOGLE_PROTOBUF_REFLECTION_H__
#define GOOGLE_PROTOBUF_REFLECTION_H__
+
#include <memory>
#include <google/protobuf/message.h>
@@ -42,6 +43,7 @@
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc
index a369ddb001..92287d7470 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc
@@ -38,12 +38,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/map_field_inl.h>
#include <google/protobuf/unknown_field_set.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -182,7 +183,9 @@ void ReflectionOps::Clear(Message* message) {
reflection->ClearField(message, field);
}
- reflection->MutableUnknownFields(message)->Clear();
+ if (reflection->GetInternalMetadata(*message).have_unknown_fields()) {
+ reflection->MutableUnknownFields(message)->Clear();
+ }
}
bool ReflectionOps::IsInitialized(const Message& message, bool check_fields,
@@ -420,16 +423,16 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
void GenericSwap(Message* lhs, Message* rhs) {
#ifndef PROTOBUF_FORCE_COPY_IN_SWAP
- GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) !=
- Arena::InternalHelper<Message>::GetOwningArena(rhs));
- GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) != nullptr ||
- Arena::InternalHelper<Message>::GetOwningArena(rhs) != nullptr);
+ GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) !=
+ Arena::InternalGetOwningArena(rhs));
+ GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr ||
+ Arena::InternalGetOwningArena(rhs) != nullptr);
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
// At least one of these must have an arena, so make `rhs` point to it.
- Arena* arena = Arena::InternalHelper<Message>::GetOwningArena(rhs);
+ Arena* arena = Arena::InternalGetOwningArena(rhs);
if (arena == nullptr) {
std::swap(lhs, rhs);
- arena = Arena::InternalHelper<Message>::GetOwningArena(rhs);
+ arena = Arena::InternalGetOwningArena(rhs);
}
// Improve efficiency by placing the temporary on an arena so that messages
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
index 50b68aeef2..32f95cffb0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
@@ -45,6 +45,7 @@
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc b/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc
index 016cfbc65e..9e467ab148 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc
@@ -39,6 +39,7 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -54,6 +55,16 @@ template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<float>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<double>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedPtrField<TProtoStringType>;
+namespace internal {
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<bool>;
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<arc_i32>;
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<arc_ui32>;
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<arc_i64>;
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<arc_ui64>;
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<float>;
+template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<double>;
+} // namespace internal
+
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/repeated_field.h b/contrib/libs/protobuf/src/google/protobuf/repeated_field.h
index 2b7fe6135d..27f1df72f9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_field.h
@@ -39,32 +39,25 @@
// particularly different from STL vector as it manages ownership of the
// pointers that it contains.
//
-// Typically, clients should not need to access RepeatedField objects directly,
-// but should instead use the accessor functions generated automatically by the
-// protocol compiler.
-//
// This header covers RepeatedField.
#ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__
#define GOOGLE_PROTOBUF_REPEATED_FIELD_H__
-#include <utility>
-#ifdef _MSC_VER
-// This is required for min/max on VS2013 only.
-#include <algorithm>
-#endif
+#include <algorithm>
#include <iterator>
#include <limits>
#include <string>
#include <type_traits>
+#include <utility>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/repeated_ptr_field.h>
#include <google/protobuf/arena.h>
-#include <google/protobuf/message_lite.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/message_lite.h>
+#include <google/protobuf/repeated_ptr_field.h>
// Must be included last.
@@ -81,9 +74,18 @@ class Message;
namespace internal {
-// kRepeatedFieldLowerClampLimit is the smallest size that will be allocated
-// when growing a repeated field.
-constexpr int kRepeatedFieldLowerClampLimit = 4;
+template <typename T, int kRepHeaderSize>
+constexpr int RepeatedFieldLowerClampLimit() {
+ // The header is padded to be at least `sizeof(T)` when it would be smaller
+ // otherwise.
+ static_assert(sizeof(T) <= kRepHeaderSize, "");
+ // We want to pad the minimum size to be a power of two bytes, including the
+ // header.
+ // The first allocation is kRepHeaderSize bytes worth of elements for a total
+ // of 2*kRepHeaderSize bytes.
+ // For an 8-byte header, we allocate 8 bool, 2 ints, or 1 int64.
+ return kRepHeaderSize / sizeof(T);
+}
// kRepeatedFieldUpperClampLimit is the lowest signed integer value that
// overflows when multiplied by 2 (which is undefined behavior). Sizes above
@@ -120,7 +122,6 @@ inline void SwapBlock(char* p, char* q) {
// Swaps two blocks of memory of size kSize:
// template <int kSize> void memswap(char* p, char* q);
-
template <int kSize>
inline typename std::enable_if<(kSize == 0), void>::type memswap(char*, char*) {
}
@@ -148,6 +149,9 @@ PROTO_MEMSWAP_DEF_SIZE(arc_ui64, (1u << 31))
#undef PROTO_MEMSWAP_DEF_SIZE
+template <typename Element>
+class RepeatedIterator;
+
} // namespace internal
// RepeatedField is used to represent repeated fields of a primitive type (in
@@ -192,20 +196,20 @@ class RepeatedField {
void Set(int index, const Element& value);
void Add(const Element& value);
- // Appends a new element and return a pointer to it.
+ // Appends a new element and returns a pointer to it.
// The new element is uninitialized if |Element| is a POD type.
Element* Add();
- // Append elements in the range [begin, end) after reserving
+ // Appends elements in the range [begin, end) after reserving
// the appropriate number of elements.
template <typename Iter>
void Add(Iter begin, Iter end);
- // Remove the last element in the array.
+ // Removes the last element in the array.
void RemoveLast();
- // Extract elements with indices in "[start .. start+num-1]".
- // Copy them into "elements[0 .. num-1]" if "elements" is not nullptr.
- // Caution: implementation also moves elements with indices [start+num ..].
+ // Extracts elements with indices in "[start .. start+num-1]".
+ // Copies them into "elements[0 .. num-1]" if "elements" is not nullptr.
+ // Caution: also moves elements with indices [start+num ..].
// Calling this routine inside a loop can cause quadratic behavior.
void ExtractSubrange(int start, int num, Element* elements);
@@ -217,11 +221,11 @@ class RepeatedField {
template <typename Iter>
PROTOBUF_ATTRIBUTE_REINITIALIZES void Assign(Iter begin, Iter end);
- // Reserve space to expand the field to at least the given size. If the
+ // Reserves space to expand the field to at least the given size. If the
// array is grown, it will always be at least doubled in size.
void Reserve(int new_size);
- // Resize the RepeatedField to a new, smaller size. This is O(1).
+ // Resizes the RepeatedField to a new, smaller size. This is O(1).
void Truncate(int new_size);
void AddAlreadyReserved(const Element& value);
@@ -242,22 +246,22 @@ class RepeatedField {
Element* mutable_data();
const Element* data() const;
- // Swap entire contents with "other". If they are separate arenas then, copies
- // data between each other.
+ // Swaps entire contents with "other". If they are separate arenas then,
+ // copies data between each other.
void Swap(RepeatedField* other);
- // Swap entire contents with "other". Should be called only if the caller can
+ // Swaps entire contents with "other". Should be called only if the caller can
// guarantee that both repeated fields are on the same arena or are on the
// heap. Swapping between different arenas is disallowed and caught by a
// GOOGLE_DCHECK (see API docs for details).
void UnsafeArenaSwap(RepeatedField* other);
- // Swap two elements.
+ // Swaps two elements.
void SwapElements(int index1, int index2);
// STL-like iterator support
- typedef Element* iterator;
- typedef const Element* const_iterator;
+ typedef internal::RepeatedIterator<Element> iterator;
+ typedef internal::RepeatedIterator<const Element> const_iterator;
typedef Element value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -308,10 +312,9 @@ class RepeatedField {
// Invalidates all iterators at or after the removed range, including end().
iterator erase(const_iterator first, const_iterator last);
- // Get the Arena on which this RepeatedField stores its elements.
+ // Gets the Arena on which this RepeatedField stores its elements.
inline Arena* GetArena() const {
- return (total_size_ == 0) ? static_cast<Arena*>(arena_or_elements_)
- : rep()->arena;
+ return GetOwningArena();
}
// For internal use only.
@@ -320,6 +323,14 @@ class RepeatedField {
inline void InternalSwap(RepeatedField* other);
private:
+ template <typename T> friend class Arena::InternalHelper;
+
+ // Gets the Arena on which this RepeatedField stores its elements.
+ inline Arena* GetOwningArena() const {
+ return (total_size_ == 0) ? static_cast<Arena*>(arena_or_elements_)
+ : rep()->arena;
+ }
+
static constexpr int kInitialSize = 0;
// A note on the representation here (see also comment below for
// RepeatedPtrFieldBase's struct Rep):
@@ -333,21 +344,24 @@ class RepeatedField {
// RepeatedField class to avoid costly cache misses due to the indirection.
int current_size_;
int total_size_;
+ // Pad the Rep after arena allow for power-of-two byte sizes when
+ // sizeof(Element) > sizeof(Arena*). eg for 16-byte objects.
+ static constexpr size_t kRepHeaderSize =
+ sizeof(Arena*) < sizeof(Element) ? sizeof(Element) : sizeof(Arena*);
struct Rep {
Arena* arena;
- // Here we declare a huge array as a way of approximating C's "flexible
- // array member" feature without relying on undefined behavior.
- Element elements[(std::numeric_limits<int>::max() - 2 * sizeof(Arena*)) /
- sizeof(Element)];
+ Element* elements() {
+ return reinterpret_cast<Element*>(reinterpret_cast<char*>(this) +
+ kRepHeaderSize);
+ }
};
- static constexpr size_t kRepHeaderSize = offsetof(Rep, elements);
// If total_size_ == 0 this points to an Arena otherwise it points to the
// elements member of a Rep struct. Using this invariant allows the storage of
// the arena pointer without an extra allocation in the constructor.
void* arena_or_elements_;
- // Return pointer to elements array.
+ // Returns a pointer to elements array.
// pre-condition: the array must have been allocated.
Element* elements() const {
GOOGLE_DCHECK_GT(total_size_, 0);
@@ -355,48 +369,48 @@ class RepeatedField {
return unsafe_elements();
}
- // Return pointer to elements array if it exists otherwise either null or
- // a invalid pointer is returned. This only happens for empty repeated fields,
- // where you can't dereference this pointer anyway (it's empty).
+ // Returns a pointer to elements array if it exists; otherwise either null or
+ // an invalid pointer is returned. This only happens for empty repeated
+ // fields, where you can't dereference this pointer anyway (it's empty).
Element* unsafe_elements() const {
return static_cast<Element*>(arena_or_elements_);
}
- // Return pointer to the Rep struct.
+ // Returns a pointer to the Rep struct.
// pre-condition: the Rep must have been allocated, ie elements() is safe.
Rep* rep() const {
- char* addr = reinterpret_cast<char*>(elements()) - offsetof(Rep, elements);
- return reinterpret_cast<Rep*>(addr);
+ return reinterpret_cast<Rep*>(reinterpret_cast<char*>(elements()) -
+ kRepHeaderSize);
}
friend class Arena;
typedef void InternalArenaConstructable_;
- // Move the contents of |from| into |to|, possibly clobbering |from| in the
+ // Moves the contents of |from| into |to|, possibly clobbering |from| in the
// process. For primitive types this is just a memcpy(), but it could be
// specialized for non-primitive types to, say, swap each element instead.
void MoveArray(Element* to, Element* from, int size);
- // Copy the elements of |from| into |to|.
+ // Copies the elements of |from| into |to|.
void CopyArray(Element* to, const Element* from, int size);
// Internal helper to delete all elements and deallocate the storage.
- void InternalDeallocate(Rep* rep, int size) {
+ void InternalDeallocate(Rep* rep, int size, bool in_destructor) {
if (rep != nullptr) {
- Element* e = &rep->elements[0];
+ Element* e = &rep->elements()[0];
if (!std::is_trivial<Element>::value) {
- Element* limit = &rep->elements[size];
+ Element* limit = &rep->elements()[size];
for (; e < limit; e++) {
e->~Element();
}
}
+ const size_t bytes = size * sizeof(*e) + kRepHeaderSize;
if (rep->arena == nullptr) {
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
- const size_t bytes = size * sizeof(*e) + kRepHeaderSize;
- ::operator delete(static_cast<void*>(rep), bytes);
-#else
- ::operator delete(static_cast<void*>(rep));
-#endif
+ internal::SizedDelete(rep, bytes);
+ } else if (!in_destructor) {
+ // If we are in the destructor, we might be being destroyed as part of
+ // the arena teardown. We can't try and return blocks to the arena then.
+ rep->arena->ReturnArrayMemory(rep, bytes);
}
}
}
@@ -419,7 +433,7 @@ class RepeatedField {
// largely the presence of the fallback path disturbs the compilers mem-to-reg
// analysis.
//
- // This class takes ownership of a repeated field for the duration of it's
+ // This class takes ownership of a repeated field for the duration of its
// lifetime. The repeated field should not be accessed during this time, ie.
// only access through this class is allowed. This class should always be a
// function local stack variable. Intended use
@@ -432,13 +446,13 @@ class RepeatedField {
// }
// }
//
- // Typically due to the fact adder is a local stack variable. The compiler
- // will be successful in mem-to-reg transformation and the machine code will
- // be loop: cmp %size, %capacity jae fallback mov dword ptr [%buffer + %size *
- // 4], %val inc %size jmp loop
+ // Typically, due to the fact that adder is a local stack variable, the
+ // compiler will be successful in mem-to-reg transformation and the machine
+ // code will be loop: cmp %size, %capacity jae fallback mov dword ptr [%buffer
+ // + %size * 4], %val inc %size jmp loop
//
// The first version executes at 7 cycles per iteration while the second
- // version near 1 or 2 cycles.
+ // version executes at only 1 or 2 cycles.
template <int = 0, bool = std::is_trivial<Element>::value>
class FastAdderImpl {
public:
@@ -531,13 +545,13 @@ RepeatedField<Element>::RepeatedField(Iter begin, Iter end)
template <typename Element>
RepeatedField<Element>::~RepeatedField() {
#ifndef NDEBUG
- // Try to trigger segfault / asan failure in non-opt builds. If arena_
+ // Try to trigger segfault / asan failure in non-opt builds if arena_
// lifetime has ended before the destructor.
auto arena = GetArena();
if (arena) (void)arena->SpaceAllocated();
#endif
if (total_size_ > 0) {
- InternalDeallocate(rep(), total_size_);
+ InternalDeallocate(rep(), total_size_, true);
}
}
@@ -612,15 +626,15 @@ inline Element* RepeatedField<Element>::AddAlreadyReserved() {
}
template <typename Element>
-inline Element* RepeatedField<Element>::AddNAlreadyReserved(int n) {
- GOOGLE_DCHECK_GE(total_size_ - current_size_, n)
+inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
+ GOOGLE_DCHECK_GE(total_size_ - current_size_, elements)
<< total_size_ << ", " << current_size_;
- // Warning: sometimes people call this when n == 0 and total_size_ == 0. In
- // this case the return pointer points to a zero size array (n == 0). Hence
- // we can just use unsafe_elements(), because the user cannot dereference the
- // pointer anyway.
+ // Warning: sometimes people call this when elements == 0 and
+ // total_size_ == 0. In this case the return pointer points to a zero size
+ // array (n == 0). Hence we can just use unsafe_elements(), because the user
+ // cannot dereference the pointer anyway.
Element* ret = unsafe_elements() + current_size_;
- current_size_ += n;
+ current_size_ += elements;
return ret;
}
@@ -833,6 +847,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) {
template <typename Element>
void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
if (this == other) return;
+ GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
InternalSwap(other);
}
@@ -845,31 +860,31 @@ void RepeatedField<Element>::SwapElements(int index1, int index2) {
template <typename Element>
inline typename RepeatedField<Element>::iterator
RepeatedField<Element>::begin() {
- return unsafe_elements();
+ return iterator(unsafe_elements());
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::begin() const {
- return unsafe_elements();
+ return const_iterator(unsafe_elements());
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::cbegin() const {
- return unsafe_elements();
+ return const_iterator(unsafe_elements());
}
template <typename Element>
inline typename RepeatedField<Element>::iterator RepeatedField<Element>::end() {
- return unsafe_elements() + current_size_;
+ return iterator(unsafe_elements() + current_size_);
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::end() const {
- return unsafe_elements() + current_size_;
+ return const_iterator(unsafe_elements() + current_size_);
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::cend() const {
- return unsafe_elements() + current_size_;
+ return const_iterator(unsafe_elements() + current_size_);
}
template <typename Element>
@@ -886,18 +901,23 @@ namespace internal {
// new_size > total_size &&
// (total_size == 0 ||
// total_size >= kRepeatedFieldLowerClampLimit)
+template <typename T, int kRepHeaderSize>
inline int CalculateReserveSize(int total_size, int new_size) {
- if (new_size < kRepeatedFieldLowerClampLimit) {
+ constexpr int lower_limit = RepeatedFieldLowerClampLimit<T, kRepHeaderSize>();
+ if (new_size < lower_limit) {
// Clamp to smallest allowed size.
- return kRepeatedFieldLowerClampLimit;
+ return lower_limit;
}
- if (total_size < kRepeatedFieldUpperClampLimit) {
- return std::max(total_size * 2, new_size);
- } else {
- // Clamp to largest allowed size.
- GOOGLE_DCHECK_GT(new_size, kRepeatedFieldUpperClampLimit);
+ constexpr int kMaxSizeBeforeClamp =
+ (std::numeric_limits<int>::max() - kRepHeaderSize) / 2;
+ if (PROTOBUF_PREDICT_FALSE(total_size > kMaxSizeBeforeClamp)) {
return std::numeric_limits<int>::max();
}
+ // We want to double the number of bytes, not the number of elements, to try
+ // to stay within power-of-two allocations.
+ // The allocation has kRepHeaderSize + sizeof(T) * capacity.
+ int doubled_size = 2 * total_size + kRepHeaderSize / sizeof(T);
+ return std::max(doubled_size, new_size);
}
} // namespace internal
@@ -909,7 +929,10 @@ void RepeatedField<Element>::Reserve(int new_size) {
Rep* old_rep = total_size_ > 0 ? rep() : nullptr;
Rep* new_rep;
Arena* arena = GetArena();
- new_size = internal::CalculateReserveSize(total_size_, new_size);
+
+ new_size = internal::CalculateReserveSize<Element, kRepHeaderSize>(
+ total_size_, new_size);
+
GOOGLE_DCHECK_LE(
static_cast<size_t>(new_size),
(std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element))
@@ -928,7 +951,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
// total_size_ == 0 ||
// total_size_ >= internal::kMinRepeatedFieldAllocationSize
total_size_ = new_size;
- arena_or_elements_ = new_rep->elements;
+ arena_or_elements_ = new_rep->elements();
// Invoke placement-new on newly allocated elements. We shouldn't have to do
// this, since Element is supposed to be POD, but a previous version of this
// code allocated storage with "new Element[size]" and some code uses
@@ -944,11 +967,11 @@ void RepeatedField<Element>::Reserve(int new_size) {
new (e) Element;
}
if (current_size_ > 0) {
- MoveArray(&elements()[0], old_rep->elements, current_size_);
+ MoveArray(&elements()[0], old_rep->elements(), current_size_);
}
// Likewise, we need to invoke destructors on the old array.
- InternalDeallocate(old_rep, old_total_size);
+ InternalDeallocate(old_rep, old_total_size, false);
}
@@ -1003,6 +1026,134 @@ struct ElementCopier<Element, true> {
// Ported by johannes from util/gtl/proto-array-iterators.h
namespace internal {
+
+// STL-like iterator implementation for RepeatedField. You should not
+// refer to this class directly; use RepeatedField<T>::iterator instead.
+//
+// Note: All of the iterator operators *must* be inlined to avoid performance
+// regressions. This is caused by the extern template declarations below (which
+// are required because of the RepeatedField extern template declarations). If
+// any of these functions aren't explicitly inlined (e.g. defined in the class),
+// the compiler isn't allowed to inline them.
+template <typename Element>
+class RepeatedIterator {
+ private:
+ using traits =
+ std::iterator_traits<typename std::remove_const<Element>::type*>;
+
+ public:
+ // Note: value_type is never cv-qualified.
+ using value_type = typename traits::value_type;
+ using difference_type = typename traits::difference_type;
+ using pointer = Element*;
+ using reference = Element&;
+ using iterator_category = typename traits::iterator_category;
+ using iterator_concept = typename IteratorConceptSupport<traits>::tag;
+
+ constexpr RepeatedIterator() noexcept : it_(nullptr) {}
+
+ // Allows "upcasting" from RepeatedIterator<T**> to
+ // RepeatedIterator<const T*const*>.
+ template <typename OtherElement,
+ typename std::enable_if<std::is_convertible<
+ OtherElement*, pointer>::value>::type* = nullptr>
+ constexpr RepeatedIterator(
+ const RepeatedIterator<OtherElement>& other) noexcept
+ : it_(other.it_) {}
+
+ // dereferenceable
+ constexpr reference operator*() const noexcept { return *it_; }
+ constexpr pointer operator->() const noexcept { return it_; }
+
+ private:
+ // Helper alias to hide the internal type.
+ using iterator = RepeatedIterator<Element>;
+
+ public:
+ // {inc,dec}rementable
+ iterator& operator++() noexcept {
+ ++it_;
+ return *this;
+ }
+ iterator operator++(int) noexcept { return iterator(it_++); }
+ iterator& operator--() noexcept {
+ --it_;
+ return *this;
+ }
+ iterator operator--(int) noexcept { return iterator(it_--); }
+
+ // equality_comparable
+ friend constexpr bool operator==(const iterator& x,
+ const iterator& y) noexcept {
+ return x.it_ == y.it_;
+ }
+ friend constexpr bool operator!=(const iterator& x,
+ const iterator& y) noexcept {
+ return x.it_ != y.it_;
+ }
+
+ // less_than_comparable
+ friend constexpr bool operator<(const iterator& x,
+ const iterator& y) noexcept {
+ return x.it_ < y.it_;
+ }
+ friend constexpr bool operator<=(const iterator& x,
+ const iterator& y) noexcept {
+ return x.it_ <= y.it_;
+ }
+ friend constexpr bool operator>(const iterator& x,
+ const iterator& y) noexcept {
+ return x.it_ > y.it_;
+ }
+ friend constexpr bool operator>=(const iterator& x,
+ const iterator& y) noexcept {
+ return x.it_ >= y.it_;
+ }
+
+ // addable, subtractable
+ iterator& operator+=(difference_type d) noexcept {
+ it_ += d;
+ return *this;
+ }
+ constexpr iterator operator+(difference_type d) const noexcept {
+ return iterator(it_ + d);
+ }
+ friend constexpr iterator operator+(const difference_type d,
+ iterator it) noexcept {
+ return it + d;
+ }
+
+ iterator& operator-=(difference_type d) noexcept {
+ it_ -= d;
+ return *this;
+ }
+ iterator constexpr operator-(difference_type d) const noexcept {
+ return iterator(it_ - d);
+ }
+
+ // indexable
+ constexpr reference operator[](difference_type d) const noexcept {
+ return it_[d];
+ }
+
+ // random access iterator
+ friend constexpr difference_type operator-(iterator it1,
+ iterator it2) noexcept {
+ return it1.it_ - it2.it_;
+ }
+
+ private:
+ template <typename OtherElement>
+ friend class RepeatedIterator;
+
+ // Allow construction from RepeatedField.
+ friend class RepeatedField<value_type>;
+ explicit RepeatedIterator(pointer it) noexcept : it_(it) {}
+
+ // The internal iterator.
+ pointer it_;
+};
+
// A back inserter for RepeatedField objects.
template <typename T>
class RepeatedFieldBackInsertIterator {
@@ -1049,6 +1200,20 @@ extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<arc_ui64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<float>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<double>;
+namespace internal {
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<bool>;
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
+ RepeatedIterator<arc_i32>;
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
+ RepeatedIterator<arc_ui32>;
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
+ RepeatedIterator<arc_i64>;
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
+ RepeatedIterator<arc_ui64>;
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<float>;
+extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<double>;
+} // namespace internal
+
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc b/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc
index b94b094d48..a8ba509882 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc
@@ -32,14 +32,15 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/repeated_field.h>
-
#include <algorithm>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/implicit_weak_message.h>
+#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -56,8 +57,8 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) {
}
Rep* old_rep = rep_;
Arena* arena = GetArena();
- new_size = std::max(internal::kRepeatedFieldLowerClampLimit,
- std::max(total_size_ * 2, new_size));
+ new_size = internal::CalculateReserveSize<void*, kRepHeaderSize>(total_size_,
+ new_size);
GOOGLE_CHECK_LE(static_cast<arc_i64>(new_size),
static_cast<arc_i64>(
(std::numeric_limits<size_t>::max() - kRepHeaderSize) /
@@ -69,25 +70,24 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) {
} else {
rep_ = reinterpret_cast<Rep*>(Arena::CreateArray<char>(arena, bytes));
}
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
const int old_total_size = total_size_;
-#endif
total_size_ = new_size;
- if (old_rep && old_rep->allocated_size > 0) {
- memcpy(rep_->elements, old_rep->elements,
- old_rep->allocated_size * sizeof(rep_->elements[0]));
+ if (old_rep) {
+ if (old_rep->allocated_size > 0) {
+ memcpy(rep_->elements, old_rep->elements,
+ old_rep->allocated_size * sizeof(rep_->elements[0]));
+ }
rep_->allocated_size = old_rep->allocated_size;
- } else {
- rep_->allocated_size = 0;
- }
- if (arena == nullptr) {
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
+
const size_t old_size =
old_total_size * sizeof(rep_->elements[0]) + kRepHeaderSize;
- ::operator delete(static_cast<void*>(old_rep), old_size);
-#else
- ::operator delete(static_cast<void*>(old_rep));
-#endif
+ if (arena == nullptr) {
+ internal::SizedDelete(old_rep, old_size);
+ } else {
+ arena_->ReturnArrayMemory(old_rep, old_size);
+ }
+ } else {
+ rep_->allocated_size = 0;
}
return &rep_->elements[current_size_];
}
@@ -106,14 +106,9 @@ void RepeatedPtrFieldBase::DestroyProtos() {
for (int i = 0; i < n; i++) {
delete static_cast<MessageLite*>(elements[i]);
}
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize;
- ::operator delete(static_cast<void*>(rep_), size);
- rep_ = nullptr;
-#else
- ::operator delete(static_cast<void*>(rep_));
+ internal::SizedDelete(rep_, size);
rep_ = nullptr;
-#endif
}
void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) {
diff --git a/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h b/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h
index 6c38172fd3..94b1281af7 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h
@@ -39,16 +39,15 @@
// particularly different from STL vector as it manages ownership of the
// pointers that it contains.
//
-// Typically, clients should not need to access RepeatedField objects directly,
-// but should instead use the accessor functions generated automatically by the
-// protocol compiler.
-//
// This header covers RepeatedPtrField.
+// IWYU pragma: private, include "net/proto2/public/repeated_field.h"
+
#ifndef GOOGLE_PROTOBUF_REPEATED_PTR_FIELD_H__
#define GOOGLE_PROTOBUF_REPEATED_PTR_FIELD_H__
#include <utility>
+
#ifdef _MSC_VER
// This is required for min/max on VS2013 only.
#include <algorithm>
@@ -62,8 +61,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
-#include <google/protobuf/message_lite.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/message_lite.h>
// Must be included last.
@@ -166,8 +165,14 @@ struct IsMovable
// };
class PROTOBUF_EXPORT RepeatedPtrFieldBase {
protected:
- constexpr RepeatedPtrFieldBase();
- explicit RepeatedPtrFieldBase(Arena* arena);
+ constexpr RepeatedPtrFieldBase()
+ : arena_(nullptr), current_size_(0), total_size_(0), rep_(nullptr) {}
+ explicit RepeatedPtrFieldBase(Arena* arena)
+ : arena_(arena), current_size_(0), total_size_(0), rep_(nullptr) {}
+
+ RepeatedPtrFieldBase(const RepeatedPtrFieldBase&) = delete;
+ RepeatedPtrFieldBase& operator=(const RepeatedPtrFieldBase&) = delete;
+
~RepeatedPtrFieldBase() {
#ifndef NDEBUG
// Try to trigger segfault / asan failure in non-opt builds. If arena_
@@ -176,27 +181,84 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
#endif
}
- // Must be called from destructor.
- template <typename TypeHandler>
- void Destroy();
- bool NeedsDestroy() const { return rep_ != nullptr && arena_ == nullptr; }
- void DestroyProtos();
+ bool empty() const { return current_size_ == 0; }
+ int size() const { return current_size_; }
+ int Capacity() const { return total_size_; }
- bool empty() const;
- int size() const;
+ template <typename TypeHandler>
+ const typename TypeHandler::Type& at(int index) const {
+ GOOGLE_CHECK_GE(index, 0);
+ GOOGLE_CHECK_LT(index, current_size_);
+ return *cast<TypeHandler>(rep_->elements[index]);
+ }
template <typename TypeHandler>
- const typename TypeHandler::Type& at(int index) const;
+ typename TypeHandler::Type& at(int index) {
+ GOOGLE_CHECK_GE(index, 0);
+ GOOGLE_CHECK_LT(index, current_size_);
+ return *cast<TypeHandler>(rep_->elements[index]);
+ }
+
template <typename TypeHandler>
- typename TypeHandler::Type& at(int index);
+ typename TypeHandler::Type* Mutable(int index) {
+ GOOGLE_DCHECK_GE(index, 0);
+ GOOGLE_DCHECK_LT(index, current_size_);
+ return cast<TypeHandler>(rep_->elements[index]);
+ }
template <typename TypeHandler>
- typename TypeHandler::Type* Mutable(int index);
+ typename TypeHandler::Type* Add(
+ const typename TypeHandler::Type* prototype = nullptr) {
+ if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
+ return cast<TypeHandler>(rep_->elements[current_size_++]);
+ }
+ typename TypeHandler::Type* result =
+ TypeHandler::NewFromPrototype(prototype, arena_);
+ return reinterpret_cast<typename TypeHandler::Type*>(
+ AddOutOfLineHelper(result));
+ }
+
+ template <
+ typename TypeHandler,
+ typename std::enable_if<TypeHandler::Movable::value>::type* = nullptr>
+ inline void Add(typename TypeHandler::Type&& value) {
+ if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
+ *cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value);
+ return;
+ }
+ if (!rep_ || rep_->allocated_size == total_size_) {
+ Reserve(total_size_ + 1);
+ }
+ ++rep_->allocated_size;
+ typename TypeHandler::Type* result =
+ TypeHandler::New(arena_, std::move(value));
+ rep_->elements[current_size_++] = result;
+ }
+
template <typename TypeHandler>
- void Delete(int index);
+ void Delete(int index) {
+ GOOGLE_DCHECK_GE(index, 0);
+ GOOGLE_DCHECK_LT(index, current_size_);
+ TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_);
+ }
+
+ // Must be called from destructor.
template <typename TypeHandler>
- typename TypeHandler::Type* Add(
- typename TypeHandler::Type* prototype = nullptr);
+ void Destroy() {
+ if (rep_ != nullptr && arena_ == nullptr) {
+ int n = rep_->allocated_size;
+ void* const* elements = rep_->elements;
+ for (int i = 0; i < n; i++) {
+ TypeHandler::Delete(cast<TypeHandler>(elements[i]), nullptr);
+ }
+ const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize;
+ internal::SizedDelete(rep_, size);
+ }
+ rep_ = nullptr;
+ }
+
+ bool NeedsDestroy() const { return rep_ != nullptr && arena_ == nullptr; }
+ void DestroyProtos(); // implemented in the cc file
public:
// The next few methods are public so that they can be called from generated
@@ -204,7 +266,11 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// application code.
template <typename TypeHandler>
- const typename TypeHandler::Type& Get(int index) const;
+ const typename TypeHandler::Type& Get(int index) const {
+ GOOGLE_DCHECK_GE(index, 0);
+ GOOGLE_DCHECK_LT(index, current_size_);
+ return *cast<TypeHandler>(rep_->elements[index]);
+ }
// Creates and adds an element using the given prototype, without introducing
// a link-time dependency on the concrete message type. This method is used to
@@ -213,27 +279,61 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
MessageLite* AddWeak(const MessageLite* prototype);
template <typename TypeHandler>
- void Clear();
+ void Clear() {
+ const int n = current_size_;
+ GOOGLE_DCHECK_GE(n, 0);
+ if (n > 0) {
+ void* const* elements = rep_->elements;
+ int i = 0;
+ do {
+ TypeHandler::Clear(cast<TypeHandler>(elements[i++]));
+ } while (i < n);
+ current_size_ = 0;
+ }
+ }
template <typename TypeHandler>
- void MergeFrom(const RepeatedPtrFieldBase& other);
-
- inline void InternalSwap(RepeatedPtrFieldBase*);
+ void MergeFrom(const RepeatedPtrFieldBase& other) {
+ // To avoid unnecessary code duplication and reduce binary size, we use a
+ // layered approach to implementing MergeFrom(). The toplevel method is
+ // templated, so we get a small thunk per concrete message type in the
+ // binary. This calls a shared implementation with most of the logic,
+ // passing a function pointer to another type-specific piece of code that
+ // calls the object-allocate and merge handlers.
+ GOOGLE_DCHECK_NE(&other, this);
+ if (other.current_size_ == 0) return;
+ MergeFromInternal(other,
+ &RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>);
+ }
+
+ inline void InternalSwap(RepeatedPtrFieldBase* rhs) {
+ GOOGLE_DCHECK(this != rhs);
+
+ // Swap all fields at once.
+ auto temp = std::make_tuple(rhs->arena_, rhs->current_size_,
+ rhs->total_size_, rhs->rep_);
+ std::tie(rhs->arena_, rhs->current_size_, rhs->total_size_, rhs->rep_) =
+ std::make_tuple(arena_, current_size_, total_size_, rep_);
+ std::tie(arena_, current_size_, total_size_, rep_) = temp;
+ }
protected:
- template <
- typename TypeHandler,
- typename std::enable_if<TypeHandler::Movable::value>::type* = nullptr>
- void Add(typename TypeHandler::Type&& value);
-
template <typename TypeHandler>
- void RemoveLast();
+ void RemoveLast() {
+ GOOGLE_DCHECK_GT(current_size_, 0);
+ TypeHandler::Clear(cast<TypeHandler>(rep_->elements[--current_size_]));
+ }
+
template <typename TypeHandler>
- void CopyFrom(const RepeatedPtrFieldBase& other);
+ void CopyFrom(const RepeatedPtrFieldBase& other) {
+ if (&other == this) return;
+ RepeatedPtrFieldBase::Clear<TypeHandler>();
+ RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);
+ }
- void CloseGap(int start, int num);
+ void CloseGap(int start, int num); // implemented in the cc file
- void Reserve(int new_size);
+ void Reserve(int new_size); // implemented in the cc file
template<typename TypeHandler>
void Truncate(int new_size) {
@@ -244,8 +344,6 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
current_size_ = new_size;
}
- int Capacity() const;
-
template <typename TypeHandler>
static inline typename TypeHandler::Type* copy(
typename TypeHandler::Type* value) {
@@ -255,27 +353,69 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
}
// Used for constructing iterators.
- void* const* raw_data() const;
- void** raw_mutable_data() const;
+ void* const* raw_data() const { return rep_ ? rep_->elements : nullptr; }
+ void** raw_mutable_data() const {
+ return rep_ ? const_cast<void**>(rep_->elements) : nullptr;
+ }
template <typename TypeHandler>
- typename TypeHandler::Type** mutable_data();
+ typename TypeHandler::Type** mutable_data() {
+ // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
+ // method entirely.
+ return reinterpret_cast<typename TypeHandler::Type**>(raw_mutable_data());
+ }
+
template <typename TypeHandler>
- const typename TypeHandler::Type* const* data() const;
+ const typename TypeHandler::Type* const* data() const {
+ // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
+ // method entirely.
+ return reinterpret_cast<const typename TypeHandler::Type* const*>(
+ raw_data());
+ }
template <typename TypeHandler>
- PROTOBUF_NDEBUG_INLINE void Swap(RepeatedPtrFieldBase* other);
+ PROTOBUF_NDEBUG_INLINE void Swap(RepeatedPtrFieldBase* other) {
+#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
+ if (GetArena() != nullptr && GetArena() == other->GetArena())
+#else // PROTOBUF_FORCE_COPY_IN_SWAP
+ if (GetArena() == other->GetArena())
+#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
+ {
+ InternalSwap(other);
+ } else {
+ SwapFallback<TypeHandler>(other);
+ }
+ }
- void SwapElements(int index1, int index2);
+ void SwapElements(int index1, int index2) {
+ using std::swap; // enable ADL with fallback
+ swap(rep_->elements[index1], rep_->elements[index2]);
+ }
template <typename TypeHandler>
- size_t SpaceUsedExcludingSelfLong() const;
+ size_t SpaceUsedExcludingSelfLong() const {
+ size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*);
+ if (rep_ != nullptr) {
+ for (int i = 0; i < rep_->allocated_size; ++i) {
+ allocated_bytes +=
+ TypeHandler::SpaceUsedLong(*cast<TypeHandler>(rep_->elements[i]));
+ }
+ allocated_bytes += kRepHeaderSize;
+ }
+ return allocated_bytes;
+ }
// Advanced memory management --------------------------------------
// Like Add(), but if there are no cleared objects to use, returns nullptr.
template <typename TypeHandler>
- typename TypeHandler::Type* AddFromCleared();
+ typename TypeHandler::Type* AddFromCleared() {
+ if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
+ return cast<TypeHandler>(rep_->elements[current_size_++]);
+ } else {
+ return nullptr;
+ }
+ }
template <typename TypeHandler>
void AddAllocated(typename TypeHandler::Type* value) {
@@ -284,7 +424,31 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
}
template <typename TypeHandler>
- void UnsafeArenaAddAllocated(typename TypeHandler::Type* value);
+ void UnsafeArenaAddAllocated(typename TypeHandler::Type* value) {
+ // Make room for the new pointer.
+ if (!rep_ || current_size_ == total_size_) {
+ // The array is completely full with no cleared objects, so grow it.
+ Reserve(total_size_ + 1);
+ ++rep_->allocated_size;
+ } else if (rep_->allocated_size == total_size_) {
+ // There is no more space in the pointer array because it contains some
+ // cleared objects awaiting reuse. We don't want to grow the array in
+ // this case because otherwise a loop calling AddAllocated() followed by
+ // Clear() would leak memory.
+ TypeHandler::Delete(cast<TypeHandler>(rep_->elements[current_size_]),
+ arena_);
+ } else if (current_size_ < rep_->allocated_size) {
+ // We have some cleared objects. We don't care about their order, so we
+ // can just move the first one to the end to make space.
+ rep_->elements[rep_->allocated_size] = rep_->elements[current_size_];
+ ++rep_->allocated_size;
+ } else {
+ // There are no cleared objects.
+ ++rep_->allocated_size;
+ }
+
+ rep_->elements[current_size_++] = value;
+ }
template <typename TypeHandler>
PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseLast() {
@@ -292,51 +456,187 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
return ReleaseLastInternal<TypeHandler>(t);
}
- // Releases last element and returns it, but does not do out-of-arena copy.
- // And just returns the raw pointer to the contained element in the arena.
+ // Releases and returns the last element, but does not do out-of-arena copy.
+ // Instead, just returns the raw pointer to the contained element in the
+ // arena.
template <typename TypeHandler>
- typename TypeHandler::Type* UnsafeArenaReleaseLast();
+ typename TypeHandler::Type* UnsafeArenaReleaseLast() {
+ GOOGLE_DCHECK_GT(current_size_, 0);
+ typename TypeHandler::Type* result =
+ cast<TypeHandler>(rep_->elements[--current_size_]);
+ --rep_->allocated_size;
+ if (current_size_ < rep_->allocated_size) {
+ // There are cleared elements on the end; replace the removed element
+ // with the last allocated element.
+ rep_->elements[current_size_] = rep_->elements[rep_->allocated_size];
+ }
+ return result;
+ }
+
+ int ClearedCount() const {
+ return rep_ ? (rep_->allocated_size - current_size_) : 0;
+ }
- int ClearedCount() const;
template <typename TypeHandler>
- void AddCleared(typename TypeHandler::Type* value);
+ void AddCleared(typename TypeHandler::Type* value) {
+ GOOGLE_DCHECK(GetArena() == nullptr) << "AddCleared() can only be used on a "
+ "RepeatedPtrField not on an arena.";
+ GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr)
+ << "AddCleared() can only accept values not on an arena.";
+ if (!rep_ || rep_->allocated_size == total_size_) {
+ Reserve(total_size_ + 1);
+ }
+ rep_->elements[rep_->allocated_size++] = value;
+ }
+
template <typename TypeHandler>
- PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared();
+ PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared() {
+ GOOGLE_DCHECK(GetArena() == nullptr)
+ << "ReleaseCleared() can only be used on a RepeatedPtrField not on "
+ << "an arena.";
+ GOOGLE_DCHECK(GetArena() == nullptr);
+ GOOGLE_DCHECK(rep_ != nullptr);
+ GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_);
+ return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]);
+ }
template <typename TypeHandler>
- void AddAllocatedInternal(typename TypeHandler::Type* value, std::true_type);
+ void AddAllocatedInternal(typename TypeHandler::Type* value, std::true_type) {
+ // AddAllocated version that implements arena-safe copying behavior.
+ Arena* element_arena =
+ reinterpret_cast<Arena*>(TypeHandler::GetOwningArena(value));
+ 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 one slot that is not allocated).
+ void** elems = rep_->elements;
+ if (current_size_ < rep_->allocated_size) {
+ // Make space at [current] by moving first allocated element to end of
+ // allocated list.
+ elems[rep_->allocated_size] = elems[current_size_];
+ }
+ elems[current_size_] = value;
+ current_size_ = current_size_ + 1;
+ rep_->allocated_size = rep_->allocated_size + 1;
+ } else {
+ AddAllocatedSlowWithCopy<TypeHandler>(value, element_arena, arena);
+ }
+ }
+
template <typename TypeHandler>
- void AddAllocatedInternal(typename TypeHandler::Type* value, std::false_type);
+ void AddAllocatedInternal(
+ // AddAllocated version that does not implement arena-safe copying
+ // behavior.
+ typename TypeHandler::Type* value, std::false_type) {
+ if (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 one slot that is not allocated).
+ void** elems = rep_->elements;
+ if (current_size_ < rep_->allocated_size) {
+ // Make space at [current] by moving first allocated element to end of
+ // allocated list.
+ elems[rep_->allocated_size] = elems[current_size_];
+ }
+ elems[current_size_] = value;
+ current_size_ = current_size_ + 1;
+ ++rep_->allocated_size;
+ } else {
+ UnsafeArenaAddAllocated<TypeHandler>(value);
+ }
+ }
+ // Slowpath handles all cases, copying if necessary.
template <typename TypeHandler>
PROTOBUF_NOINLINE void AddAllocatedSlowWithCopy(
- typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena);
- template <typename TypeHandler>
- PROTOBUF_NOINLINE void AddAllocatedSlowWithoutCopy(
- typename TypeHandler::Type* value);
+ // Pass value_arena and my_arena to avoid duplicate virtual call (value)
+ // or load (mine).
+ typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena) {
+ // Ensure that either the value is in the same arena, or if not, we do the
+ // appropriate thing: Own() it (if it's on heap and we're in an arena) or
+ // copy it to our arena/heap (otherwise).
+ if (my_arena != nullptr && value_arena == nullptr) {
+ my_arena->Own(value);
+ } else if (my_arena != value_arena) {
+ typename TypeHandler::Type* new_value =
+ TypeHandler::NewFromPrototype(value, my_arena);
+ TypeHandler::Merge(*value, new_value);
+ TypeHandler::Delete(value, value_arena);
+ value = new_value;
+ }
+
+ UnsafeArenaAddAllocated<TypeHandler>(value);
+ }
template <typename TypeHandler>
- typename TypeHandler::Type* ReleaseLastInternal(std::true_type);
+ typename TypeHandler::Type* ReleaseLastInternal(std::true_type) {
+ // ReleaseLast() for types that implement merge/copy behavior.
+ // First, release an element.
+ typename TypeHandler::Type* result = UnsafeArenaReleaseLast<TypeHandler>();
+ // Now perform a copy if we're on an arena.
+ Arena* arena = GetArena();
+
+ typename TypeHandler::Type* new_result;
+#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
+ new_result = copy<TypeHandler>(result);
+ if (arena == nullptr) delete result;
+#else // PROTOBUF_FORCE_COPY_IN_RELEASE
+ new_result = (arena == nullptr) ? result : copy<TypeHandler>(result);
+#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
+ return new_result;
+ }
+
template <typename TypeHandler>
- typename TypeHandler::Type* ReleaseLastInternal(std::false_type);
+ typename TypeHandler::Type* ReleaseLastInternal(std::false_type) {
+ // ReleaseLast() for types that *do not* implement merge/copy behavior --
+ // this is the same as UnsafeArenaReleaseLast(). Note that we GOOGLE_DCHECK-fail if
+ // we're on an arena, since the user really should implement the copy
+ // operation in this case.
+ GOOGLE_DCHECK(GetArena() == nullptr)
+ << "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.";
+ return UnsafeArenaReleaseLast<TypeHandler>();
+ }
template <typename TypeHandler>
- PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other);
+ PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other) {
+#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
+ GOOGLE_DCHECK(GetArena() == nullptr || other->GetArena() != GetArena());
+#else // PROTOBUF_FORCE_COPY_IN_SWAP
+ GOOGLE_DCHECK(other->GetArena() != GetArena());
+#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
+
+ // Copy semantics in this case. We try to improve efficiency by placing the
+ // temporary on |other|'s arena so that messages are copied twice rather
+ // than three times.
+ RepeatedPtrFieldBase temp(other->GetArena());
+ temp.MergeFrom<TypeHandler>(*this);
+ this->Clear<TypeHandler>();
+ this->MergeFrom<TypeHandler>(*other);
+ other->InternalSwap(&temp);
+ temp.Destroy<TypeHandler>(); // Frees rep_ if `other` had no arena.
+ }
inline Arena* GetArena() const { return arena_; }
private:
+ template <typename T> friend class Arena::InternalHelper;
+
+ inline Arena* GetOwningArena() const { return arena_; }
+
static constexpr int kInitialSize = 0;
// A few notes on internal representation:
//
// We use an indirected approach, with struct Rep, to keep
// sizeof(RepeatedPtrFieldBase) equivalent to what it was before arena support
- // was added, namely, 3 8-byte machine words on x86-64. An instance of Rep is
+ // was added; namely, 3 8-byte machine words on x86-64. An instance of Rep is
// allocated only when the repeated field is non-empty, and it is a
// dynamically-sized struct (the header is directly followed by elements[]).
// We place arena_ and current_size_ directly in the object to avoid cache
// misses due to the indirection, because these fields are checked frequently.
- // Placing all fields directly in the RepeatedPtrFieldBase instance costs
+ // Placing all fields directly in the RepeatedPtrFieldBase instance would cost
// significant performance for memory-sensitive workloads.
Arena* arena_;
int current_size_;
@@ -365,20 +665,55 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
void MergeFromInternal(const RepeatedPtrFieldBase& other,
void (RepeatedPtrFieldBase::*inner_loop)(void**,
void**, int,
- int));
+ int)) {
+ // Note: wrapper has already guaranteed that other.rep_ != nullptr here.
+ int other_size = other.current_size_;
+ void** other_elements = other.rep_->elements;
+ void** new_elements = InternalExtend(other_size);
+ int allocated_elems = rep_->allocated_size - current_size_;
+ (this->*inner_loop)(new_elements, other_elements, other_size,
+ allocated_elems);
+ current_size_ += other_size;
+ if (rep_->allocated_size < current_size_) {
+ rep_->allocated_size = current_size_;
+ }
+ }
+ // Merges other_elems to our_elems.
template <typename TypeHandler>
PROTOBUF_NOINLINE void MergeFromInnerLoop(void** our_elems,
void** other_elems, int length,
- int already_allocated);
+ int already_allocated) {
+ if (already_allocated < length) {
+ Arena* arena = GetArena();
+ typename TypeHandler::Type* elem_prototype =
+ reinterpret_cast<typename TypeHandler::Type*>(other_elems[0]);
+ for (int i = already_allocated; i < length; i++) {
+ // Allocate a new empty element that we'll merge into below
+ typename TypeHandler::Type* new_elem =
+ TypeHandler::NewFromPrototype(elem_prototype, arena);
+ our_elems[i] = new_elem;
+ }
+ }
+ // Main loop that does the actual merging
+ for (int i = 0; i < length; i++) {
+ // Already allocated: use existing element.
+ typename TypeHandler::Type* other_elem =
+ reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
+ typename TypeHandler::Type* new_elem =
+ reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]);
+ TypeHandler::Merge(*other_elem, new_elem);
+ }
+ }
- // Internal helper: extend array space if necessary to contain |extend_amount|
- // more elements, and return a pointer to the element immediately following
- // the old list of elements. This interface factors out common behavior from
- // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.
+ // Internal helper: extends array space if necessary to contain
+ // |extend_amount| more elements, and returns a pointer to the element
+ // immediately following the old list of elements. This interface factors out
+ // common behavior from Reserve() and MergeFrom() to reduce code size.
+ // |extend_amount| must be > 0.
void** InternalExtend(int extend_amount);
- // Internal helper for Add: add "obj" as the next element in the
+ // Internal helper for Add: adds "obj" as the next element in the
// array, including potentially resizing the array with Reserve if
// needed
void* AddOutOfLineHelper(void* obj);
@@ -408,8 +743,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
friend class AccessorHelper;
template <typename T>
friend struct google::protobuf::WeakRepeatedPtrField;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase);
+ friend class internal::TcParser; // TODO(jorg): Remove this friend.
};
template <typename GenericType>
@@ -425,7 +759,9 @@ class GenericTypeHandler {
return Arena::Create<GenericType>(arena, std::move(value));
}
static inline GenericType* NewFromPrototype(const GenericType* prototype,
- Arena* arena = nullptr);
+ Arena* arena = nullptr) {
+ return New(arena);
+ }
static inline void Delete(GenericType* value, Arena* arena) {
if (arena == nullptr) {
delete value;
@@ -436,38 +772,37 @@ class GenericTypeHandler {
}
static inline void Clear(GenericType* value) { value->Clear(); }
- PROTOBUF_NOINLINE
static void Merge(const GenericType& from, GenericType* to);
static inline size_t SpaceUsedLong(const GenericType& value) {
return value.SpaceUsedLong();
}
};
-template <typename GenericType>
-GenericType* GenericTypeHandler<GenericType>::NewFromPrototype(
- const GenericType* /* prototype */, Arena* arena) {
- return New(arena);
-}
-template <typename GenericType>
-void GenericTypeHandler<GenericType>::Merge(const GenericType& from,
- GenericType* to) {
- to->MergeFrom(from);
-}
+// NewFromPrototypeHelper() is not defined inline here, as we will need to do a
+// virtual function dispatch anyways to go from Message* to call New/Merge. (The
+// additional helper is needed as a workaround for MSVC.)
+MessageLite* NewFromPrototypeHelper(const MessageLite* prototype, Arena* arena);
-// NewFromPrototype() and Merge() are not defined inline here, as we will need
-// to do a virtual function dispatch anyways to go from Message* to call
-// New/Merge.
template <>
-MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
- const MessageLite* prototype, Arena* arena);
+inline MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
+ const MessageLite* prototype, Arena* arena) {
+ return NewFromPrototypeHelper(prototype, arena);
+}
template <>
inline Arena* GenericTypeHandler<MessageLite>::GetOwningArena(
MessageLite* value) {
return value->GetOwningArena();
}
+
+template <typename GenericType>
+PROTOBUF_NOINLINE inline void GenericTypeHandler<GenericType>::Merge(
+ const GenericType& from, GenericType* to) {
+ to->MergeFrom(from);
+}
template <>
void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,
MessageLite* to);
+
template <>
inline void GenericTypeHandler<TProtoStringType>::Clear(TProtoStringType* value) {
value->clear();
@@ -522,6 +857,7 @@ class StringTypeHandler {
// Messages.
template <typename Element>
class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
+
public:
constexpr RepeatedPtrField();
explicit RepeatedPtrField(Arena* arena);
@@ -558,12 +894,12 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
const Element& at(int index) const;
Element& at(int index);
- // Remove the last element in the array.
+ // Removes the last element in the array.
// Ownership of the element is retained by the array.
void RemoveLast();
- // Delete elements with indices in the range [start .. start+num-1].
- // Caution: implementation moves all elements with indices [start+num .. ].
+ // Deletes elements with indices in the range [start .. start+num-1].
+ // Caution: moves all elements with indices [start+num .. ].
// Calling this routine inside a loop can cause quadratic behavior.
void DeleteSubrange(int start, int num);
@@ -575,7 +911,7 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
template <typename Iter>
PROTOBUF_ATTRIBUTE_REINITIALIZES void Assign(Iter begin, Iter end);
- // Reserve space to expand the field to at least the given size. This only
+ // Reserves space to expand the field to at least the given size. This only
// resizes the pointer array; it doesn't allocate any objects. If the
// array is grown, it will always be at least doubled in size.
void Reserve(int new_size);
@@ -588,20 +924,24 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// Gets the underlying array. This pointer is possibly invalidated by
// any add or remove operation.
+ //
+ // This API is deprecated. Instead of directly working with element array,
+ // use APIs in repeated_field_util.h; e.g. sorting, etc.
+ PROTOBUF_DEPRECATED_MSG("Use APIs in repeated_field_util.h")
Element** mutable_data();
const Element* const* data() const;
- // Swap entire contents with "other". If they are on separate arenas, then
+ // Swaps entire contents with "other". If they are on separate arenas, then
// copies data.
void Swap(RepeatedPtrField* other);
- // Swap entire contents with "other". Caller should guarantee that either both
- // fields are on the same arena or both are on the heap. Swapping between
+ // Swaps entire contents with "other". Caller should guarantee that either
+ // both fields are on the same arena or both are on the heap. Swapping between
// different arenas with this function is disallowed and is caught via
// GOOGLE_DCHECK.
void UnsafeArenaSwap(RepeatedPtrField* other);
- // Swap two elements.
+ // Swaps two elements.
void SwapElements(int index1, int index2);
// STL-like iterator support
@@ -658,7 +998,7 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// When hardcore memory management becomes necessary -- as it sometimes
// does here at Google -- the following methods may be useful.
- // Add an already-allocated object, passing ownership to the
+ // Adds an already-allocated object, passing ownership to the
// RepeatedPtrField.
//
// Note that some special behavior occurs with respect to arenas:
@@ -671,7 +1011,7 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// this at runtime, so User Beware.
void AddAllocated(Element* value);
- // Remove the last element and return it, passing ownership to the caller.
+ // Removes and returns the last element, passing ownership to the caller.
// Requires: size() > 0
//
// If this RepeatedPtrField is on an arena, an object copy is required to pass
@@ -679,7 +1019,7 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// UnsafeArenaReleaseLast() if this behavior is undesired.
PROTOBUF_NODISCARD Element* ReleaseLast();
- // Add an already-allocated object, skipping arena-ownership checks. The user
+ // Adds an already-allocated object, skipping arena-ownership checks. The user
// must guarantee that the given object is in the same arena as this
// RepeatedPtrField.
// It is also useful in legacy code that uses temporary ownership to avoid
@@ -690,16 +1030,16 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// temp_field.UnsafeArenaExtractSubrange(0, temp_field.size(), nullptr);
// If you put temp_field on the arena this fails, because the ownership
// transfers to the arena at the "AddAllocated" call and is not released
- // anymore causing a double delete. UnsafeArenaAddAllocated prevents this.
+ // anymore, causing a double delete. UnsafeArenaAddAllocated prevents this.
void UnsafeArenaAddAllocated(Element* value);
- // Remove the last element and return it. Unlike ReleaseLast, the returned
- // pointer is always to the original object. This may be in an arena, and
- // therefore have the arena's lifetime.
+ // Removes and returns the last element. Unlike ReleaseLast, the returned
+ // pointer is always to the original object. This may be in an arena, in
+ // which case it would have the arena's lifetime.
// Requires: current_size_ > 0
Element* UnsafeArenaReleaseLast();
- // Extract elements with indices in the range "[start .. start+num-1]".
+ // Extracts elements with indices in the range "[start .. start+num-1]".
// The caller assumes ownership of the extracted elements and is responsible
// for deleting them when they are no longer needed.
// If "elements" is non-nullptr, then pointers to the extracted elements
@@ -730,22 +1070,21 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// Hardcore programs may choose to manipulate these cleared objects
// to better optimize memory management using the following routines.
- // Get the number of cleared objects that are currently being kept
+ // Gets the number of cleared objects that are currently being kept
// around for reuse.
int ClearedCount() const;
#ifndef PROTOBUF_FUTURE_BREAKING_CHANGES
- // Add an element to the pool of cleared objects, passing ownership to
+ // Adds an element to the pool of cleared objects, passing ownership to
// the RepeatedPtrField. The element must be cleared prior to calling
// this method.
//
- // This method cannot be called when the repeated field is on an arena or when
- // |value| is; both cases will trigger a GOOGLE_DCHECK-failure.
+ // This method cannot be called when either the repeated field or |value| is
+ // on an arena; both cases will trigger a GOOGLE_DCHECK-failure.
void AddCleared(Element* value);
- // Remove a single element from the cleared pool and return it, passing
+ // Removes and returns a single element from the cleared pool, passing
// ownership to the caller. The element is guaranteed to be cleared.
// Requires: ClearedCount() > 0
//
- //
// This method cannot be called when the repeated field is on an arena; doing
// so will trigger a GOOGLE_DCHECK-failure.
PROTOBUF_NODISCARD Element* ReleaseCleared();
@@ -798,446 +1137,6 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
};
-// implementation ====================================================
-
-namespace internal {
-
-constexpr RepeatedPtrFieldBase::RepeatedPtrFieldBase()
- : arena_(nullptr), current_size_(0), total_size_(0), rep_(nullptr) {}
-
-inline RepeatedPtrFieldBase::RepeatedPtrFieldBase(Arena* arena)
- : arena_(arena), current_size_(0), total_size_(0), rep_(nullptr) {}
-
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::Destroy() {
- if (rep_ != nullptr && arena_ == nullptr) {
- int n = rep_->allocated_size;
- void* const* elements = rep_->elements;
- for (int i = 0; i < n; i++) {
- TypeHandler::Delete(cast<TypeHandler>(elements[i]), nullptr);
- }
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
- const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize;
- ::operator delete(static_cast<void*>(rep_), size);
-#else
- ::operator delete(static_cast<void*>(rep_));
-#endif
- }
- rep_ = nullptr;
-}
-
-template <typename TypeHandler>
-inline void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) {
-#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
- if (GetArena() != nullptr && GetArena() == other->GetArena()) {
-#else // PROTOBUF_FORCE_COPY_IN_SWAP
- if (GetArena() == other->GetArena()) {
-#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
- InternalSwap(other);
- } else {
- SwapFallback<TypeHandler>(other);
- }
-}
-
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::SwapFallback(RepeatedPtrFieldBase* other) {
-#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
- GOOGLE_DCHECK(GetArena() == nullptr || other->GetArena() != GetArena());
-#else // PROTOBUF_FORCE_COPY_IN_SWAP
- GOOGLE_DCHECK(other->GetArena() != GetArena());
-#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
-
- // Copy semantics in this case. We try to improve efficiency by placing the
- // temporary on |other|'s arena so that messages are copied twice rather than
- // three times.
- RepeatedPtrFieldBase temp(other->GetArena());
- temp.MergeFrom<TypeHandler>(*this);
- this->Clear<TypeHandler>();
- this->MergeFrom<TypeHandler>(*other);
- other->InternalSwap(&temp);
- temp.Destroy<TypeHandler>(); // Frees rep_ if `other` had no arena.
-}
-
-inline bool RepeatedPtrFieldBase::empty() const { return current_size_ == 0; }
-
-inline int RepeatedPtrFieldBase::size() const { return current_size_; }
-
-template <typename TypeHandler>
-inline const typename TypeHandler::Type& RepeatedPtrFieldBase::Get(
- int index) const {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
- return *cast<TypeHandler>(rep_->elements[index]);
-}
-
-template <typename TypeHandler>
-inline const typename TypeHandler::Type& RepeatedPtrFieldBase::at(
- int index) const {
- GOOGLE_CHECK_GE(index, 0);
- GOOGLE_CHECK_LT(index, current_size_);
- return *cast<TypeHandler>(rep_->elements[index]);
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type& RepeatedPtrFieldBase::at(int index) {
- GOOGLE_CHECK_GE(index, 0);
- GOOGLE_CHECK_LT(index, current_size_);
- return *cast<TypeHandler>(rep_->elements[index]);
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type* RepeatedPtrFieldBase::Mutable(int index) {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
- return cast<TypeHandler>(rep_->elements[index]);
-}
-
-template <typename TypeHandler>
-inline void RepeatedPtrFieldBase::Delete(int index) {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
- TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_);
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add(
- typename TypeHandler::Type* prototype) {
- if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
- return cast<TypeHandler>(rep_->elements[current_size_++]);
- }
- typename TypeHandler::Type* result =
- TypeHandler::NewFromPrototype(prototype, arena_);
- return reinterpret_cast<typename TypeHandler::Type*>(
- AddOutOfLineHelper(result));
-}
-
-template <typename TypeHandler,
- typename std::enable_if<TypeHandler::Movable::value>::type*>
-inline void RepeatedPtrFieldBase::Add(typename TypeHandler::Type&& value) {
- if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
- *cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value);
- return;
- }
- if (!rep_ || rep_->allocated_size == total_size_) {
- Reserve(total_size_ + 1);
- }
- ++rep_->allocated_size;
- typename TypeHandler::Type* result =
- TypeHandler::New(arena_, std::move(value));
- rep_->elements[current_size_++] = result;
-}
-
-template <typename TypeHandler>
-inline void RepeatedPtrFieldBase::RemoveLast() {
- GOOGLE_DCHECK_GT(current_size_, 0);
- TypeHandler::Clear(cast<TypeHandler>(rep_->elements[--current_size_]));
-}
-
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::Clear() {
- const int n = current_size_;
- GOOGLE_DCHECK_GE(n, 0);
- if (n > 0) {
- void* const* elements = rep_->elements;
- int i = 0;
- do {
- TypeHandler::Clear(cast<TypeHandler>(elements[i++]));
- } while (i < n);
- current_size_ = 0;
- }
-}
-
-// To avoid unnecessary code duplication and reduce binary size, we use a
-// layered approach to implementing MergeFrom(). The toplevel method is
-// templated, so we get a small thunk per concrete message type in the binary.
-// This calls a shared implementation with most of the logic, passing a function
-// pointer to another type-specific piece of code that calls the object-allocate
-// and merge handlers.
-template <typename TypeHandler>
-inline void RepeatedPtrFieldBase::MergeFrom(const RepeatedPtrFieldBase& other) {
- GOOGLE_DCHECK_NE(&other, this);
- if (other.current_size_ == 0) return;
- MergeFromInternal(other,
- &RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>);
-}
-
-inline void RepeatedPtrFieldBase::MergeFromInternal(
- const RepeatedPtrFieldBase& other,
- void (RepeatedPtrFieldBase::*inner_loop)(void**, void**, int, int)) {
- // Note: wrapper has already guaranteed that other.rep_ != nullptr here.
- int other_size = other.current_size_;
- void** other_elements = other.rep_->elements;
- void** new_elements = InternalExtend(other_size);
- int allocated_elems = rep_->allocated_size - current_size_;
- (this->*inner_loop)(new_elements, other_elements, other_size,
- allocated_elems);
- current_size_ += other_size;
- if (rep_->allocated_size < current_size_) {
- rep_->allocated_size = current_size_;
- }
-}
-
-// Merges other_elems to our_elems.
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems,
- void** other_elems, int length,
- int already_allocated) {
- if (already_allocated < length) {
- Arena* arena = GetArena();
- typename TypeHandler::Type* elem_prototype =
- reinterpret_cast<typename TypeHandler::Type*>(other_elems[0]);
- for (int i = already_allocated; i < length; i++) {
- // Allocate a new empty element that we'll merge into below
- typename TypeHandler::Type* new_elem =
- TypeHandler::NewFromPrototype(elem_prototype, arena);
- our_elems[i] = new_elem;
- }
- }
- // Main loop that does the actual merging
- for (int i = 0; i < length; i++) {
- // Already allocated: use existing element.
- typename TypeHandler::Type* other_elem =
- reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
- typename TypeHandler::Type* new_elem =
- reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]);
- TypeHandler::Merge(*other_elem, new_elem);
- }
-}
-
-template <typename TypeHandler>
-inline void RepeatedPtrFieldBase::CopyFrom(const RepeatedPtrFieldBase& other) {
- if (&other == this) return;
- RepeatedPtrFieldBase::Clear<TypeHandler>();
- RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);
-}
-
-inline int RepeatedPtrFieldBase::Capacity() const { return total_size_; }
-
-inline void* const* RepeatedPtrFieldBase::raw_data() const {
- return rep_ ? rep_->elements : nullptr;
-}
-
-inline void** RepeatedPtrFieldBase::raw_mutable_data() const {
- return rep_ ? const_cast<void**>(rep_->elements) : nullptr;
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type** RepeatedPtrFieldBase::mutable_data() {
- // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
- // method entirely.
- return reinterpret_cast<typename TypeHandler::Type**>(raw_mutable_data());
-}
-
-template <typename TypeHandler>
-inline const typename TypeHandler::Type* const* RepeatedPtrFieldBase::data()
- const {
- // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
- // method entirely.
- return reinterpret_cast<const typename TypeHandler::Type* const*>(raw_data());
-}
-
-inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) {
- using std::swap; // enable ADL with fallback
- swap(rep_->elements[index1], rep_->elements[index2]);
-}
-
-template <typename TypeHandler>
-inline size_t RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong() const {
- size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*);
- if (rep_ != nullptr) {
- for (int i = 0; i < rep_->allocated_size; ++i) {
- allocated_bytes +=
- TypeHandler::SpaceUsedLong(*cast<TypeHandler>(rep_->elements[i]));
- }
- allocated_bytes += kRepHeaderSize;
- }
- return allocated_bytes;
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type* RepeatedPtrFieldBase::AddFromCleared() {
- if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
- return cast<TypeHandler>(rep_->elements[current_size_++]);
- } else {
- return nullptr;
- }
-}
-
-// AddAllocated version that implements arena-safe copying behavior.
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::AddAllocatedInternal(
- typename TypeHandler::Type* value, std::true_type) {
- Arena* element_arena =
- reinterpret_cast<Arena*>(TypeHandler::GetOwningArena(value));
- 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
- // one slot that is not allocated).
- void** elems = rep_->elements;
- if (current_size_ < rep_->allocated_size) {
- // Make space at [current] by moving first allocated element to end of
- // allocated list.
- elems[rep_->allocated_size] = elems[current_size_];
- }
- elems[current_size_] = value;
- current_size_ = current_size_ + 1;
- rep_->allocated_size = rep_->allocated_size + 1;
- } else {
- AddAllocatedSlowWithCopy<TypeHandler>(value, element_arena, arena);
- }
-}
-
-// Slowpath handles all cases, copying if necessary.
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::AddAllocatedSlowWithCopy(
- // Pass value_arena and my_arena to avoid duplicate virtual call (value) or
- // load (mine).
- typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena) {
- // Ensure that either the value is in the same arena, or if not, we do the
- // appropriate thing: Own() it (if it's on heap and we're in an arena) or copy
- // it to our arena/heap (otherwise).
- if (my_arena != nullptr && value_arena == nullptr) {
- my_arena->Own(value);
- } else if (my_arena != value_arena) {
- typename TypeHandler::Type* new_value =
- TypeHandler::NewFromPrototype(value, my_arena);
- TypeHandler::Merge(*value, new_value);
- TypeHandler::Delete(value, value_arena);
- value = new_value;
- }
-
- UnsafeArenaAddAllocated<TypeHandler>(value);
-}
-
-// AddAllocated version that does not implement arena-safe copying behavior.
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::AddAllocatedInternal(
- typename TypeHandler::Type* value, std::false_type) {
- if (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
- // one slot that is not allocated).
- void** elems = rep_->elements;
- if (current_size_ < rep_->allocated_size) {
- // Make space at [current] by moving first allocated element to end of
- // allocated list.
- elems[rep_->allocated_size] = elems[current_size_];
- }
- elems[current_size_] = value;
- current_size_ = current_size_ + 1;
- ++rep_->allocated_size;
- } else {
- UnsafeArenaAddAllocated<TypeHandler>(value);
- }
-}
-
-template <typename TypeHandler>
-void RepeatedPtrFieldBase::UnsafeArenaAddAllocated(
- typename TypeHandler::Type* value) {
- // Make room for the new pointer.
- if (!rep_ || current_size_ == total_size_) {
- // The array is completely full with no cleared objects, so grow it.
- Reserve(total_size_ + 1);
- ++rep_->allocated_size;
- } else if (rep_->allocated_size == total_size_) {
- // There is no more space in the pointer array because it contains some
- // cleared objects awaiting reuse. We don't want to grow the array in this
- // case because otherwise a loop calling AddAllocated() followed by Clear()
- // would leak memory.
- TypeHandler::Delete(cast<TypeHandler>(rep_->elements[current_size_]),
- arena_);
- } else if (current_size_ < rep_->allocated_size) {
- // We have some cleared objects. We don't care about their order, so we
- // can just move the first one to the end to make space.
- rep_->elements[rep_->allocated_size] = rep_->elements[current_size_];
- ++rep_->allocated_size;
- } else {
- // There are no cleared objects.
- ++rep_->allocated_size;
- }
-
- rep_->elements[current_size_++] = value;
-}
-
-// ReleaseLast() for types that implement merge/copy behavior.
-template <typename TypeHandler>
-inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal(
- std::true_type) {
- // First, release an element.
- typename TypeHandler::Type* result = UnsafeArenaReleaseLast<TypeHandler>();
- // Now perform a copy if we're on an arena.
- Arena* arena = GetArena();
-
- typename TypeHandler::Type* new_result;
-#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
- new_result = copy<TypeHandler>(result);
- if (arena == nullptr) delete result;
-#else // PROTOBUF_FORCE_COPY_IN_RELEASE
- new_result = (arena == nullptr) ? result : copy<TypeHandler>(result);
-#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
- return new_result;
-}
-
-// ReleaseLast() for types that *do not* implement merge/copy behavior -- this
-// is the same as UnsafeArenaReleaseLast(). Note that we GOOGLE_DCHECK-fail if we're on
-// an arena, since the user really should implement the copy operation in this
-// case.
-template <typename TypeHandler>
-inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal(
- std::false_type) {
- GOOGLE_DCHECK(GetArena() == nullptr)
- << "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.";
- return UnsafeArenaReleaseLast<TypeHandler>();
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type*
-RepeatedPtrFieldBase::UnsafeArenaReleaseLast() {
- GOOGLE_DCHECK_GT(current_size_, 0);
- typename TypeHandler::Type* result =
- cast<TypeHandler>(rep_->elements[--current_size_]);
- --rep_->allocated_size;
- if (current_size_ < rep_->allocated_size) {
- // There are cleared elements on the end; replace the removed element
- // with the last allocated element.
- rep_->elements[current_size_] = rep_->elements[rep_->allocated_size];
- }
- return result;
-}
-
-inline int RepeatedPtrFieldBase::ClearedCount() const {
- return rep_ ? (rep_->allocated_size - current_size_) : 0;
-}
-
-template <typename TypeHandler>
-inline void RepeatedPtrFieldBase::AddCleared(
- typename TypeHandler::Type* value) {
- GOOGLE_DCHECK(GetArena() == nullptr)
- << "AddCleared() can only be used on a RepeatedPtrField not on an arena.";
- GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr)
- << "AddCleared() can only accept values not on an arena.";
- if (!rep_ || rep_->allocated_size == total_size_) {
- Reserve(total_size_ + 1);
- }
- rep_->elements[rep_->allocated_size++] = value;
-}
-
-template <typename TypeHandler>
-inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseCleared() {
- GOOGLE_DCHECK(GetArena() == nullptr)
- << "ReleaseCleared() can only be used on a RepeatedPtrField not on "
- << "an arena.";
- GOOGLE_DCHECK(GetArena() == nullptr);
- GOOGLE_DCHECK(rep_ != nullptr);
- GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_);
- return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]);
-}
-
-} // namespace internal
-
// -------------------------------------------------------------------
template <typename Element>
@@ -1544,6 +1443,7 @@ template <typename Element>
inline void RepeatedPtrField<Element>::UnsafeArenaSwap(
RepeatedPtrField* other) {
if (this == other) return;
+ GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
RepeatedPtrFieldBase::InternalSwap(other);
}
@@ -1637,16 +1537,13 @@ class RepeatedPtrIterator {
RepeatedPtrIterator() : it_(nullptr) {}
explicit RepeatedPtrIterator(void* const* it) : it_(it) {}
- // Allow "upcasting" from RepeatedPtrIterator<T**> to
+ // Allows "upcasting" from RepeatedPtrIterator<T**> to
// RepeatedPtrIterator<const T*const*>.
- template <typename OtherElement>
+ template <typename OtherElement,
+ typename std::enable_if<std::is_convertible<
+ OtherElement*, pointer>::value>::type* = nullptr>
RepeatedPtrIterator(const RepeatedPtrIterator<OtherElement>& other)
- : it_(other.it_) {
- // Force a compiler error if the other type is not convertible to ours.
- if (false) {
- static_cast<void>([](OtherElement* from) -> Element* { return from; });
- }
- }
+ : it_(other.it_) {}
// dereferenceable
reference operator*() const { return *reinterpret_cast<Element*>(*it_); }
@@ -1665,14 +1562,26 @@ class RepeatedPtrIterator {
iterator operator--(int) { return iterator(it_--); }
// equality_comparable
- bool operator==(const iterator& x) const { return it_ == x.it_; }
- bool operator!=(const iterator& x) const { return it_ != x.it_; }
+ friend bool operator==(const iterator& x, const iterator& y) {
+ return x.it_ == y.it_;
+ }
+ friend bool operator!=(const iterator& x, const iterator& y) {
+ return x.it_ != y.it_;
+ }
// less_than_comparable
- bool operator<(const iterator& x) const { return it_ < x.it_; }
- bool operator<=(const iterator& x) const { return it_ <= x.it_; }
- bool operator>(const iterator& x) const { return it_ > x.it_; }
- bool operator>=(const iterator& x) const { return it_ >= x.it_; }
+ friend bool operator<(const iterator& x, const iterator& y) {
+ return x.it_ < y.it_;
+ }
+ friend bool operator<=(const iterator& x, const iterator& y) {
+ return x.it_ <= y.it_;
+ }
+ friend bool operator>(const iterator& x, const iterator& y) {
+ return x.it_ > y.it_;
+ }
+ friend bool operator>=(const iterator& x, const iterator& y) {
+ return x.it_ >= y.it_;
+ }
// addable, subtractable
iterator& operator+=(difference_type d) {
@@ -1700,7 +1609,9 @@ class RepeatedPtrIterator {
reference operator[](difference_type d) const { return *(*this + d); }
// random access iterator
- difference_type operator-(const iterator& x) const { return it_ - x.it_; }
+ friend difference_type operator-(iterator it1, iterator it2) {
+ return it1.it_ - it2.it_;
+ }
private:
template <typename OtherElement>
@@ -1710,7 +1621,18 @@ class RepeatedPtrIterator {
void* const* it_;
};
-// Provide an iterator that operates on pointers to the underlying objects
+template <typename Traits, typename = void>
+struct IteratorConceptSupport {
+ using tag = typename Traits::iterator_category;
+};
+
+template <typename Traits>
+struct IteratorConceptSupport<Traits,
+ std::void_t<typename Traits::iterator_concept>> {
+ using tag = typename Traits::iterator_concept;
+};
+
+// Provides an iterator that operates on pointers to the underlying objects
// rather than the objects themselves as RepeatedPtrIterator does.
// Consider using this when working with stl algorithms that change
// the array.
@@ -1719,17 +1641,34 @@ class RepeatedPtrIterator {
// iterator, or "const void* const" for a constant iterator.
template <typename Element, typename VoidPtr>
class RepeatedPtrOverPtrsIterator {
+ private:
+ using traits =
+ std::iterator_traits<typename std::remove_const<Element>::type*>;
+
public:
- using iterator = RepeatedPtrOverPtrsIterator<Element, VoidPtr>;
- using iterator_category = std::random_access_iterator_tag;
- using value_type = typename std::remove_const<Element>::type;
- using difference_type = std::ptrdiff_t;
+ using value_type = typename traits::value_type;
+ using difference_type = typename traits::difference_type;
using pointer = Element*;
using reference = Element&;
+ using iterator_category = typename traits::iterator_category;
+ using iterator_concept = typename IteratorConceptSupport<traits>::tag;
+
+ using iterator = RepeatedPtrOverPtrsIterator<Element, VoidPtr>;
RepeatedPtrOverPtrsIterator() : it_(nullptr) {}
explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {}
+ // Allows "upcasting" from RepeatedPtrOverPtrsIterator<T**> to
+ // RepeatedPtrOverPtrsIterator<const T*const*>.
+ template <
+ typename OtherElement, typename OtherVoidPtr,
+ typename std::enable_if<
+ std::is_convertible<OtherElement*, pointer>::value &&
+ std::is_convertible<OtherVoidPtr*, VoidPtr>::value>::type* = nullptr>
+ RepeatedPtrOverPtrsIterator(
+ const RepeatedPtrOverPtrsIterator<OtherElement, OtherVoidPtr>& other)
+ : it_(other.it_) {}
+
// dereferenceable
reference operator*() const { return *reinterpret_cast<Element*>(it_); }
pointer operator->() const { return &(operator*()); }
@@ -1747,14 +1686,26 @@ class RepeatedPtrOverPtrsIterator {
iterator operator--(int) { return iterator(it_--); }
// equality_comparable
- bool operator==(const iterator& x) const { return it_ == x.it_; }
- bool operator!=(const iterator& x) const { return it_ != x.it_; }
+ friend bool operator==(const iterator& x, const iterator& y) {
+ return x.it_ == y.it_;
+ }
+ friend bool operator!=(const iterator& x, const iterator& y) {
+ return x.it_ != y.it_;
+ }
// less_than_comparable
- bool operator<(const iterator& x) const { return it_ < x.it_; }
- bool operator<=(const iterator& x) const { return it_ <= x.it_; }
- bool operator>(const iterator& x) const { return it_ > x.it_; }
- bool operator>=(const iterator& x) const { return it_ >= x.it_; }
+ friend bool operator<(const iterator& x, const iterator& y) {
+ return x.it_ < y.it_;
+ }
+ friend bool operator<=(const iterator& x, const iterator& y) {
+ return x.it_ <= y.it_;
+ }
+ friend bool operator>(const iterator& x, const iterator& y) {
+ return x.it_ > y.it_;
+ }
+ friend bool operator>=(const iterator& x, const iterator& y) {
+ return x.it_ >= y.it_;
+ }
// addable, subtractable
iterator& operator+=(difference_type d) {
@@ -1782,27 +1733,18 @@ class RepeatedPtrOverPtrsIterator {
reference operator[](difference_type d) const { return *(*this + d); }
// random access iterator
- difference_type operator-(const iterator& x) const { return it_ - x.it_; }
+ friend difference_type operator-(iterator it1, iterator it2) {
+ return it1.it_ - it2.it_;
+ }
private:
- template <typename OtherElement>
- friend class RepeatedPtrIterator;
+ template <typename OtherElement, typename OtherVoidPtr>
+ friend class RepeatedPtrOverPtrsIterator;
// The internal iterator.
VoidPtr* it_;
};
-void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* rhs) {
- GOOGLE_DCHECK(this != rhs);
-
- // Swap all fields at once.
- auto temp = std::make_tuple(rhs->arena_, rhs->current_size_, rhs->total_size_,
- rhs->rep_);
- std::tie(rhs->arena_, rhs->current_size_, rhs->total_size_, rhs->rep_) =
- std::make_tuple(arena_, current_size_, total_size_, rep_);
- std::tie(arena_, current_size_, total_size_, rep_) = temp;
-}
-
} // namespace internal
template <typename Element>
@@ -2005,9 +1947,9 @@ AllocatedRepeatedPtrFieldBackInserter(
// temp_field.UnsafeArenaAddAllocated(new T);
// ... // Do something with temp_field
// temp_field.UnsafeArenaExtractSubrange(0, temp_field.size(), nullptr);
-// If you put temp_field on the arena this fails, because the ownership
-// transfers to the arena at the "AddAllocated" call and is not released anymore
-// causing a double delete. Using UnsafeArenaAddAllocated prevents this.
+// Putting temp_field on the arena fails because the ownership transfers to the
+// arena at the "AddAllocated" call and is not released anymore causing a
+// double delete. This function uses UnsafeArenaAddAllocated to prevent this.
template <typename T>
internal::UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>
UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(
diff --git a/contrib/libs/protobuf/src/google/protobuf/service.h b/contrib/libs/protobuf/src/google/protobuf/service.h
index b385bc15ee..c25f672baa 100644
--- a/contrib/libs/protobuf/src/google/protobuf/service.h
+++ b/contrib/libs/protobuf/src/google/protobuf/service.h
@@ -100,6 +100,7 @@
#ifndef GOOGLE_PROTOBUF_SERVICE_H__
#define GOOGLE_PROTOBUF_SERVICE_H__
+
#include <string>
#include <google/protobuf/stubs/callback.h>
#include <google/protobuf/stubs/common.h>
@@ -108,6 +109,7 @@
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc b/contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc
index 15dd5494e8..63f464bc8a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc
@@ -16,23 +16,27 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr SourceContext::SourceContext(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : file_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
+PROTOBUF_CONSTEXPR SourceContext::SourceContext(
+ ::_pbi::ConstantInitialized)
+ : file_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct SourceContextDefaultTypeInternal {
- constexpr SourceContextDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR SourceContextDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~SourceContextDefaultTypeInternal() {}
union {
SourceContext _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceContextDefaultTypeInternal _SourceContext_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[1];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -43,12 +47,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, file_name_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceContext)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -59,19 +63,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eprot
"tobuf/types/known/sourcecontextpb\242\002\003GPB\252"
"\002\036Google.Protobuf.WellKnownTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = {
- false, false, 240, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto",
- &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, nullptr, 0, 1,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = {
+ false, false, 240, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto,
+ "google/protobuf/source_context.proto",
+ &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, nullptr, 0, 1,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fsource_5fcontext_2eproto(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fsource_5fcontext_2eproto(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -84,50 +90,43 @@ SourceContext::SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.SourceContext)
}
SourceContext::SourceContext(const SourceContext& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ file_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ file_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_file_name().empty()) {
- file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_file_name(),
+ file_name_.Set(from._internal_file_name(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
}
inline void SourceContext::SharedCtor() {
-file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+file_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ file_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
SourceContext::~SourceContext() {
// @@protoc_insertion_point(destructor:google.protobuf.SourceContext)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void SourceContext::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ file_name_.Destroy();
}
-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);
}
@@ -142,19 +141,19 @@ void SourceContext::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* SourceContext::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* SourceContext::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string file_name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_file_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceContext.file_name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.SourceContext.file_name"));
} else
goto handle_unusual;
continue;
@@ -198,7 +197,7 @@ uint8_t* SourceContext::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -265,14 +264,13 @@ void SourceContext::InternalSwap(SourceContext* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&file_name_, lhs_arena,
&other->file_name_, rhs_arena
);
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter, &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once,
file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[0]);
}
@@ -280,7 +278,8 @@ void SourceContext::InternalSwap(SourceContext* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceContext* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceContext >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceContext*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceContext >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceContext >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/source_context.pb.h b/contrib/libs/protobuf/src/google/protobuf/source_context.pb.h
index 408200d2bf..56be038c96 100644
--- a/contrib/libs/protobuf/src/google/protobuf/source_context.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/source_context.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
@@ -70,7 +61,7 @@ class PROTOBUF_EXPORT SourceContext final :
public:
inline SourceContext() : SourceContext(nullptr) {}
~SourceContext() override;
- explicit constexpr SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SourceContext(const SourceContext& from);
SourceContext(SourceContext&& from) noexcept
@@ -172,9 +163,6 @@ class PROTOBUF_EXPORT SourceContext final :
protected:
explicit SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -237,7 +225,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) {
- file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ file_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
}
inline TProtoStringType* SourceContext::mutable_file_name() {
@@ -250,15 +238,15 @@ inline const TProtoStringType& SourceContext::_internal_file_name() const {
}
inline void SourceContext::_internal_set_file_name(const TProtoStringType& value) {
- file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ file_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* SourceContext::_internal_mutable_file_name() {
- return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return file_name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* SourceContext::release_file_name() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)
- return file_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return file_name_.Release();
}
inline void SourceContext::set_allocated_file_name(TProtoStringType* file_name) {
if (file_name != nullptr) {
@@ -266,11 +254,10 @@ inline void SourceContext::set_allocated_file_name(TProtoStringType* file_name)
} else {
}
- file_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name,
- GetArenaForAllocation());
+ file_name_.SetAllocated(file_name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (file_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (file_name_.IsDefault()) {
+ file_name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
diff --git a/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc b/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc
index 4596e7b2a5..5d0f7619c9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc
@@ -16,58 +16,62 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){}
+PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(
+ ::_pbi::ConstantInitialized){}
struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal {
- constexpr Struct_FieldsEntry_DoNotUseDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUseDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~Struct_FieldsEntry_DoNotUseDefaultTypeInternal() {}
union {
Struct_FieldsEntry_DoNotUse _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
-constexpr Struct::Struct(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
+PROTOBUF_CONSTEXPR Struct::Struct(
+ ::_pbi::ConstantInitialized)
: fields_(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}){}
struct StructDefaultTypeInternal {
- constexpr StructDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR StructDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~StructDefaultTypeInternal() {}
union {
Struct _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT StructDefaultTypeInternal _Struct_default_instance_;
-constexpr Value::Value(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StructDefaultTypeInternal _Struct_default_instance_;
+PROTOBUF_CONSTEXPR Value::Value(
+ ::_pbi::ConstantInitialized)
: _oneof_case_{}{}
struct ValueDefaultTypeInternal {
- constexpr ValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~ValueDefaultTypeInternal() {}
union {
Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ValueDefaultTypeInternal _Value_default_instance_;
-constexpr ListValue::ListValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ValueDefaultTypeInternal _Value_default_instance_;
+PROTOBUF_CONSTEXPR ListValue::ListValue(
+ ::_pbi::ConstantInitialized)
: values_(){}
struct ListValueDefaultTypeInternal {
- constexpr ListValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ListValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~ListValueDefaultTypeInternal() {}
union {
ListValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ListValueDefaultTypeInternal _ListValue_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ListValueDefaultTypeInternal _ListValue_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fstruct_2eproto[4];
-static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fstruct_2eproto[4];
+static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1];
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, _has_bits_),
@@ -93,12 +97,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _oneof_case_[0]),
~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_
- ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag,
- ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag,
- ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag,
- ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag,
- ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag,
- ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, kind_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _internal_metadata_),
@@ -108,18 +112,18 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, values_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 8, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse)},
{ 10, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct)},
{ 17, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Value)},
{ 30, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ListValue)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Struct_FieldsEntry_DoNotUse_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Value_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Struct_FieldsEntry_DoNotUse_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Value_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -140,19 +144,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto[] PROTOB
"rotobuf/types/known/structpb\370\001\001\242\002\003GPB\252\002\036"
"Google.Protobuf.WellKnownTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = {
- false, false, 638, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto",
- &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, nullptr, 0, 4,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = {
+ false, false, 638, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto,
+ "google/protobuf/struct.proto",
+ &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, nullptr, 0, 4,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fstruct_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fstruct_2eproto(&descriptor_table_google_2fprotobuf_2fstruct_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fstruct_2eproto(&descriptor_table_google_2fprotobuf_2fstruct_2eproto);
PROTOBUF_NAMESPACE_OPEN
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NullValue_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fstruct_2eproto);
@@ -177,7 +183,7 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom(const Struct_FieldsEntry_DoNotUse& o
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata Struct_FieldsEntry_DoNotUse::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[0]);
}
@@ -193,8 +199,8 @@ Struct::Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
fields_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
+ if (arena != nullptr && !is_message_owned) {
+ arena->OwnCustomDestructor(this, &Struct::ArenaDtor);
}
// @@protoc_insertion_point(arena_constructor:google.protobuf.Struct)
}
@@ -210,24 +216,22 @@ inline void Struct::SharedCtor() {
Struct::~Struct() {
// @@protoc_insertion_point(destructor:google.protobuf.Struct)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ ArenaDtor(this);
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Struct::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ fields_.Destruct();
}
void Struct::ArenaDtor(void* object) {
Struct* _this = reinterpret_cast< Struct* >(object);
- (void)_this;
- _this->fields_. ~MapField();
-}
-inline void Struct::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena) {
- if (arena != nullptr) {
- arena->OwnCustomDestructor(this, &Struct::ArenaDtor);
- }
+ _this->fields_.Destruct();
}
void Struct::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -243,11 +247,11 @@ void Struct::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Struct::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Struct::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// map<string, .google.protobuf.Value> fields = 1;
case 1:
@@ -293,48 +297,32 @@ uint8_t* Struct::_InternalSerialize(
// map<string, .google.protobuf.Value> fields = 1;
if (!this->_internal_fields().empty()) {
- typedef ::PROTOBUF_NAMESPACE_ID::Map< TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value >::const_pointer
- ConstPtr;
- typedef ConstPtr SortItem;
- typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less;
- struct Utf8Check {
- static void Check(ConstPtr p) {
- (void)p;
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- p->first.data(), static_cast<int>(p->first.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Struct.FieldsEntry.key");
- }
+ using MapType = ::_pb::Map<TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value>;
+ using WireHelper = Struct_FieldsEntry_DoNotUse::Funcs;
+ const auto& map_field = this->_internal_fields();
+ auto check_utf8 = [](const MapType::value_type& entry) {
+ (void)entry;
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
+ entry.first.data(), static_cast<int>(entry.first.length()),
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
+ "google.protobuf.Struct.FieldsEntry.key");
};
- if (stream->IsSerializationDeterministic() &&
- this->_internal_fields().size() > 1) {
- ::std::unique_ptr<SortItem[]> items(
- new SortItem[this->_internal_fields().size()]);
- typedef ::PROTOBUF_NAMESPACE_ID::Map< TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value >::size_type size_type;
- size_type n = 0;
- for (::PROTOBUF_NAMESPACE_ID::Map< TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value >::const_iterator
- it = this->_internal_fields().begin();
- it != this->_internal_fields().end(); ++it, ++n) {
- items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
- }
- ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
- for (size_type i = 0; i < n; i++) {
- target = Struct_FieldsEntry_DoNotUse::Funcs::InternalSerialize(1, items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second, target, stream);
- Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)]));
+ if (stream->IsSerializationDeterministic() && map_field.size() > 1) {
+ for (const auto& entry : ::_pbi::MapSorterPtr<MapType>(map_field)) {
+ target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream);
+ check_utf8(entry);
}
} else {
- for (::PROTOBUF_NAMESPACE_ID::Map< TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value >::const_iterator
- it = this->_internal_fields().begin();
- it != this->_internal_fields().end(); ++it) {
- target = Struct_FieldsEntry_DoNotUse::Funcs::InternalSerialize(1, it->first, it->second, target, stream);
- Utf8Check::Check(&(*it));
+ for (const auto& entry : map_field) {
+ target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream);
+ check_utf8(entry);
}
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -402,7 +390,7 @@ void Struct::InternalSwap(Struct* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Struct::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[1]);
}
@@ -428,7 +416,7 @@ void Value::set_allocated_struct_value(::PROTOBUF_NAMESPACE_ID::Struct* struct_v
clear_kind();
if (struct_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::Struct>::GetOwningArena(struct_value);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(struct_value);
if (message_arena != submessage_arena) {
struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, struct_value, submessage_arena);
@@ -443,7 +431,7 @@ void Value::set_allocated_list_value(::PROTOBUF_NAMESPACE_ID::ListValue* list_va
clear_kind();
if (list_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ListValue>::GetOwningArena(list_value);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(list_value);
if (message_arena != submessage_arena) {
list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, list_value, submessage_arena);
@@ -457,9 +445,6 @@ Value::Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Value)
}
Value::Value(const Value& from)
@@ -504,9 +489,11 @@ clear_has_kind();
Value::~Value() {
// @@protoc_insertion_point(destructor:google.protobuf.Value)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Value::SharedDtor() {
@@ -516,12 +503,6 @@ inline void Value::SharedDtor() {
}
}
-void Value::ArenaDtor(void* object) {
- Value* _this = reinterpret_cast< Value* >(object);
- (void)_this;
-}
-void Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -538,7 +519,7 @@ void Value::clear_kind() {
break;
}
case kStringValue: {
- kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ kind_.string_value_.Destroy();
break;
}
case kBoolValue: {
@@ -575,11 +556,11 @@ void Value::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// .google.protobuf.NullValue null_value = 1;
case 1:
@@ -602,9 +583,9 @@ const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
auto str = _internal_mutable_string_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Value.string_value"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Value.string_value"));
} else
goto handle_unusual;
continue;
@@ -664,14 +645,14 @@ uint8_t* Value::_InternalSerialize(
// .google.protobuf.NullValue null_value = 1;
if (_internal_has_null_value()) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
1, this->_internal_null_value(), target);
}
// double number_value = 2;
if (_internal_has_number_value()) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(2, this->_internal_number_value(), target);
+ target = ::_pbi::WireFormatLite::WriteDoubleToArray(2, this->_internal_number_value(), target);
}
// string string_value = 3;
@@ -687,27 +668,25 @@ uint8_t* Value::_InternalSerialize(
// bool bool_value = 4;
if (_internal_has_bool_value()) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_bool_value(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(4, this->_internal_bool_value(), target);
}
// .google.protobuf.Struct struct_value = 5;
if (_internal_has_struct_value()) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 5, _Internal::struct_value(this), target, stream);
+ InternalWriteMessage(5, _Internal::struct_value(this),
+ _Internal::struct_value(this).GetCachedSize(), target, stream);
}
// .google.protobuf.ListValue list_value = 6;
if (_internal_has_list_value()) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 6, _Internal::list_value(this), target, stream);
+ InternalWriteMessage(6, _Internal::list_value(this),
+ _Internal::list_value(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -726,7 +705,7 @@ size_t Value::ByteSizeLong() const {
// .google.protobuf.NullValue null_value = 1;
case kNullValue: {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_null_value());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_null_value());
break;
}
// double number_value = 2;
@@ -837,7 +816,7 @@ void Value::InternalSwap(Value* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Value::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[2]);
}
@@ -853,9 +832,6 @@ ListValue::ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
values_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue)
}
ListValue::ListValue(const ListValue& from)
@@ -870,21 +846,17 @@ inline void ListValue::SharedCtor() {
ListValue::~ListValue() {
// @@protoc_insertion_point(destructor:google.protobuf.ListValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ListValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void ListValue::ArenaDtor(void* object) {
- ListValue* _this = reinterpret_cast< ListValue* >(object);
- (void)_this;
-}
-void ListValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void ListValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -899,11 +871,11 @@ void ListValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* ListValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* ListValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.Value values = 1;
case 1:
@@ -948,15 +920,15 @@ uint8_t* ListValue::_InternalSerialize(
(void) cached_has_bits;
// repeated .google.protobuf.Value values = 1;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_values_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_values_size()); i < n; i++) {
+ const auto& repfield = this->_internal_values(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(1, this->_internal_values(i), target, stream);
+ InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1022,7 +994,7 @@ void ListValue::InternalSwap(ListValue* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ListValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[3]);
}
@@ -1030,16 +1002,20 @@ void ListValue::InternalSwap(ListValue* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Struct >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Value*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Value >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ListValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ListValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ListValue >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/struct.pb.h b/contrib/libs/protobuf/src/google/protobuf/struct.pb.h
index b5b4dae602..ccdb792184 100644
--- a/contrib/libs/protobuf/src/google/protobuf/struct.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/struct.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -46,14 +45,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto;
@@ -115,7 +106,7 @@ public:
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> SuperType;
Struct_FieldsEntry_DoNotUse();
- explicit constexpr Struct_FieldsEntry_DoNotUse(
+ explicit PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit Struct_FieldsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void MergeFrom(const Struct_FieldsEntry_DoNotUse& other);
@@ -126,6 +117,7 @@ public:
static bool ValidateValue(void*) { return true; }
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
+ friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
};
// -------------------------------------------------------------------
@@ -135,7 +127,7 @@ class PROTOBUF_EXPORT Struct final :
public:
inline Struct() : Struct(nullptr) {}
~Struct() override;
- explicit constexpr Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Struct(const Struct& from);
Struct(Struct&& from) noexcept
@@ -239,7 +231,6 @@ class PROTOBUF_EXPORT Struct final :
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -294,7 +285,7 @@ class PROTOBUF_EXPORT Value final :
public:
inline Value() : Value(nullptr) {}
~Value() override;
- explicit constexpr Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Value(const Value& from);
Value(Value&& from) noexcept
@@ -406,9 +397,6 @@ class PROTOBUF_EXPORT Value final :
protected:
explicit Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -561,7 +549,7 @@ class PROTOBUF_EXPORT ListValue final :
public:
inline ListValue() : ListValue(nullptr) {}
~ListValue() override;
- explicit constexpr ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ListValue(const ListValue& from);
ListValue(ListValue&& from) noexcept
@@ -663,9 +651,6 @@ class PROTOBUF_EXPORT ListValue final :
protected:
explicit ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -843,7 +828,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::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ kind_.string_value_.Destroy();
clear_has_kind();
}
}
@@ -856,9 +841,9 @@ inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) {
if (!_internal_has_string_value()) {
clear_kind();
set_has_string_value();
- kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ kind_.string_value_.InitDefault();
}
- kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ kind_.string_value_.Set( static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
}
inline TProtoStringType* Value::mutable_string_value() {
@@ -876,24 +861,23 @@ inline void Value::_internal_set_string_value(const TProtoStringType& value) {
if (!_internal_has_string_value()) {
clear_kind();
set_has_string_value();
- kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ kind_.string_value_.InitDefault();
}
- kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ kind_.string_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Value::_internal_mutable_string_value() {
if (!_internal_has_string_value()) {
clear_kind();
set_has_string_value();
- kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ kind_.string_value_.InitDefault();
}
- return kind_.string_value_.Mutable(
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return kind_.string_value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* 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_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return kind_.string_value_.Release();
} else {
return nullptr;
}
@@ -904,11 +888,7 @@ inline void Value::set_allocated_string_value(TProtoStringType* string_value) {
}
if (string_value != nullptr) {
set_has_string_value();
- kind_.string_value_.UnsafeSetDefault(string_value);
- ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaForAllocation();
- if (arena != nullptr) {
- arena->Own(string_value);
- }
+ kind_.string_value_.InitAllocated(string_value, GetArenaForAllocation());
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)
}
@@ -973,7 +953,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)
if (_internal_has_struct_value()) {
clear_has_kind();
- ::PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_;
+ ::PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_;
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
@@ -1047,7 +1027,7 @@ inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)
if (_internal_has_list_value()) {
clear_has_kind();
- ::PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_;
+ ::PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_;
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/common.h b/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
index 4a7036df17..45bb73a10b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
@@ -84,7 +84,7 @@ namespace internal {
// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
-#define GOOGLE_PROTOBUF_VERSION 3019000
+#define GOOGLE_PROTOBUF_VERSION 3020002
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
@@ -92,15 +92,15 @@ namespace internal {
// The minimum header version which works with the current version of
// the library. This constant should only be used by protoc's C++ code
// generator.
-static const int kMinHeaderVersionForLibrary = 3019000;
+static const int kMinHeaderVersionForLibrary = 3020000;
// The minimum protoc version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3019000
+#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3020000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
-static const int kMinHeaderVersionForProtoc = 3019000;
+static const int kMinHeaderVersionForProtoc = 3020000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc
index ca1f3863ac..200b0c696a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc
@@ -173,12 +173,13 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
// Add the requisite padding.
std::streamsize width = o.width(0);
- if (width > rep.size()) {
+ auto repSize = static_cast<std::streamsize>(rep.size());
+ if (width > repSize) {
if ((flags & std::ios::adjustfield) == std::ios::left) {
- rep.append(width - rep.size(), o.fill());
+ rep.append(width - repSize, o.fill());
} else {
- rep.insert(static_cast<TProtoStringType::size_type>(0),
- width - rep.size(), o.fill());
+ rep.insert(static_cast<TProtoStringType::size_type>(0), width - repSize,
+ o.fill());
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h b/contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h
index 7b44c9593f..94bc9c65fd 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h
@@ -37,6 +37,9 @@
#include <algorithm>
+// Must be last.
+#include <google/protobuf/port_def.inc> // NOLINT
+
namespace google {
namespace protobuf {
@@ -57,7 +60,7 @@ inline void STLStringResizeUninitializedAmortized(TProtoStringType* s,
const size_t cap = s->capacity();
if (new_size > cap) {
// Make sure to always grow by at least a factor of 2x.
- s->reserve(std::max(new_size, 2 * cap));
+ s->reserve(std::max<size_t>(new_size, 2 * cap));
}
STLStringResizeUninitialized(s, new_size);
}
@@ -82,4 +85,6 @@ inline char* string_as_array(TProtoStringType* str) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc> // NOLINT
+
#endif // GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc
index b72f10a3da..68efd15e1e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc
@@ -1405,7 +1405,7 @@ AlphaNum::AlphaNum(strings::Hex hex) {
// We accomplish minimum width by OR'ing in 0x10000 to the user's value,
// where 0x10000 is the smallest hex number that is as wide as the user
// asked for.
- uint64 mask = ((static_cast<uint64>(1) << (width - 1) * 4)) | value;
+ uint64 mask = (static_cast<uint64>(1) << ((width - 1) * 4)) | value;
static const char hexdigits[] = "0123456789abcdef";
do {
*--writer = hexdigits[value & 0xF];
diff --git a/contrib/libs/protobuf/src/google/protobuf/text_format.cc b/contrib/libs/protobuf/src/google/protobuf/text_format.cc
index 5b6eadfc19..706b58d8c7 100644
--- a/contrib/libs/protobuf/src/google/protobuf/text_format.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/text_format.cc
@@ -44,22 +44,21 @@
#include <limits>
#include <vector>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/any.h>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/any.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/io/strtod.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/io/strtod.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
@@ -276,6 +275,7 @@ class TextFormat::Parser::ParserImpl {
allow_partial_(allow_partial),
initial_recursion_limit_(recursion_limit),
recursion_limit_(recursion_limit),
+ had_silent_marker_(false),
had_errors_(false) {
// For backwards-compatibility with proto1, we need to allow the 'f' suffix
// for floats.
@@ -429,10 +429,11 @@ class TextFormat::Parser::ParserImpl {
TProtoStringType prefix_and_full_type_name =
StrCat(prefix, full_type_name);
DO(ConsumeBeforeWhitespace("]"));
- TryConsumeWhitespace(prefix_and_full_type_name, "Any");
+ TryConsumeWhitespace();
// ':' is optional between message labels and values.
- TryConsumeBeforeWhitespace(":");
- TryConsumeWhitespace(prefix_and_full_type_name, "Any");
+ if (TryConsumeBeforeWhitespace(":")) {
+ TryConsumeWhitespace();
+ }
TProtoStringType serialized_value;
const Descriptor* value_descriptor =
finder_ ? finder_->FindAnyType(*message, prefix, full_type_name)
@@ -462,7 +463,7 @@ class TextFormat::Parser::ParserImpl {
// Extension.
DO(ConsumeFullTypeName(&field_name));
DO(ConsumeBeforeWhitespace("]"));
- TryConsumeWhitespace(message->GetTypeName(), "Extension");
+ TryConsumeWhitespace();
field = finder_ ? finder_->FindExtension(message, field_name)
: DefaultFinderFindExtension(message, field_name);
@@ -482,7 +483,7 @@ class TextFormat::Parser::ParserImpl {
}
} else {
DO(ConsumeIdentifierBeforeWhitespace(&field_name));
- TryConsumeWhitespace(message->GetTypeName(), "Normal");
+ TryConsumeWhitespace();
arc_i32 field_number;
if (allow_field_number_ && safe_strto32(field_name, &field_number)) {
@@ -552,7 +553,7 @@ class TextFormat::Parser::ParserImpl {
// to be a message or the input is ill-formed.
bool skip;
if (TryConsumeBeforeWhitespace(":")) {
- TryConsumeWhitespace(message->GetTypeName(), "Unknown/Reserved");
+ TryConsumeWhitespace();
if (!LookingAt("{") && !LookingAt("<")) {
skip = SkipFieldValue();
} else {
@@ -593,7 +594,9 @@ class TextFormat::Parser::ParserImpl {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// ':' is optional here.
bool consumed_semicolon = TryConsumeBeforeWhitespace(":");
- TryConsumeWhitespace(message->GetTypeName(), "Normal");
+ if (consumed_semicolon) {
+ TryConsumeWhitespace();
+ }
if (consumed_semicolon && field->options().weak() &&
LookingAtType(io::Tokenizer::TYPE_STRING)) {
// we are getting a bytes string for a weak field.
@@ -608,7 +611,7 @@ class TextFormat::Parser::ParserImpl {
} else {
// ':' is required here.
DO(ConsumeBeforeWhitespace(":"));
- TryConsumeWhitespace(message->GetTypeName(), "Normal");
+ TryConsumeWhitespace();
}
if (field->is_repeated() && TryConsume("[")) {
@@ -659,15 +662,15 @@ class TextFormat::Parser::ParserImpl {
// Skips the next field including the field's name and value.
bool SkipField() {
+ TProtoStringType field_name;
if (TryConsume("[")) {
// Extension name or type URL.
- DO(ConsumeTypeUrlOrFullTypeName());
+ DO(ConsumeTypeUrlOrFullTypeName(&field_name));
DO(ConsumeBeforeWhitespace("]"));
} else {
- TProtoStringType field_name;
DO(ConsumeIdentifierBeforeWhitespace(&field_name));
}
- TryConsumeWhitespace("Unknown/Reserved", "n/a");
+ TryConsumeWhitespace();
// Try to guess the type of this field.
// If this field is not a message, there should be a ":" between the
@@ -676,7 +679,7 @@ class TextFormat::Parser::ParserImpl {
// If there is no ":" or there is a "{" or "<" after ":", this field has
// to be a message or the input is ill-formed.
if (TryConsumeBeforeWhitespace(":")) {
- TryConsumeWhitespace("Unknown/Reserved", "n/a");
+ TryConsumeWhitespace();
if (!LookingAt("{") && !LookingAt("<")) {
DO(SkipFieldValue());
} else {
@@ -1024,11 +1027,21 @@ class TextFormat::Parser::ParserImpl {
return true;
}
- bool ConsumeTypeUrlOrFullTypeName() {
- TProtoStringType discarded;
- DO(ConsumeIdentifier(&discarded));
- while (TryConsume(".") || TryConsume("/")) {
- DO(ConsumeIdentifier(&discarded));
+ bool ConsumeTypeUrlOrFullTypeName(TProtoStringType* name) {
+ DO(ConsumeIdentifier(name));
+ while (true) {
+ TProtoStringType connector;
+ if (TryConsume(".")) {
+ connector = ".";
+ } else if (TryConsume("/")) {
+ connector = "/";
+ } else {
+ break;
+ }
+ TProtoStringType part;
+ DO(ConsumeIdentifier(&part));
+ *name += connector;
+ *name += part;
}
return true;
}
@@ -1270,13 +1283,15 @@ class TextFormat::Parser::ParserImpl {
return result;
}
- bool TryConsumeWhitespace(const TProtoStringType& message_type,
- const char* field_type) {
+ bool TryConsumeWhitespace() {
+ had_silent_marker_ = false;
if (LookingAtType(io::Tokenizer::TYPE_WHITESPACE)) {
+ if (tokenizer_.current().text == " " DEBUG_STRING_SILENT_MARKER) {
+ had_silent_marker_ = true;
+ }
tokenizer_.Next();
return true;
}
-
return false;
}
@@ -1317,6 +1332,7 @@ class TextFormat::Parser::ParserImpl {
const bool allow_partial_;
const int initial_recursion_limit_;
int recursion_limit_;
+ bool had_silent_marker_;
bool had_errors_;
};
@@ -1348,10 +1364,10 @@ class TextFormat::Printer::TextGenerator
indent_level_(initial_indent_level),
initial_indent_level_(initial_indent_level) {}
- ~TextGenerator() {
+ ~TextGenerator() override {
// Only BackUp() if we're sure we've successfully called Next() at least
// once.
- if (!failed_ && buffer_size_ > 0) {
+ if (!failed_) {
output_->BackUp(buffer_size_);
}
}
@@ -1646,7 +1662,6 @@ bool TextFormat::Parser::MergeFromString(ConstStringParam input,
return Merge(&input_stream, output);
}
-
bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */,
Message* output,
ParserImpl* parser_impl) {
@@ -1695,7 +1710,6 @@ bool TextFormat::Parser::ParseFieldValueFromString(const TProtoStringType& input
return Parser().MergeFromString(input, output);
}
-
#undef DO
// ===========================================================================
diff --git a/contrib/libs/protobuf/src/google/protobuf/text_format.h b/contrib/libs/protobuf/src/google/protobuf/text_format.h
index 70c49f4ed1..17abe31ac6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/text_format.h
+++ b/contrib/libs/protobuf/src/google/protobuf/text_format.h
@@ -38,17 +38,19 @@
#ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__
#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__
+
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/message.h>
#include <google/protobuf/message_lite.h>
-#include <google/protobuf/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
diff --git a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc
index 6f39fd988f..5edd305857 100644
--- a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc
@@ -16,24 +16,28 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr Timestamp::Timestamp(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR Timestamp::Timestamp(
+ ::_pbi::ConstantInitialized)
: seconds_(arc_i64{0})
, nanos_(0){}
struct TimestampDefaultTypeInternal {
- constexpr TimestampDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR TimestampDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~TimestampDefaultTypeInternal() {}
union {
Timestamp _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT TimestampDefaultTypeInternal _Timestamp_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TimestampDefaultTypeInternal _Timestamp_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[1];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[1];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -45,12 +49,12 @@ const arc_ui32 TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] PROT
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, seconds_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, nanos_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Timestamp)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -61,19 +65,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PRO
"tobuf/types/known/timestamppb\370\001\001\242\002\003GPB\252\002"
"\036Google.Protobuf.WellKnownTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = {
- false, false, 239, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto",
- &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, nullptr, 0, 1,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = {
+ false, false, 239, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto,
+ "google/protobuf/timestamp.proto",
+ &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, nullptr, 0, 1,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftimestamp_2eproto(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftimestamp_2eproto(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -86,9 +92,6 @@ Timestamp::Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp)
}
Timestamp::Timestamp(const Timestamp& from)
@@ -109,21 +112,17 @@ inline void Timestamp::SharedCtor() {
Timestamp::~Timestamp() {
// @@protoc_insertion_point(destructor:google.protobuf.Timestamp)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Timestamp::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void Timestamp::ArenaDtor(void* object) {
- Timestamp* _this = reinterpret_cast< Timestamp* >(object);
- (void)_this;
-}
-void Timestamp::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Timestamp::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -140,11 +139,11 @@ void Timestamp::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Timestamp::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Timestamp::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int64 seconds = 1;
case 1:
@@ -194,17 +193,17 @@ uint8_t* Timestamp::_InternalSerialize(
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target);
+ target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target);
}
// int32 nanos = 2;
if (this->_internal_nanos() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -221,12 +220,12 @@ size_t Timestamp::ByteSizeLong() const {
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_seconds());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seconds());
}
// int32 nanos = 2;
if (this->_internal_nanos() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_nanos());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_nanos());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -283,7 +282,7 @@ void Timestamp::InternalSwap(Timestamp* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Timestamp::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[0]);
}
@@ -291,7 +290,8 @@ void Timestamp::InternalSwap(Timestamp* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Timestamp* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Timestamp >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Timestamp*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Timestamp >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Timestamp >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h
index 744cd9a2af..59af8ec76f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
@@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Timestamp final :
public:
inline Timestamp() : Timestamp(nullptr) {}
~Timestamp() override;
- explicit constexpr Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Timestamp(const Timestamp& from);
Timestamp(Timestamp&& from) noexcept
@@ -172,9 +163,6 @@ class PROTOBUF_EXPORT Timestamp final :
protected:
explicit Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
diff --git a/contrib/libs/protobuf/src/google/protobuf/type.pb.cc b/contrib/libs/protobuf/src/google/protobuf/type.pb.cc
index a12ad27b82..4c1363a8ef 100644
--- a/contrib/libs/protobuf/src/google/protobuf/type.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/type.pb.cc
@@ -16,32 +16,36 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr Type::Type(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR Type::Type(
+ ::_pbi::ConstantInitialized)
: fields_()
, oneofs_()
, options_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, source_context_(nullptr)
, syntax_(0)
{}
struct TypeDefaultTypeInternal {
- constexpr TypeDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR TypeDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~TypeDefaultTypeInternal() {}
union {
Type _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT TypeDefaultTypeInternal _Type_default_instance_;
-constexpr Field::Field(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TypeDefaultTypeInternal _Type_default_instance_;
+PROTOBUF_CONSTEXPR Field::Field(
+ ::_pbi::ConstantInitialized)
: options_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , json_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , default_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , json_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , default_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, kind_(0)
, cardinality_(0)
@@ -50,62 +54,62 @@ constexpr Field::Field(
, oneof_index_(0)
, packed_(false){}
struct FieldDefaultTypeInternal {
- constexpr FieldDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FieldDefaultTypeInternal() {}
union {
Field _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldDefaultTypeInternal _Field_default_instance_;
-constexpr Enum::Enum(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDefaultTypeInternal _Field_default_instance_;
+PROTOBUF_CONSTEXPR Enum::Enum(
+ ::_pbi::ConstantInitialized)
: enumvalue_()
, options_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, source_context_(nullptr)
, syntax_(0)
{}
struct EnumDefaultTypeInternal {
- constexpr EnumDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumDefaultTypeInternal() {}
union {
Enum _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumDefaultTypeInternal _Enum_default_instance_;
-constexpr EnumValue::EnumValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDefaultTypeInternal _Enum_default_instance_;
+PROTOBUF_CONSTEXPR EnumValue::EnumValue(
+ ::_pbi::ConstantInitialized)
: options_()
- , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, number_(0){}
struct EnumValueDefaultTypeInternal {
- constexpr EnumValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueDefaultTypeInternal() {}
union {
EnumValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumValueDefaultTypeInternal _EnumValue_default_instance_;
-constexpr Option::Option(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDefaultTypeInternal _EnumValue_default_instance_;
+PROTOBUF_CONSTEXPR Option::Option(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, value_(nullptr){}
struct OptionDefaultTypeInternal {
- constexpr OptionDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR OptionDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~OptionDefaultTypeInternal() {}
union {
Option _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT OptionDefaultTypeInternal _Option_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OptionDefaultTypeInternal _Option_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ftype_2eproto[5];
-static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[3];
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2ftype_2eproto[5];
+static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[3];
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -165,7 +169,7 @@ const arc_ui32 TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, name_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, value_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Type)},
{ 12, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Field)},
{ 28, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Enum)},
@@ -173,12 +177,12 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB
{ 48, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Option)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Type_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Field_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Enum_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumValue_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Option_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_Type_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Field_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Enum_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_EnumValue_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Option_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -223,23 +227,25 @@ const char descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto[] PROTOBUF
"buf/types/known/typepb\370\001\001\242\002\003GPB\252\002\036Google"
".Protobuf.WellKnownTypesb\006proto3"
;
-static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ftype_2eproto_deps[2] = {
+static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2ftype_2eproto_deps[2] = {
&::descriptor_table_google_2fprotobuf_2fany_2eproto,
&::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto,
};
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto = {
- false, false, 1592, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, "google/protobuf/type.proto",
- &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, descriptor_table_google_2fprotobuf_2ftype_2eproto_deps, 2, 5,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto = {
+ false, false, 1592, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto,
+ "google/protobuf/type.proto",
+ &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, descriptor_table_google_2fprotobuf_2ftype_2eproto_deps, 2, 5,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftype_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2ftype_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2ftype_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftype_2eproto(&descriptor_table_google_2fprotobuf_2ftype_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftype_2eproto(&descriptor_table_google_2fprotobuf_2ftype_2eproto);
PROTOBUF_NAMESPACE_OPEN
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Field_Kind_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftype_2eproto);
@@ -360,9 +366,6 @@ Type::Type(::PROTOBUF_NAMESPACE_ID::Arena* arena,
oneofs_(arena),
options_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Type)
}
Type::Type(const Type& from)
@@ -371,12 +374,12 @@ Type::Type(const Type& from)
oneofs_(from.oneofs_),
options_(from.options_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_source_context()) {
@@ -389,9 +392,9 @@ Type::Type(const Type& from)
}
inline void Type::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)),
@@ -401,23 +404,19 @@ name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlready
Type::~Type() {
// @@protoc_insertion_point(destructor:google.protobuf.Type)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Type::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete source_context_;
}
-void Type::ArenaDtor(void* object) {
- Type* _this = reinterpret_cast< Type* >(object);
- (void)_this;
-}
-void Type::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Type::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -440,19 +439,19 @@ void Type::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Type::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Type.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Type.name"));
} else
goto handle_unusual;
continue;
@@ -476,9 +475,9 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter
do {
ptr += 1;
auto str = _internal_add_oneofs();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Type.oneofs"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Type.oneofs"));
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
} else
@@ -554,11 +553,11 @@ uint8_t* Type::_InternalSerialize(
}
// repeated .google.protobuf.Field fields = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_fields_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_fields_size()); i < n; i++) {
+ const auto& repfield = this->_internal_fields(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_fields(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated string oneofs = 3;
@@ -572,30 +571,29 @@ uint8_t* Type::_InternalSerialize(
}
// repeated .google.protobuf.Option options = 4;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
+ const auto& repfield = this->_internal_options(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(4, this->_internal_options(i), target, stream);
+ InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream);
}
// .google.protobuf.SourceContext source_context = 5;
if (this->_internal_has_source_context()) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 5, _Internal::source_context(this), target, stream);
+ InternalWriteMessage(5, _Internal::source_context(this),
+ _Internal::source_context(this).GetCachedSize(), target, stream);
}
// .google.protobuf.Syntax syntax = 6;
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
6, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -649,7 +647,7 @@ size_t Type::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 6;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -709,7 +707,6 @@ void Type::InternalSwap(Type* other) {
oneofs_.InternalSwap(&other->oneofs_);
options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -722,7 +719,7 @@ void Type::InternalSwap(Type* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Type::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[0]);
}
@@ -738,45 +735,42 @@ Field::Field(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
options_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Field)
}
Field::Field(const Field& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
options_(from.options_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_type_url().empty()) {
- type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(),
+ type_url_.Set(from._internal_type_url(),
GetArenaForAllocation());
}
- json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_json_name().empty()) {
- json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(),
+ json_name_.Set(from._internal_json_name(),
GetArenaForAllocation());
}
- default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_default_value().empty()) {
- default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(),
+ default_value_.Set(from._internal_default_value(),
GetArenaForAllocation());
}
::memcpy(&kind_, &from.kind_,
@@ -786,21 +780,21 @@ Field::Field(const Field& from)
}
inline void Field::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&kind_) - reinterpret_cast<char*>(this)),
@@ -810,25 +804,21 @@ default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStri
Field::~Field() {
// @@protoc_insertion_point(destructor:google.protobuf.Field)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Field::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- default_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ type_url_.Destroy();
+ json_name_.Destroy();
+ default_value_.Destroy();
}
-void Field::ArenaDtor(void* object) {
- Field* _this = reinterpret_cast< Field* >(object);
- (void)_this;
-}
-void Field::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Field::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -850,11 +840,11 @@ void Field::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Field::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// .google.protobuf.Field.Kind kind = 1;
case 1:
@@ -886,9 +876,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.name"));
} else
goto handle_unusual;
continue;
@@ -896,9 +886,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
auto str = _internal_mutable_type_url();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.type_url"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.type_url"));
} else
goto handle_unusual;
continue;
@@ -935,9 +925,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
case 10:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) {
auto str = _internal_mutable_json_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.json_name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.json_name"));
} else
goto handle_unusual;
continue;
@@ -945,9 +935,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
case 11:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) {
auto str = _internal_mutable_default_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.default_value"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.default_value"));
} else
goto handle_unusual;
continue;
@@ -983,21 +973,21 @@ uint8_t* Field::_InternalSerialize(
// .google.protobuf.Field.Kind kind = 1;
if (this->_internal_kind() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
1, this->_internal_kind(), target);
}
// .google.protobuf.Field.Cardinality cardinality = 2;
if (this->_internal_cardinality() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
2, this->_internal_cardinality(), target);
}
// int32 number = 3;
if (this->_internal_number() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target);
}
// string name = 4;
@@ -1023,21 +1013,21 @@ uint8_t* Field::_InternalSerialize(
// int32 oneof_index = 7;
if (this->_internal_oneof_index() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_oneof_index(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(7, this->_internal_oneof_index(), target);
}
// bool packed = 8;
if (this->_internal_packed() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(8, this->_internal_packed(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(8, this->_internal_packed(), target);
}
// repeated .google.protobuf.Option options = 9;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
+ const auto& repfield = this->_internal_options(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(9, this->_internal_options(i), target, stream);
+ InternalWriteMessage(9, repfield, repfield.GetCachedSize(), target, stream);
}
// string json_name = 10;
@@ -1061,7 +1051,7 @@ uint8_t* Field::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1114,23 +1104,23 @@ size_t Field::ByteSizeLong() const {
// .google.protobuf.Field.Kind kind = 1;
if (this->_internal_kind() != 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_kind());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_kind());
}
// .google.protobuf.Field.Cardinality cardinality = 2;
if (this->_internal_cardinality() != 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_cardinality());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_cardinality());
}
// int32 number = 3;
if (this->_internal_number() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number());
}
// int32 oneof_index = 7;
if (this->_internal_oneof_index() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index());
}
// bool packed = 8;
@@ -1209,22 +1199,18 @@ void Field::InternalSwap(Field* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&type_url_, lhs_arena,
&other->type_url_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&json_name_, lhs_arena,
&other->json_name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&default_value_, lhs_arena,
&other->default_value_, rhs_arena
);
@@ -1237,7 +1223,7 @@ void Field::InternalSwap(Field* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Field::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[1]);
}
@@ -1265,9 +1251,6 @@ Enum::Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena,
enumvalue_(arena),
options_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Enum)
}
Enum::Enum(const Enum& from)
@@ -1275,12 +1258,12 @@ Enum::Enum(const Enum& from)
enumvalue_(from.enumvalue_),
options_(from.options_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_source_context()) {
@@ -1293,9 +1276,9 @@ Enum::Enum(const Enum& from)
}
inline void Enum::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)),
@@ -1305,23 +1288,19 @@ name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlready
Enum::~Enum() {
// @@protoc_insertion_point(destructor:google.protobuf.Enum)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Enum::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete source_context_;
}
-void Enum::ArenaDtor(void* object) {
- Enum* _this = reinterpret_cast< Enum* >(object);
- (void)_this;
-}
-void Enum::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Enum::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1343,19 +1322,19 @@ void Enum::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Enum::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Enum.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Enum.name"));
} else
goto handle_unusual;
continue;
@@ -1442,38 +1421,37 @@ uint8_t* Enum::_InternalSerialize(
}
// repeated .google.protobuf.EnumValue enumvalue = 2;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_enumvalue_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_enumvalue_size()); i < n; i++) {
+ const auto& repfield = this->_internal_enumvalue(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(2, this->_internal_enumvalue(i), target, stream);
+ InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
}
// repeated .google.protobuf.Option options = 3;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
+ const auto& repfield = this->_internal_options(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(3, this->_internal_options(i), target, stream);
+ InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream);
}
// .google.protobuf.SourceContext source_context = 4;
if (this->_internal_has_source_context()) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 4, _Internal::source_context(this), target, stream);
+ InternalWriteMessage(4, _Internal::source_context(this),
+ _Internal::source_context(this).GetCachedSize(), target, stream);
}
// .google.protobuf.Syntax syntax = 5;
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
5, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1519,7 +1497,7 @@ size_t Enum::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 5;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -1577,7 +1555,6 @@ void Enum::InternalSwap(Enum* other) {
enumvalue_.InternalSwap(&other->enumvalue_);
options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -1590,7 +1567,7 @@ void Enum::InternalSwap(Enum* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Enum::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[2]);
}
@@ -1606,21 +1583,18 @@ EnumValue::EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
options_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue)
}
EnumValue::EnumValue(const EnumValue& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
options_(from.options_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
number_ = from.number_;
@@ -1628,31 +1602,27 @@ EnumValue::EnumValue(const EnumValue& from)
}
inline void EnumValue::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
number_ = 0;
}
EnumValue::~EnumValue() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void EnumValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
}
-void EnumValue::ArenaDtor(void* object) {
- EnumValue* _this = reinterpret_cast< EnumValue* >(object);
- (void)_this;
-}
-void EnumValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void EnumValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1669,19 +1639,19 @@ void EnumValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* EnumValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumValue.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.EnumValue.name"));
} else
goto handle_unusual;
continue;
@@ -1748,19 +1718,19 @@ uint8_t* EnumValue::_InternalSerialize(
// int32 number = 2;
if (this->_internal_number() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target);
}
// repeated .google.protobuf.Option options = 3;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
+ const auto& repfield = this->_internal_options(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(3, this->_internal_options(i), target, stream);
+ InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1791,7 +1761,7 @@ size_t EnumValue::ByteSizeLong() const {
// int32 number = 2;
if (this->_internal_number() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -1844,7 +1814,6 @@ void EnumValue::InternalSwap(EnumValue* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -1852,7 +1821,7 @@ void EnumValue::InternalSwap(EnumValue* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[3]);
}
@@ -1878,20 +1847,17 @@ Option::Option(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Option)
}
Option::Option(const Option& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
if (from._internal_has_value()) {
@@ -1903,32 +1869,28 @@ Option::Option(const Option& from)
}
inline void Option::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_ = nullptr;
}
Option::~Option() {
// @@protoc_insertion_point(destructor:google.protobuf.Option)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Option::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
if (this != internal_default_instance()) delete value_;
}
-void Option::ArenaDtor(void* object) {
- Option* _this = reinterpret_cast< Option* >(object);
- (void)_this;
-}
-void Option::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Option::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1947,19 +1909,19 @@ void Option::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Option::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Option::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Option.name"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Option.name"));
} else
goto handle_unusual;
continue;
@@ -2012,14 +1974,13 @@ uint8_t* Option::_InternalSerialize(
// .google.protobuf.Any value = 2;
if (this->_internal_has_value()) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 2, _Internal::value(this), target, stream);
+ InternalWriteMessage(2, _Internal::value(this),
+ _Internal::value(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -2096,7 +2057,6 @@ void Option::InternalSwap(Option* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
@@ -2104,7 +2064,7 @@ void Option::InternalSwap(Option* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Option::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[4]);
}
@@ -2112,19 +2072,24 @@ void Option::InternalSwap(Option* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Type* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Type >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Type*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Type >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Type >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Field* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Field >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Field*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Field >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Field >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Enum* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Enum >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Enum*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Enum >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Enum >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumValue >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Option* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Option >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Option*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Option >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Option >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/type.pb.h b/contrib/libs/protobuf/src/google/protobuf/type.pb.h
index c3d703ba40..233395d293 100644
--- a/contrib/libs/protobuf/src/google/protobuf/type.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/type.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -45,14 +44,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[5]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto;
@@ -183,7 +174,7 @@ class PROTOBUF_EXPORT Type final :
public:
inline Type() : Type(nullptr) {}
~Type() override;
- explicit constexpr Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Type(const Type& from);
Type(Type&& from) noexcept
@@ -285,9 +276,6 @@ class PROTOBUF_EXPORT Type final :
protected:
explicit Type(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -431,7 +419,7 @@ class PROTOBUF_EXPORT Field final :
public:
inline Field() : Field(nullptr) {}
~Field() override;
- explicit constexpr Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Field(const Field& from);
Field(Field&& from) noexcept
@@ -533,9 +521,6 @@ class PROTOBUF_EXPORT Field final :
protected:
explicit Field(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -803,7 +788,7 @@ class PROTOBUF_EXPORT Enum final :
public:
inline Enum() : Enum(nullptr) {}
~Enum() override;
- explicit constexpr Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Enum(const Enum& from);
Enum(Enum&& from) noexcept
@@ -905,9 +890,6 @@ class PROTOBUF_EXPORT Enum final :
protected:
explicit Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1025,7 +1007,7 @@ class PROTOBUF_EXPORT EnumValue final :
public:
inline EnumValue() : EnumValue(nullptr) {}
~EnumValue() override;
- explicit constexpr EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumValue(const EnumValue& from);
EnumValue(EnumValue&& from) noexcept
@@ -1127,9 +1109,6 @@ class PROTOBUF_EXPORT EnumValue final :
protected:
explicit EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1207,7 +1186,7 @@ class PROTOBUF_EXPORT Option final :
public:
inline Option() : Option(nullptr) {}
~Option() override;
- explicit constexpr Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Option(const Option& from);
Option(Option&& from) noexcept
@@ -1309,9 +1288,6 @@ class PROTOBUF_EXPORT Option final :
protected:
explicit Option(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1394,7 +1370,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Type::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Type.name)
}
inline TProtoStringType* Type::mutable_name() {
@@ -1407,15 +1383,15 @@ inline const TProtoStringType& Type::_internal_name() const {
}
inline void Type::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Type::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Type::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Type.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Type::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -1423,11 +1399,10 @@ inline void Type::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)
@@ -1659,8 +1634,7 @@ inline void Type::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
}
if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
- ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@@ -1770,7 +1744,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Field::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.name)
}
inline TProtoStringType* Field::mutable_name() {
@@ -1783,15 +1757,15 @@ inline const TProtoStringType& Field::_internal_name() const {
}
inline void Field::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Field::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Field::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -1799,11 +1773,10 @@ inline void Field::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)
@@ -1821,7 +1794,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Field::set_type_url(ArgT0&& arg0, ArgT... args) {
- type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.type_url)
}
inline TProtoStringType* Field::mutable_type_url() {
@@ -1834,15 +1807,15 @@ inline const TProtoStringType& Field::_internal_type_url() const {
}
inline void Field::_internal_set_type_url(const TProtoStringType& value) {
- type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_type_url() {
- return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return type_url_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Field::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.type_url)
- return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return type_url_.Release();
}
inline void Field::set_allocated_type_url(TProtoStringType* type_url) {
if (type_url != nullptr) {
@@ -1850,11 +1823,10 @@ inline void Field::set_allocated_type_url(TProtoStringType* type_url) {
} else {
}
- type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url,
- GetArenaForAllocation());
+ type_url_.SetAllocated(type_url, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (type_url_.IsDefault()) {
+ type_url_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)
@@ -1952,7 +1924,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Field::set_json_name(ArgT0&& arg0, ArgT... args) {
- json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)
}
inline TProtoStringType* Field::mutable_json_name() {
@@ -1965,15 +1937,15 @@ inline const TProtoStringType& Field::_internal_json_name() const {
}
inline void Field::_internal_set_json_name(const TProtoStringType& value) {
- json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ json_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_json_name() {
- return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return json_name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Field::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.json_name)
- return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return json_name_.Release();
}
inline void Field::set_allocated_json_name(TProtoStringType* json_name) {
if (json_name != nullptr) {
@@ -1981,11 +1953,10 @@ inline void Field::set_allocated_json_name(TProtoStringType* json_name) {
} else {
}
- json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name,
- GetArenaForAllocation());
+ json_name_.SetAllocated(json_name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (json_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (json_name_.IsDefault()) {
+ json_name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)
@@ -2003,7 +1974,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Field::set_default_value(ArgT0&& arg0, ArgT... args) {
- default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.default_value)
}
inline TProtoStringType* Field::mutable_default_value() {
@@ -2016,15 +1987,15 @@ inline const TProtoStringType& Field::_internal_default_value() const {
}
inline void Field::_internal_set_default_value(const TProtoStringType& value) {
- default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ default_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_default_value() {
- return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return default_value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Field::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.default_value)
- return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return default_value_.Release();
}
inline void Field::set_allocated_default_value(TProtoStringType* default_value) {
if (default_value != nullptr) {
@@ -2032,11 +2003,10 @@ inline void Field::set_allocated_default_value(TProtoStringType* default_value)
} else {
}
- default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value,
- GetArenaForAllocation());
+ default_value_.SetAllocated(default_value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (default_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (default_value_.IsDefault()) {
+ default_value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)
@@ -2058,7 +2028,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Enum::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Enum.name)
}
inline TProtoStringType* Enum::mutable_name() {
@@ -2071,15 +2041,15 @@ inline const TProtoStringType& Enum::_internal_name() const {
}
inline void Enum::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Enum::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Enum::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Enum.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Enum::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -2087,11 +2057,10 @@ inline void Enum::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)
@@ -2248,8 +2217,7 @@ inline void Enum::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
}
if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
- ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@@ -2299,7 +2267,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void EnumValue::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name)
}
inline TProtoStringType* EnumValue::mutable_name() {
@@ -2312,15 +2280,15 @@ inline const TProtoStringType& EnumValue::_internal_name() const {
}
inline void EnumValue::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* EnumValue::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* EnumValue::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void EnumValue::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -2328,11 +2296,10 @@ inline void EnumValue::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)
@@ -2414,7 +2381,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Option::set_name(ArgT0&& arg0, ArgT... args) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Option.name)
}
inline TProtoStringType* Option::mutable_name() {
@@ -2427,15 +2394,15 @@ inline const TProtoStringType& Option::_internal_name() const {
}
inline void Option::_internal_set_name(const TProtoStringType& value) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Option::_internal_mutable_name() {
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Option::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Option.name)
- return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return name_.Release();
}
inline void Option::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
@@ -2443,11 +2410,10 @@ inline void Option::set_allocated_name(TProtoStringType* name) {
} else {
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)
@@ -2524,8 +2490,7 @@ inline void Option::set_allocated_value(::PROTOBUF_NAMESPACE_ID::Any* value) {
}
if (value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
- ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value));
if (message_arena != submessage_arena) {
value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
diff --git a/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc b/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc
index 5715434b0f..2d5d94990d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc
@@ -36,17 +36,19 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_tctable_decl.h>
#include <google/protobuf/generated_message_tctable_impl.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/stubs/stl_util.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -238,6 +240,20 @@ bool UnknownFieldSet::ParseFromArray(const void* data, int size) {
return ParseFromZeroCopyStream(&input);
}
+bool UnknownFieldSet::SerializeToString(TProtoStringType* output) const {
+ const size_t size =
+ google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(*this);
+ STLStringResizeUninitializedAmortized(output, size);
+ google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ *this, reinterpret_cast<uint8_t*>(const_cast<char*>(output->data())));
+ return true;
+}
+
+bool UnknownFieldSet::SerializeToCodedStream(
+ io::CodedOutputStream* output) const {
+ google::protobuf::internal::WireFormat::SerializeUnknownFields(*this, output);
+ return !output->HadError();
+}
void UnknownField::Delete() {
switch (type()) {
case UnknownField::TYPE_LENGTH_DELIMITED:
diff --git a/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h b/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h
index bfe16d6d7b..d43d9c81bb 100644
--- a/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h
+++ b/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h
@@ -38,6 +38,7 @@
#ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
#define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
+
#include <assert.h>
#include <string>
@@ -45,12 +46,13 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/message_lite.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
#ifdef SWIG
@@ -172,6 +174,9 @@ class PROTOBUF_EXPORT UnknownFieldSet {
template <typename MessageType>
bool MergeFromMessage(const MessageType& message);
+ // Serialization.
+ bool SerializeToString(TProtoStringType* output) const;
+ bool SerializeToCodedStream(io::CodedOutputStream* output) const;
static const UnknownFieldSet& default_instance();
private:
@@ -259,15 +264,6 @@ class PROTOBUF_EXPORT UnknownField {
inline TProtoStringType* mutable_length_delimited();
inline UnknownFieldSet* mutable_group();
- // Serialization API.
- // These methods can take advantage of the underlying implementation and may
- // archieve a better performance than using getters to retrieve the data and
- // do the serialization yourself.
- void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const {
- output->SetCur(InternalSerializeLengthDelimitedNoTag(output->Cur(),
- output->EpsCopy()));
- }
-
inline size_t GetLengthDelimitedSize() const;
uint8_t* InternalSerializeLengthDelimitedNoTag(
uint8_t* target, io::EpsCopyOutputStream* stream) const;
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.h b/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.h
index d3f7dbe8ad..78625cf2f1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.h
@@ -41,6 +41,7 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h b/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h
index f14bbcca98..0584f1eade 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h
@@ -33,12 +33,15 @@
#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
#define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
+
#include <cstdint>
#include <map>
#include <string>
#include <vector>
#include <google/protobuf/stubs/common.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.cc b/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.cc
index 32db742a2e..17f3d19f1e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.cc
@@ -32,8 +32,8 @@
#include <cstdint>
-#include <google/protobuf/message.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/message.h>
#include <google/protobuf/stubs/map_util.h>
// Must be included last.
@@ -339,7 +339,7 @@ void FieldMaskTree::AddPath(const TProtoStringType& path) {
return;
}
Node*& child = node->children[node_name];
- if (child == NULL) {
+ if (child == nullptr) {
new_branch = true;
child = new Node();
}
@@ -423,7 +423,7 @@ void FieldMaskTree::IntersectPath(const TProtoStringType& path, FieldMaskTree* o
return;
}
const Node* result = FindPtrOrNull(node->children, node_name);
- if (result == NULL) {
+ if (result == nullptr) {
// No intersection found.
return;
}
@@ -459,7 +459,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source,
const TProtoStringType& field_name = it->first;
const Node* child = it->second;
const FieldDescriptor* field = descriptor->FindFieldByName(field_name);
- if (field == NULL) {
+ if (field == nullptr) {
GOOGLE_LOG(ERROR) << "Cannot find field \"" << field_name << "\" in message "
<< descriptor->full_name();
continue;
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.h b/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.h
index bdfc92c440..10a5eb2dbb 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.h
@@ -37,8 +37,8 @@
#include <string>
#include <google/protobuf/field_mask.pb.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/descriptor.h>
// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -96,8 +96,9 @@ class PROTOBUF_EXPORT FieldMaskUtil {
template <typename T>
static bool IsValidFieldMask(const FieldMask& mask) {
for (int i = 0; i < mask.paths_size(); ++i) {
- if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), nullptr))
+ if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), nullptr)) {
return false;
+ }
}
return true;
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h
index 9dcdfb8ad7..e7b8f4483f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
#include <cstdint>
@@ -98,4 +98,4 @@ const char kOptionJspbMessageId[] = "jspb.message_id";
} // namespace util
} // namespace protobuf
} // namespace google
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc
index 6cff38a216..9c615a083f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc
@@ -37,9 +37,9 @@
#include <google/protobuf/struct.pb.h>
#include <google/protobuf/type.pb.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/mathutil.h>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h
index 0a5bdd74af..bef9e389f2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
#include <cstdint>
#include <string>
@@ -40,6 +40,7 @@
#include <google/protobuf/stubs/statusor.h>
#include <google/protobuf/stubs/strutil.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -215,4 +216,4 @@ class PROTOBUF_EXPORT DataPiece {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
index 0cb3491a41..e161cb806f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
#include <cstdint>
#include <functional>
@@ -38,12 +38,12 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/util/internal/type_info.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/util/internal/datapiece.h>
#include <google/protobuf/util/internal/object_writer.h>
+#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/util/type_resolver.h>
-#include <google/protobuf/stubs/strutil.h>
// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -81,7 +81,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
const google::protobuf::Type& type,
ObjectWriter* ow);
- virtual ~DefaultValueObjectWriter();
+ ~DefaultValueObjectWriter() override;
// ObjectWriter methods.
DefaultValueObjectWriter* StartObject(StringPiece name) override;
@@ -329,4 +329,4 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h
index 745b66a952..8c9c501682 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
#include <algorithm>
#include <memory>
@@ -39,8 +39,8 @@
#include <google/protobuf/stubs/callback.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/util/internal/location_tracker.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/internal/location_tracker.h>
// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -106,4 +106,4 @@ class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc
index 94d2738cf6..4dd5145b47 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc
@@ -30,9 +30,9 @@
#include <google/protobuf/util/internal/field_mask_utility.h>
-#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/status_macros.h>
// Must be included last.
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h
index 5019460dc6..288aa7a15b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h
@@ -30,8 +30,8 @@
// FieldMask related utility methods.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
#include <functional>
#include <stack>
@@ -71,4 +71,4 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths,
} // namespace protobuf
} // namespace google
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h
index 98ae79b718..b70190244f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
#include <cstdint>
@@ -95,4 +95,4 @@ class JsonEscaping {
} // namespace protobuf
} // namespace google
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc
index c40e582e32..b179899f4d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -38,8 +38,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/internal/utility.h>
-#include <google/protobuf/util/internal/json_escaping.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/internal/json_escaping.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
index b5520d300a..4eb5587f29 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
@@ -28,16 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__
#include <cstdint>
#include <memory>
#include <string>
#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/util/internal/structured_objectwriter.h>
#include <google/protobuf/stubs/bytestream.h>
+#include <google/protobuf/util/internal/structured_objectwriter.h>
// clang-format off
#include <google/protobuf/port_def.inc>
@@ -111,7 +111,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
}
}
}
- virtual ~JsonObjectWriter();
+ ~JsonObjectWriter() override;
// ObjectWriter methods.
JsonObjectWriter* StartObject(StringPiece name) override;
@@ -275,4 +275,4 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc
index 62d2a8fe9b..880c6bb0bc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc
@@ -485,7 +485,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() {
}
GOOGLE_DCHECK_EQ('\\', p_.data()[0]);
GOOGLE_DCHECK_EQ('u', p_.data()[1]);
- uint32 code = 0;
+ arc_ui32 code = 0;
for (int i = 2; i < kUnicodeEscapedLength; ++i) {
if (!isxdigit(p_.data()[i])) {
return ReportFailure("Invalid escape sequence.",
@@ -505,7 +505,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() {
}
} else if (p_.data()[kUnicodeEscapedLength] == '\\' &&
p_.data()[kUnicodeEscapedLength + 1] == 'u') {
- uint32 low_code = 0;
+ arc_ui32 low_code = 0;
for (int i = kUnicodeEscapedLength + 2; i < 2 * kUnicodeEscapedLength;
++i) {
if (!isxdigit(p_.data()[i])) {
@@ -626,7 +626,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {
return status;
}
- // Positive non-floating point number, parse as a uint64.
+ // Positive non-floating point number, parse as a arc_ui64.
if (!negative) {
// Octal/Hex numbers are not valid JSON values.
if (number.length() >= 2 && number[0] == '0') {
@@ -654,7 +654,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {
"Octal/hex numbers are not valid JSON values.",
ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES);
}
- // Negative non-floating point number, parse as an int64.
+ // Negative non-floating point number, parse as an arc_i64.
if (safe_strto64(number, &result->int_val)) {
result->type = NumberResult::INT;
p_.remove_prefix(index);
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h
index 1230f6e6e8..0a0c6823a4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
#include <cstdint>
#include <stack>
@@ -40,6 +40,7 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/status.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -346,4 +347,4 @@ class PROTOBUF_EXPORT JsonStreamParser {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h
index 9ffe163609..2a67a82a0d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h
@@ -28,13 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
#include <string>
#include <google/protobuf/stubs/common.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -66,4 +67,4 @@ class PROTOBUF_EXPORT LocationTrackerInterface {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h
index 0cd65c87b5..ff99d04b89 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
#include <string>
@@ -61,4 +61,4 @@ class ObjectLocationTracker : public LocationTrackerInterface {
} // namespace protobuf
} // namespace google
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h
index de548c1d0a..fc7672e5fa 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/status.h>
@@ -82,4 +82,4 @@ class PROTOBUF_EXPORT ObjectSource {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h
index 69b692979c..f265386e75 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__
#include <cstdint>
@@ -148,4 +148,4 @@ class PROTOBUF_EXPORT ObjectWriter {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc
index c39ff9f0e2..40cbe18bfe 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc
@@ -33,19 +33,21 @@
#include <cstdint>
#include <functional>
#include <stack>
+#include <unordered_set>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/util/internal/field_mask_utility.h>
-#include <google/protobuf/util/internal/object_location_tracker.h>
-#include <google/protobuf/util/internal/constants.h>
-#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/statusor.h>
#include <google/protobuf/stubs/time.h>
+#include <google/protobuf/util/internal/constants.h>
+#include <google/protobuf/util/internal/field_mask_utility.h>
+#include <google/protobuf/util/internal/object_location_tracker.h>
+#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/map_util.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -269,9 +271,9 @@ inline util::Status WriteString(int field_number, const DataPiece& data,
}
// Given a google::protobuf::Type, returns the set of all required fields.
-std::set<const google::protobuf::Field*> GetRequiredFields(
+std::unordered_set<const google::protobuf::Field*> GetRequiredFields(
const google::protobuf::Type& type) {
- std::set<const google::protobuf::Field*> required;
+ std::unordered_set<const google::protobuf::Field*> required;
for (int i = 0; i < type.fields_size(); i++) {
const google::protobuf::Field& field = type.fields(i);
if (field.cardinality() == google::protobuf::Field::CARDINALITY_REQUIRED) {
@@ -346,7 +348,7 @@ ProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() {
if (!proto3_) {
// Calls the registered error listener for any required field(s) not yet
// seen.
- for (std::set<const google::protobuf::Field*>::iterator it =
+ for (std::unordered_set<const google::protobuf::Field*>::iterator it =
required_fields_.begin();
it != required_fields_.end(); ++it) {
ow_->MissingField(ow_->use_json_name_in_missing_fields_
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h
index 6ecabb428b..a4d0b1f67e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h
@@ -28,12 +28,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTO_WRITER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTO_WRITER_H__
#include <cstdint>
#include <deque>
#include <string>
+#include <unordered_set>
#include <vector>
#include <google/protobuf/stubs/common.h>
@@ -41,13 +42,13 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/util/internal/type_info.h>
+#include <google/protobuf/stubs/bytestream.h>
+#include <google/protobuf/stubs/status.h>
#include <google/protobuf/util/internal/datapiece.h>
#include <google/protobuf/util/internal/error_listener.h>
#include <google/protobuf/util/internal/structured_objectwriter.h>
+#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/type_resolver.h>
-#include <google/protobuf/stubs/bytestream.h>
-#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/hash.h>
#include <google/protobuf/stubs/status.h>
@@ -235,7 +236,7 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
// size_index_ : index into ProtoWriter::size_insert_
// for later insertion of serialized message length.
const google::protobuf::Type& type_;
- std::set<const google::protobuf::Field*> required_fields_;
+ std::unordered_set<const google::protobuf::Field*> required_fields_;
const int size_index_;
// Tracks position in repeated fields, needed for LocationTrackerInterface.
@@ -385,4 +386,4 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTO_WRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc
index 8a04f7927f..a51650c3a9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -36,7 +36,6 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
@@ -44,19 +43,22 @@
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/util/internal/field_mask_utility.h>
-#include <google/protobuf/util/internal/constants.h>
-#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/time.h>
+#include <google/protobuf/util/internal/constants.h>
+#include <google/protobuf/util/internal/field_mask_utility.h>
+#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/status_macros.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -782,7 +784,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField(
}
case google::protobuf::Field::TYPE_INT64: {
stream_->ReadVarint64(&buffer64);
- ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
+ ow->RenderInt64(field_name, bit_cast<arc_i64>(buffer64));
break;
}
case google::protobuf::Field::TYPE_UINT32: {
@@ -792,7 +794,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField(
}
case google::protobuf::Field::TYPE_UINT64: {
stream_->ReadVarint64(&buffer64);
- ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
+ ow->RenderUint64(field_name, bit_cast<arc_ui64>(buffer64));
break;
}
case google::protobuf::Field::TYPE_SINT32: {
@@ -812,7 +814,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField(
}
case google::protobuf::Field::TYPE_SFIXED64: {
stream_->ReadLittleEndian64(&buffer64);
- ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
+ ow->RenderInt64(field_name, bit_cast<arc_i64>(buffer64));
break;
}
case google::protobuf::Field::TYPE_FIXED32: {
@@ -822,7 +824,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField(
}
case google::protobuf::Field::TYPE_FIXED64: {
stream_->ReadLittleEndian64(&buffer64);
- ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
+ ow->RenderUint64(field_name, bit_cast<arc_ui64>(buffer64));
break;
}
case google::protobuf::Field::TYPE_FLOAT: {
@@ -1096,11 +1098,11 @@ const TProtoStringType FormatNanos(arc_ui32 nanos, bool with_trailing_zeros) {
return with_trailing_zeros ? ".000" : "";
}
- const char* format = (nanos % 1000 != 0) ? "%.9f"
- : (nanos % 1000000 != 0) ? "%.6f"
- : "%.3f";
- TProtoStringType formatted =
- StringPrintf(format, static_cast<double>(nanos) / kNanosPerSecond);
+ const int precision = (nanos % 1000 != 0) ? 9
+ : (nanos % 1000000 != 0) ? 6
+ : 3;
+ TProtoStringType formatted = StringPrintf(
+ "%.*f", precision, static_cast<double>(nanos) / kNanosPerSecond);
// remove the leading 0 before decimal.
return formatted.substr(1);
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h
index 0a853cdc0e..6be281e291 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__
#include <cstdint>
#include <functional>
@@ -40,16 +40,17 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/type.pb.h>
-#include <google/protobuf/util/internal/type_info.h>
+#include <google/protobuf/stubs/statusor.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/util/internal/object_source.h>
#include <google/protobuf/util/internal/object_writer.h>
+#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/type_resolver.h>
-#include <google/protobuf/stubs/statusor.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/hash.h>
#include <google/protobuf/stubs/status.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -325,4 +326,4 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc
index 6e96598d0d..769099c503 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -38,17 +38,18 @@
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/util/internal/field_mask_utility.h>
-#include <google/protobuf/util/internal/object_location_tracker.h>
-#include <google/protobuf/util/internal/constants.h>
-#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/statusor.h>
#include <google/protobuf/stubs/time.h>
+#include <google/protobuf/util/internal/constants.h>
+#include <google/protobuf/util/internal/field_mask_utility.h>
+#include <google/protobuf/util/internal/object_location_tracker.h>
+#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/map_util.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -56,9 +57,9 @@ namespace protobuf {
namespace util {
namespace converter {
+using util::Status;
using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
using std::placeholders::_1;
-using util::Status;
ProtoStreamObjectWriter::ProtoStreamObjectWriter(
@@ -139,7 +140,7 @@ Status GetNanosFromStringPiece(StringPiece s_nanos,
}
arc_i32 i_nanos = 0;
// 's_nanos' contains fractional seconds -- i.e. 'nanos' is equal to
- // "0." + s_nanos.ToString() seconds. An int32 is used for the
+ // "0." + s_nanos.ToString() seconds. An arc_i32 is used for the
// conversion to 'nanos', rather than a double, so that there is no
// loss of precision.
if (!s_nanos.empty() && !safe_strto32(s_nanos, &i_nanos)) {
@@ -158,7 +159,7 @@ Status GetNanosFromStringPiece(StringPiece s_nanos,
// point in "0." + s_nanos.ToString()
arc_i32 scale = num_leading_zeros + s_nanos.size();
// 'conversion' converts i_nanos into nanoseconds.
- // conversion = kNanosPerSecond / static_cast<int32>(std::pow(10, scale))
+ // conversion = kNanosPerSecond / static_cast<arc_i32>(std::pow(10, scale))
// For efficiency, we precompute the conversion factor.
arc_i32 conversion = 0;
switch (scale) {
@@ -1031,8 +1032,8 @@ Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow,
StringPiece value(data.str());
- int64 seconds;
- int32 nanos;
+ arc_i64 seconds;
+ arc_i32 nanos;
if (!::google::protobuf::internal::ParseTime(value.ToString(), &seconds,
&nanos)) {
return util::InvalidArgumentError(StrCat("Invalid time format: ", value));
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h
index d70fa425ea..0ea06c682d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__
#include <deque>
#include <string>
@@ -41,16 +41,17 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/util/internal/type_info.h>
+#include <google/protobuf/stubs/bytestream.h>
+#include <google/protobuf/stubs/status.h>
#include <google/protobuf/util/internal/datapiece.h>
#include <google/protobuf/util/internal/error_listener.h>
#include <google/protobuf/util/internal/proto_writer.h>
#include <google/protobuf/util/internal/structured_objectwriter.h>
+#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/type_resolver.h>
-#include <google/protobuf/stubs/bytestream.h>
-#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/hash.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -449,4 +450,4 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h
index 01cbb9e1ac..f6f7c89e57 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__
#include <memory>
@@ -37,6 +37,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/internal/object_writer.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -57,7 +58,7 @@ namespace converter {
// Derived classes could be thread-unsafe.
class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
public:
- virtual ~StructuredObjectWriter() {}
+ ~StructuredObjectWriter() override {}
protected:
// A base element class for subclasses to extend, makes tracking state easier.
@@ -117,4 +118,4 @@ class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc
index 6a4ea2a768..f1bd827a2b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc
@@ -35,10 +35,10 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/type.pb.h>
-#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/statusor.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/status.h>
@@ -54,7 +54,7 @@ class TypeInfoForTypeResolver : public TypeInfo {
explicit TypeInfoForTypeResolver(TypeResolver* type_resolver)
: type_resolver_(type_resolver) {}
- virtual ~TypeInfoForTypeResolver() {
+ ~TypeInfoForTypeResolver() override {
DeleteCachedTypes(&cached_types_);
DeleteCachedTypes(&cached_enums_);
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h
index d8d679e1fe..257df5bad6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h
@@ -28,14 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_H__
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/type.pb.h>
-#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/stubs/statusor.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/stubs/status.h>
// Must be included last.
@@ -94,4 +94,4 @@ class PROTOBUF_EXPORT TypeInfo {
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc
index 3c1ee570c7..d2d650b32c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc
@@ -41,8 +41,8 @@
#include <google/protobuf/wrappers.pb.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/stubs/map_util.h>
#include <util/string/util.h>
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h
index 223e635902..40ae5ae566 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h
@@ -28,8 +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.
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__
#include <cstdint>
#include <memory>
@@ -201,4 +201,4 @@ PROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value);
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/json_util.cc b/contrib/libs/protobuf/src/google/protobuf/util/json_util.cc
index d96bd8e17e..1ce88be784 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/json_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/json_util.cc
@@ -218,7 +218,7 @@ util::Status JsonToBinaryString(TypeResolver* resolver,
namespace {
const char* kTypeUrlPrefix = "type.googleapis.com";
-TypeResolver* generated_type_resolver_ = NULL;
+TypeResolver* generated_type_resolver_ = nullptr;
PROTOBUF_NAMESPACE_ID::internal::once_flag generated_type_resolver_init_;
TProtoStringType GetTypeUrl(const Message& message) {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/json_util.h b/contrib/libs/protobuf/src/google/protobuf/util/json_util.h
index 7be7f4222c..35b977d2fc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/json_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/json_util.h
@@ -39,6 +39,7 @@
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/strutil.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -181,8 +182,8 @@ namespace internal {
class PROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
public:
explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream)
- : stream_(stream), buffer_(NULL), buffer_size_(0) {}
- ~ZeroCopyStreamByteSink();
+ : stream_(stream), buffer_(nullptr), buffer_size_(0) {}
+ ~ZeroCopyStreamByteSink() override;
void Append(const char* bytes, size_t len) override;
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc b/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc
index 5c2b9b6f97..b3ec430a2a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc
@@ -44,7 +44,6 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
@@ -55,8 +54,9 @@
#include <google/protobuf/map_field.h>
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
-#include <google/protobuf/util/field_comparator.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/util/field_comparator.h>
// Always include as last one, otherwise it can break compilation
#include <google/protobuf/port_def.inc>
@@ -66,6 +66,26 @@ namespace protobuf {
namespace util {
+namespace {
+
+TProtoStringType PrintShortTextFormat(const google::protobuf::Message& message) {
+ TProtoStringType debug_string;
+
+ google::protobuf::TextFormat::Printer printer;
+ printer.SetSingleLineMode(true);
+ printer.SetExpandAny(true);
+
+ printer.PrintToString(message, &debug_string);
+ // Single line mode currently might have an extra space at the end.
+ if (!debug_string.empty() && debug_string[debug_string.size() - 1] == ' ') {
+ debug_string.resize(debug_string.size() - 1);
+ }
+
+ return debug_string;
+}
+
+} // namespace
+
// A reporter to report the total number of diffs.
// TODO(ykzhu): we can improve this to take into account the value differencers.
class NumDiffsReporter : public google::protobuf::util::MessageDifferencer::Reporter {
@@ -331,9 +351,14 @@ void MessageDifferencer::set_message_field_comparison(
message_field_comparison_ = comparison;
}
+MessageDifferencer::MessageFieldComparison
+MessageDifferencer::message_field_comparison() const {
+ return message_field_comparison_;
+}
+
void MessageDifferencer::set_scope(Scope scope) { scope_ = scope; }
-MessageDifferencer::Scope MessageDifferencer::scope() { return scope_; }
+MessageDifferencer::Scope MessageDifferencer::scope() const { return scope_; }
void MessageDifferencer::set_float_comparison(FloatComparison comparison) {
default_field_comparator_.set_float_comparison(
@@ -347,7 +372,7 @@ void MessageDifferencer::set_repeated_field_comparison(
}
MessageDifferencer::RepeatedFieldComparison
-MessageDifferencer::repeated_field_comparison() {
+MessageDifferencer::repeated_field_comparison() const {
return repeated_field_comparison_;
}
@@ -2007,14 +2032,13 @@ void MessageDifferencer::StreamReporter::PrintValue(
if (field->is_map() && message1_ != nullptr && message2_ != nullptr) {
fd = field_message.GetDescriptor()->field(1);
if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- output = field_message.GetReflection()
- ->GetMessage(field_message, fd)
- .ShortDebugString();
+ output = PrintShortTextFormat(
+ field_message.GetReflection()->GetMessage(field_message, fd));
} else {
TextFormat::PrintFieldValueToString(field_message, fd, -1, &output);
}
} else {
- output = field_message.ShortDebugString();
+ output = PrintShortTextFormat(field_message);
}
if (output.empty()) {
printer_->Print("{ }");
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h b/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h
index cd569075cd..b28aa61d18 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h
@@ -43,6 +43,7 @@
#ifndef GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__
#define GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__
+
#include <functional>
#include <map>
#include <memory>
@@ -544,6 +545,9 @@ class PROTOBUF_EXPORT MessageDifferencer {
// to compare fields in messages.
void set_message_field_comparison(MessageFieldComparison comparison);
+ // Returns the current message field comparison used in this differencer.
+ MessageFieldComparison message_field_comparison() const;
+
// Tells the differencer whether or not to report matches. This method must
// be called before Compare. The default for a new differencer is false.
void set_report_matches(bool report_matches) {
@@ -567,7 +571,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
void set_scope(Scope scope);
// Returns the current scope used by this differencer.
- Scope scope();
+ Scope scope() const;
// DEPRECATED. Pass a DefaultFieldComparator instance instead.
// Sets the type of comparison (as defined in the FloatComparison enumeration
@@ -583,7 +587,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
void set_repeated_field_comparison(RepeatedFieldComparison comparison);
// Returns the current repeated field comparison used by this differencer.
- RepeatedFieldComparison repeated_field_comparison();
+ RepeatedFieldComparison repeated_field_comparison() const;
// Compares the two specified messages, returning true if they are the same,
// false otherwise. If this method returns false, any changes between the
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/time_util.cc b/contrib/libs/protobuf/src/google/protobuf/util/time_util.cc
index d30a4bffbc..854e8590a6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/time_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/time_util.cc
@@ -32,11 +32,11 @@
#include <cstdint>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/duration.pb.h>
#include <google/protobuf/timestamp.pb.h>
#include <google/protobuf/stubs/int128.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/time.h>
// Must go after other includes.
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/time_util.h b/contrib/libs/protobuf/src/google/protobuf/util/time_util.h
index 58530353b7..e85e3c2b47 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/time_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/time_util.h
@@ -53,6 +53,7 @@ struct timeval {
#include <google/protobuf/duration.pb.h>
#include <google/protobuf/timestamp.pb.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h
index 9bf967a803..00082f2adf 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h
@@ -40,6 +40,7 @@
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/status.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.cc b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.cc
index 6fafbcb652..94079dc4e1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.cc
@@ -34,10 +34,10 @@
#include <google/protobuf/wrappers.pb.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/util/internal/utility.h>
-#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/util/internal/utility.h>
+#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/stubs/status.h>
// clang-format off
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.h b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.h
index 035b385634..9d4fdaf8b8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.h
@@ -42,6 +42,7 @@ class DescriptorPool;
namespace util {
class TypeResolver;
+// Must be included last.
#include <google/protobuf/port_def.inc>
// Creates a TypeResolver that serves type information in the given descriptor
diff --git a/contrib/libs/protobuf/src/google/protobuf/wire_format.cc b/contrib/libs/protobuf/src/google/protobuf/wire_format.cc
index d7acf3da90..a90df7e4c1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format.cc
@@ -40,21 +40,21 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/map_field_inl.h>
#include <google/protobuf/message.h>
#include <google/protobuf/message_lite.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/unknown_field_set.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
const size_t kMapEntryTagByteSize = 2;
@@ -657,9 +657,11 @@ struct WireFormat::MessageSetParser {
const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) {
// Parse a MessageSetItem
auto metadata = reflection->MutableInternalMetadata(msg);
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
+ State state = State::kNoTag;
+
TProtoStringType payload;
arc_ui32 type_id = 0;
- bool payload_read = false;
while (!ctx->Done(&ptr)) {
// We use 64 bit tags in order to allow typeid's that span the whole
// range of 32 bit numbers.
@@ -668,8 +670,11 @@ struct WireFormat::MessageSetParser {
arc_ui64 tmp;
ptr = ParseBigVarint(ptr, &tmp);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- type_id = tmp;
- if (payload_read) {
+ if (state == State::kNoTag) {
+ type_id = tmp;
+ state = State::kHasType;
+ } else if (state == State::kHasPayload) {
+ type_id = tmp;
const FieldDescriptor* field;
if (ctx->data().pool == nullptr) {
field = reflection->FindKnownExtensionByNumber(type_id);
@@ -696,17 +701,17 @@ struct WireFormat::MessageSetParser {
GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) &&
tmp_ctx.EndedAtLimit());
}
- type_id = 0;
+ state = State::kDone;
}
continue;
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
- if (type_id == 0) {
+ if (state == State::kNoTag) {
arc_i32 size = ReadSize(&ptr);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ptr = ctx->ReadString(ptr, size, &payload);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- payload_read = true;
- } else {
+ state = State::kHasPayload;
+ } else if (state == State::kHasType) {
// We're now parsing the payload
const FieldDescriptor* field = nullptr;
if (descriptor->IsExtensionNumber(type_id)) {
@@ -720,7 +725,12 @@ struct WireFormat::MessageSetParser {
ptr = WireFormat::_InternalParseAndMergeField(
msg, ptr, ctx, static_cast<arc_ui64>(type_id) * 8 + 2, reflection,
field);
- type_id = 0;
+ state = State::kDone;
+ } else {
+ arc_i32 size = ReadSize(&ptr);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ptr = ctx->Skip(ptr, size);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
}
} else {
// An unknown field in MessageSetItem.
@@ -1125,10 +1135,11 @@ static uint8_t* SerializeMapValueRefWithCachedSizes(
case FieldDescriptor::TYPE_BYTES:
target = stream->WriteString(2, value.GetStringValue(), target);
break;
- case FieldDescriptor::TYPE_MESSAGE:
- target = WireFormatLite::InternalWriteMessage(2, value.GetMessageValue(),
+ case FieldDescriptor::TYPE_MESSAGE: {
+ auto& msg = value.GetMessageValue();
+ target = WireFormatLite::InternalWriteMessage(2, msg, msg.GetCachedSize(),
target, stream);
- break;
+ } break;
case FieldDescriptor::TYPE_GROUP:
target = WireFormatLite::InternalWriteGroup(2, value.GetMessageValue(),
target, stream);
@@ -1320,6 +1331,16 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field,
return target;
}
+ auto get_message_from_field = [&message, &map_entries, message_reflection](
+ const FieldDescriptor* field, int j) {
+ if (!field->is_repeated()) {
+ return &message_reflection->GetMessage(message, field);
+ }
+ if (!map_entries.empty()) {
+ return map_entries[j];
+ }
+ return &message_reflection->GetRepeatedMessage(message, field, j);
+ };
for (int j = 0; j < count; j++) {
target = stream->EnsureSpace(target);
switch (field->type()) {
@@ -1353,22 +1374,17 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field,
HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool)
#undef HANDLE_PRIMITIVE_TYPE
-#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \
- case FieldDescriptor::TYPE_##TYPE: \
- target = WireFormatLite::InternalWrite##TYPE_METHOD( \
- field->number(), \
- field->is_repeated() \
- ? (map_entries.empty() \
- ? message_reflection->GetRepeated##CPPTYPE_METHOD(message, \
- field, j) \
- : *map_entries[j]) \
- : message_reflection->Get##CPPTYPE_METHOD(message, field), \
- target, stream); \
- break;
+ case FieldDescriptor::TYPE_GROUP: {
+ auto* msg = get_message_from_field(field, j);
+ target = WireFormatLite::InternalWriteGroup(field->number(), *msg,
+ target, stream);
+ } break;
- HANDLE_TYPE(GROUP, Group, Message)
- HANDLE_TYPE(MESSAGE, Message, Message)
-#undef HANDLE_TYPE
+ case FieldDescriptor::TYPE_MESSAGE: {
+ auto* msg = get_message_from_field(field, j);
+ target = WireFormatLite::InternalWriteMessage(
+ field->number(), *msg, msg->GetCachedSize(), target, stream);
+ } break;
case FieldDescriptor::TYPE_ENUM: {
const EnumValueDescriptor* value =
@@ -1432,9 +1448,10 @@ uint8_t* WireFormat::InternalSerializeMessageSetItem(
target = WireFormatLite::WriteUInt32ToArray(
WireFormatLite::kMessageSetTypeIdNumber, field->number(), target);
// Write message.
+ auto& msg = message_reflection->GetMessage(message, field);
target = WireFormatLite::InternalWriteMessage(
- WireFormatLite::kMessageSetMessageNumber,
- message_reflection->GetMessage(message, field), target, stream);
+ WireFormatLite::kMessageSetMessageNumber, msg, msg.GetCachedSize(),
+ target, stream);
// End group.
target = stream->EnsureSpace(target);
target = io::CodedOutputStream::WriteTagToArray(
diff --git a/contrib/libs/protobuf/src/google/protobuf/wire_format.h b/contrib/libs/protobuf/src/google/protobuf/wire_format.h
index 2ff7eb3b45..9b088a9ed9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format.h
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format.h
@@ -39,22 +39,24 @@
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__
#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__
+
#include <string>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
#include <google/protobuf/metadata_lite.h>
+#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/casts.h>
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc b/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc
index 9089ff1a7e..5abdc7ab72 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc
@@ -41,12 +41,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
+#include <google/protobuf/stubs/stringprintf.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -527,6 +528,28 @@ void WireFormatLite::WriteMessage(int field_number, const MessageLite& value,
value.SerializeWithCachedSizes(output);
}
+uint8_t* WireFormatLite::InternalWriteGroup(int field_number,
+ const MessageLite& value,
+ uint8_t* target,
+ io::EpsCopyOutputStream* stream) {
+ target = stream->EnsureSpace(target);
+ target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);
+ target = value._InternalSerialize(target, stream);
+ target = stream->EnsureSpace(target);
+ return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);
+}
+
+uint8_t* WireFormatLite::InternalWriteMessage(int field_number,
+ const MessageLite& value,
+ int cached_size, uint8_t* target,
+ io::EpsCopyOutputStream* stream) {
+ target = stream->EnsureSpace(target);
+ target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
+ target = io::CodedOutputStream::WriteVarint32ToArray(
+ static_cast<arc_ui32>(cached_size), target);
+ return value._InternalSerialize(target, stream);
+}
+
void WireFormatLite::WriteSubMessageMaybeToArray(
int /*size*/, const MessageLite& value, io::CodedOutputStream* output) {
output->SetCur(value._InternalSerialize(output->Cur(), output->EpsCopy()));
@@ -570,18 +593,29 @@ bool WireFormatLite::ReadBytes(io::CodedInputStream* input, TProtoStringType** p
return ReadBytesToString(input, *p);
}
-void PrintUTF8ErrorLog(const char* field_name, const char* operation_str,
+void PrintUTF8ErrorLog(StringPiece message_name,
+ StringPiece field_name, const char* operation_str,
bool emit_stacktrace) {
TProtoStringType stacktrace;
(void)emit_stacktrace; // Parameter is used by Google-internal code.
TProtoStringType quoted_field_name = "";
- if (field_name != nullptr) {
- quoted_field_name = StringPrintf(" '%s'", field_name);
+ if (!field_name.empty()) {
+ if (!message_name.empty()) {
+ quoted_field_name =
+ StrCat(" '", message_name, ".", field_name, "'");
+ } else {
+ quoted_field_name = StrCat(" '", field_name, "'");
+ }
}
- GOOGLE_LOG(ERROR) << "String field" << quoted_field_name << " contains invalid "
- << "UTF-8 data when " << operation_str << " a protocol "
- << "buffer. Use the 'bytes' type if you intend to send raw "
- << "bytes. " << stacktrace;
+ TProtoStringType error_message =
+ StrCat("String field", quoted_field_name,
+ " contains invalid UTF-8 data "
+ "when ",
+ operation_str,
+ " a protocol buffer. Use the 'bytes' type if you intend to "
+ "send raw bytes. ",
+ stacktrace);
+ GOOGLE_LOG(ERROR) << error_message;
}
bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op,
@@ -597,7 +631,7 @@ bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op,
break;
// no default case: have the compiler warn if a case is not covered.
}
- PrintUTF8ErrorLog(field_name, operation_str, false);
+ PrintUTF8ErrorLog("", field_name, operation_str, false);
return false;
}
return true;
diff --git a/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h b/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h
index 42d57bbd76..5166f3e9c8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h
@@ -40,16 +40,17 @@
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
+
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/port.h>
+#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/message_lite.h>
-#include <google/protobuf/port.h>
#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/stubs/casts.h>
// Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL.
@@ -63,6 +64,7 @@
#undef TYPE_BOOL
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -618,14 +620,13 @@ class PROTOBUF_EXPORT WireFormatLite {
// of serialization, the "ToArray" variants may be invoked. But they don't
// have a CodedOutputStream available, so they get an additional parameter
// telling them whether to serialize deterministically.
- template <typename MessageType>
- PROTOBUF_NDEBUG_INLINE static uint8_t* InternalWriteGroup(
- int field_number, const MessageType& value, uint8_t* target,
- io::EpsCopyOutputStream* stream);
- template <typename MessageType>
- PROTOBUF_NDEBUG_INLINE static uint8_t* InternalWriteMessage(
- int field_number, const MessageType& value, uint8_t* target,
- io::EpsCopyOutputStream* stream);
+ static uint8_t* InternalWriteGroup(int field_number, const MessageLite& value,
+ uint8_t* target,
+ io::EpsCopyOutputStream* stream);
+ static uint8_t* InternalWriteMessage(int field_number,
+ const MessageLite& value,
+ int cached_size, uint8_t* target,
+ io::EpsCopyOutputStream* stream);
// Like above, but de-virtualize the call to SerializeWithCachedSizes(). The
// pointer must point at an instance of MessageType, *not* a subclass (or
@@ -658,7 +659,8 @@ class PROTOBUF_EXPORT WireFormatLite {
static_cast<arc_ui32>(field_number) << 3) +
io::CodedOutputStream::VarintSize32(size)),
io::CodedOutputStream::IsDefaultSerializationDeterministic());
- return InternalWriteMessage(field_number, value, target, &stream);
+ return InternalWriteMessage(field_number, value, value.GetCachedSize(),
+ target, &stream);
}
// Compute the byte size of a field. The XxSize() functions do NOT include
@@ -1701,25 +1703,6 @@ inline uint8_t* WireFormatLite::WriteBytesToArray(int field_number,
}
-template <typename MessageType>
-inline uint8_t* WireFormatLite::InternalWriteGroup(
- int field_number, const MessageType& value, uint8_t* target,
- io::EpsCopyOutputStream* stream) {
- target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);
- target = value._InternalSerialize(target, stream);
- target = stream->EnsureSpace(target);
- return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);
-}
-template <typename MessageType>
-inline uint8_t* WireFormatLite::InternalWriteMessage(
- int field_number, const MessageType& value, uint8_t* target,
- io::EpsCopyOutputStream* stream) {
- target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
- target = io::CodedOutputStream::WriteVarint32ToArrayOutOfLine(
- static_cast<arc_ui32>(value.GetCachedSize()), target);
- return value._InternalSerialize(target, stream);
-}
-
// See comment on ReadGroupNoVirtual to understand the need for this template
// parameter name.
template <typename MessageType_WorkAroundCppLookupDefect>
@@ -1843,6 +1826,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
// we can parse it later.
TProtoStringType message_data;
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
+ State state = State::kNoTag;
+
while (true) {
const arc_ui32 tag = input->ReadTagNoLastTag();
if (tag == 0) return false;
@@ -1851,26 +1837,34 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
case WireFormatLite::kMessageSetTypeIdTag: {
arc_ui32 type_id;
if (!input->ReadVarint32(&type_id)) return false;
- last_type_id = type_id;
-
- if (!message_data.empty()) {
+ if (state == State::kNoTag) {
+ last_type_id = type_id;
+ state = State::kHasType;
+ } else if (state == State::kHasPayload) {
// We saw some message data before the type_id. Have to parse it
// now.
io::CodedInputStream sub_input(
reinterpret_cast<const uint8_t*>(message_data.data()),
static_cast<int>(message_data.size()));
sub_input.SetRecursionLimit(input->RecursionBudget());
- if (!ms.ParseField(last_type_id, &sub_input)) {
+ if (!ms.ParseField(type_id, &sub_input)) {
return false;
}
message_data.clear();
+ state = State::kDone;
}
break;
}
case WireFormatLite::kMessageSetMessageTag: {
- if (last_type_id == 0) {
+ if (state == State::kHasType) {
+ // Already saw type_id, so we can parse this directly.
+ if (!ms.ParseField(last_type_id, input)) {
+ return false;
+ }
+ state = State::kDone;
+ } else if (state == State::kNoTag) {
// We haven't seen a type_id yet. Append this data to message_data.
arc_ui32 length;
if (!input->ReadVarint32(&length)) return false;
@@ -1881,11 +1875,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
auto ptr = reinterpret_cast<uint8_t*>(&message_data[0]);
ptr = io::CodedOutputStream::WriteVarint32ToArray(length, ptr);
if (!input->ReadRaw(ptr, length)) return false;
+ state = State::kHasPayload;
} else {
- // Already saw type_id, so we can parse this directly.
- if (!ms.ParseField(last_type_id, input)) {
- return false;
- }
+ if (!ms.SkipField(tag, input)) return false;
}
break;
diff --git a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc
index eee38e9b8a..a1d8c6a761 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc
@@ -16,119 +16,123 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
-constexpr DoubleValue::DoubleValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_CONSTEXPR DoubleValue::DoubleValue(
+ ::_pbi::ConstantInitialized)
: value_(0){}
struct DoubleValueDefaultTypeInternal {
- constexpr DoubleValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DoubleValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~DoubleValueDefaultTypeInternal() {}
union {
DoubleValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
-constexpr FloatValue::FloatValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
+PROTOBUF_CONSTEXPR FloatValue::FloatValue(
+ ::_pbi::ConstantInitialized)
: value_(0){}
struct FloatValueDefaultTypeInternal {
- constexpr FloatValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FloatValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~FloatValueDefaultTypeInternal() {}
union {
FloatValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FloatValueDefaultTypeInternal _FloatValue_default_instance_;
-constexpr Int64Value::Int64Value(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FloatValueDefaultTypeInternal _FloatValue_default_instance_;
+PROTOBUF_CONSTEXPR Int64Value::Int64Value(
+ ::_pbi::ConstantInitialized)
: value_(arc_i64{0}){}
struct Int64ValueDefaultTypeInternal {
- constexpr Int64ValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR Int64ValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~Int64ValueDefaultTypeInternal() {}
union {
Int64Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
-constexpr UInt64Value::UInt64Value(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
+PROTOBUF_CONSTEXPR UInt64Value::UInt64Value(
+ ::_pbi::ConstantInitialized)
: value_(arc_ui64{0u}){}
struct UInt64ValueDefaultTypeInternal {
- constexpr UInt64ValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UInt64ValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~UInt64ValueDefaultTypeInternal() {}
union {
UInt64Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
-constexpr Int32Value::Int32Value(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
+PROTOBUF_CONSTEXPR Int32Value::Int32Value(
+ ::_pbi::ConstantInitialized)
: value_(0){}
struct Int32ValueDefaultTypeInternal {
- constexpr Int32ValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR Int32ValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~Int32ValueDefaultTypeInternal() {}
union {
Int32Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
-constexpr UInt32Value::UInt32Value(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
+PROTOBUF_CONSTEXPR UInt32Value::UInt32Value(
+ ::_pbi::ConstantInitialized)
: value_(0u){}
struct UInt32ValueDefaultTypeInternal {
- constexpr UInt32ValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UInt32ValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~UInt32ValueDefaultTypeInternal() {}
union {
UInt32Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
-constexpr BoolValue::BoolValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
+PROTOBUF_CONSTEXPR BoolValue::BoolValue(
+ ::_pbi::ConstantInitialized)
: value_(false){}
struct BoolValueDefaultTypeInternal {
- constexpr BoolValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR BoolValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~BoolValueDefaultTypeInternal() {}
union {
BoolValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT BoolValueDefaultTypeInternal _BoolValue_default_instance_;
-constexpr StringValue::StringValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BoolValueDefaultTypeInternal _BoolValue_default_instance_;
+PROTOBUF_CONSTEXPR StringValue::StringValue(
+ ::_pbi::ConstantInitialized)
+ : value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct StringValueDefaultTypeInternal {
- constexpr StringValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR StringValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~StringValueDefaultTypeInternal() {}
union {
StringValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT StringValueDefaultTypeInternal _StringValue_default_instance_;
-constexpr BytesValue::BytesValue(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StringValueDefaultTypeInternal _StringValue_default_instance_;
+PROTOBUF_CONSTEXPR BytesValue::BytesValue(
+ ::_pbi::ConstantInitialized)
+ : value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct BytesValueDefaultTypeInternal {
- constexpr BytesValueDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR BytesValueDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~BytesValueDefaultTypeInternal() {}
union {
BytesValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT BytesValueDefaultTypeInternal _BytesValue_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BytesValueDefaultTypeInternal _BytesValue_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[9];
-static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
-static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[9];
+static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
@@ -195,7 +199,7 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, value_),
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DoubleValue)},
{ 7, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FloatValue)},
{ 14, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int64Value)},
@@ -207,16 +211,16 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB
{ 56, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BytesValue)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DoubleValue_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FloatValue_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Int64Value_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UInt64Value_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Int32Value_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UInt32Value_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_BoolValue_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_StringValue_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_BytesValue_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::_DoubleValue_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_FloatValue_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Int64Value_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_UInt64Value_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Int32Value_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_UInt32Value_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_BoolValue_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_StringValue_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_BytesValue_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -233,19 +237,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto[] PROT
"erspb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKno"
"wnTypesb\006proto3"
;
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto = {
- false, false, 455, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, "google/protobuf/wrappers.proto",
- &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, nullptr, 0, 9,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto, file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto = {
+ false, false, 455, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto,
+ "google/protobuf/wrappers.proto",
+ &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, nullptr, 0, 9,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fwrappers_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fwrappers_2eproto(&descriptor_table_google_2fprotobuf_2fwrappers_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fwrappers_2eproto(&descriptor_table_google_2fprotobuf_2fwrappers_2eproto);
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
@@ -258,9 +264,6 @@ DoubleValue::DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue)
}
DoubleValue::DoubleValue(const DoubleValue& from)
@@ -276,21 +279,17 @@ value_ = 0;
DoubleValue::~DoubleValue() {
// @@protoc_insertion_point(destructor:google.protobuf.DoubleValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void DoubleValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void DoubleValue::ArenaDtor(void* object) {
- DoubleValue* _this = reinterpret_cast< DoubleValue* >(object);
- (void)_this;
-}
-void DoubleValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void DoubleValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -305,11 +304,11 @@ void DoubleValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* DoubleValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* DoubleValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// double value = 1;
case 1:
@@ -355,11 +354,11 @@ uint8_t* DoubleValue::_InternalSerialize(
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteDoubleToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -433,7 +432,7 @@ void DoubleValue::InternalSwap(DoubleValue* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata DoubleValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[0]);
}
@@ -448,9 +447,6 @@ FloatValue::FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue)
}
FloatValue::FloatValue(const FloatValue& from)
@@ -466,21 +462,17 @@ value_ = 0;
FloatValue::~FloatValue() {
// @@protoc_insertion_point(destructor:google.protobuf.FloatValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void FloatValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void FloatValue::ArenaDtor(void* object) {
- FloatValue* _this = reinterpret_cast< FloatValue* >(object);
- (void)_this;
-}
-void FloatValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void FloatValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -495,11 +487,11 @@ void FloatValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* FloatValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* FloatValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// float value = 1;
case 1:
@@ -545,11 +537,11 @@ uint8_t* FloatValue::_InternalSerialize(
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteFloatToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -623,7 +615,7 @@ void FloatValue::InternalSwap(FloatValue* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FloatValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[1]);
}
@@ -638,9 +630,6 @@ Int64Value::Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value)
}
Int64Value::Int64Value(const Int64Value& from)
@@ -656,21 +645,17 @@ value_ = arc_i64{0};
Int64Value::~Int64Value() {
// @@protoc_insertion_point(destructor:google.protobuf.Int64Value)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Int64Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void Int64Value::ArenaDtor(void* object) {
- Int64Value* _this = reinterpret_cast< Int64Value* >(object);
- (void)_this;
-}
-void Int64Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Int64Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -685,11 +670,11 @@ void Int64Value::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Int64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Int64Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int64 value = 1;
case 1:
@@ -731,11 +716,11 @@ uint8_t* Int64Value::_InternalSerialize(
// int64 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -752,7 +737,7 @@ size_t Int64Value::ByteSizeLong() const {
// int64 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -801,7 +786,7 @@ void Int64Value::InternalSwap(Int64Value* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Int64Value::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[2]);
}
@@ -816,9 +801,6 @@ UInt64Value::UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value)
}
UInt64Value::UInt64Value(const UInt64Value& from)
@@ -834,21 +816,17 @@ value_ = arc_ui64{0u};
UInt64Value::~UInt64Value() {
// @@protoc_insertion_point(destructor:google.protobuf.UInt64Value)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void UInt64Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void UInt64Value::ArenaDtor(void* object) {
- UInt64Value* _this = reinterpret_cast< UInt64Value* >(object);
- (void)_this;
-}
-void UInt64Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void UInt64Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -863,11 +841,11 @@ void UInt64Value::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* UInt64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* UInt64Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// uint64 value = 1;
case 1:
@@ -909,11 +887,11 @@ uint8_t* UInt64Value::_InternalSerialize(
// uint64 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -930,7 +908,7 @@ size_t UInt64Value::ByteSizeLong() const {
// uint64 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -979,7 +957,7 @@ void UInt64Value::InternalSwap(UInt64Value* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata UInt64Value::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[3]);
}
@@ -994,9 +972,6 @@ Int32Value::Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value)
}
Int32Value::Int32Value(const Int32Value& from)
@@ -1012,21 +987,17 @@ value_ = 0;
Int32Value::~Int32Value() {
// @@protoc_insertion_point(destructor:google.protobuf.Int32Value)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Int32Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void Int32Value::ArenaDtor(void* object) {
- Int32Value* _this = reinterpret_cast< Int32Value* >(object);
- (void)_this;
-}
-void Int32Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void Int32Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1041,11 +1012,11 @@ void Int32Value::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Int32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Int32Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int32 value = 1;
case 1:
@@ -1087,11 +1058,11 @@ uint8_t* Int32Value::_InternalSerialize(
// int32 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1108,7 +1079,7 @@ size_t Int32Value::ByteSizeLong() const {
// int32 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -1157,7 +1128,7 @@ void Int32Value::InternalSwap(Int32Value* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Int32Value::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[4]);
}
@@ -1172,9 +1143,6 @@ UInt32Value::UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value)
}
UInt32Value::UInt32Value(const UInt32Value& from)
@@ -1190,21 +1158,17 @@ value_ = 0u;
UInt32Value::~UInt32Value() {
// @@protoc_insertion_point(destructor:google.protobuf.UInt32Value)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void UInt32Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void UInt32Value::ArenaDtor(void* object) {
- UInt32Value* _this = reinterpret_cast< UInt32Value* >(object);
- (void)_this;
-}
-void UInt32Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void UInt32Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1219,11 +1183,11 @@ void UInt32Value::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* UInt32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* UInt32Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// uint32 value = 1;
case 1:
@@ -1265,11 +1229,11 @@ uint8_t* UInt32Value::_InternalSerialize(
// uint32 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1286,7 +1250,7 @@ size_t UInt32Value::ByteSizeLong() const {
// uint32 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
@@ -1335,7 +1299,7 @@ void UInt32Value::InternalSwap(UInt32Value* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata UInt32Value::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[5]);
}
@@ -1350,9 +1314,6 @@ BoolValue::BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue)
}
BoolValue::BoolValue(const BoolValue& from)
@@ -1368,21 +1329,17 @@ value_ = false;
BoolValue::~BoolValue() {
// @@protoc_insertion_point(destructor:google.protobuf.BoolValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void BoolValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
-void BoolValue::ArenaDtor(void* object) {
- BoolValue* _this = reinterpret_cast< BoolValue* >(object);
- (void)_this;
-}
-void BoolValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void BoolValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1397,11 +1354,11 @@ void BoolValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* BoolValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* BoolValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// bool value = 1;
case 1:
@@ -1443,11 +1400,11 @@ uint8_t* BoolValue::_InternalSerialize(
// bool value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(1, this->_internal_value(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1513,7 +1470,7 @@ void BoolValue::InternalSwap(BoolValue* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata BoolValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[6]);
}
@@ -1528,50 +1485,43 @@ StringValue::StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue)
}
StringValue::StringValue(const StringValue& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
+ value_.Set(from._internal_value(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)
}
inline void StringValue::SharedCtor() {
-value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
StringValue::~StringValue() {
// @@protoc_insertion_point(destructor:google.protobuf.StringValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void StringValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ value_.Destroy();
}
-void StringValue::ArenaDtor(void* object) {
- StringValue* _this = reinterpret_cast< StringValue* >(object);
- (void)_this;
-}
-void StringValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void StringValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1586,19 +1536,19 @@ void StringValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* StringValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* StringValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string value = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
- CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.StringValue.value"));
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
+ CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.StringValue.value"));
} else
goto handle_unusual;
continue;
@@ -1642,7 +1592,7 @@ uint8_t* StringValue::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1709,14 +1659,13 @@ void StringValue::InternalSwap(StringValue* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, lhs_arena,
&other->value_, rhs_arena
);
}
::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[7]);
}
@@ -1731,50 +1680,43 @@ BytesValue::BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue)
}
BytesValue::BytesValue(const BytesValue& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
+ value_.Set(from._internal_value(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)
}
inline void BytesValue::SharedCtor() {
-value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
BytesValue::~BytesValue() {
// @@protoc_insertion_point(destructor:google.protobuf.BytesValue)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void BytesValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ value_.Destroy();
}
-void BytesValue::ArenaDtor(void* object) {
- BytesValue* _this = reinterpret_cast< BytesValue* >(object);
- (void)_this;
-}
-void BytesValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
void BytesValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
@@ -1789,17 +1731,17 @@ void BytesValue::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* BytesValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* BytesValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// bytes value = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_value();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
} else
goto handle_unusual;
@@ -1840,7 +1782,7 @@ uint8_t* BytesValue::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1907,14 +1849,13 @@ void BytesValue::InternalSwap(BytesValue* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, lhs_arena,
&other->value_, rhs_arena
);
}
::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[8]);
}
@@ -1922,31 +1863,40 @@ void BytesValue::InternalSwap(BytesValue* other) {
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DoubleValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DoubleValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FloatValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FloatValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FloatValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FloatValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FloatValue >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int64Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int64Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int64Value*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int64Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Int64Value >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt64Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt64Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt64Value*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt64Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UInt64Value >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int32Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int32Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int32Value*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int32Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Int32Value >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt32Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt32Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt32Value*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt32Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UInt32Value >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BoolValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BoolValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BoolValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BoolValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::BoolValue >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::StringValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::StringValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::StringValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::StringValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::StringValue >(arena);
}
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BytesValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BytesValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BytesValue*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BytesValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::BytesValue >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h
index a827390303..82b7a0af56 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fwrappers_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[9]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto;
@@ -102,7 +93,7 @@ class PROTOBUF_EXPORT DoubleValue final :
public:
inline DoubleValue() : DoubleValue(nullptr) {}
~DoubleValue() override;
- explicit constexpr DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DoubleValue(const DoubleValue& from);
DoubleValue(DoubleValue&& from) noexcept
@@ -204,9 +195,6 @@ class PROTOBUF_EXPORT DoubleValue final :
protected:
explicit DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -248,7 +236,7 @@ class PROTOBUF_EXPORT FloatValue final :
public:
inline FloatValue() : FloatValue(nullptr) {}
~FloatValue() override;
- explicit constexpr FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FloatValue(const FloatValue& from);
FloatValue(FloatValue&& from) noexcept
@@ -350,9 +338,6 @@ class PROTOBUF_EXPORT FloatValue final :
protected:
explicit FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -394,7 +379,7 @@ class PROTOBUF_EXPORT Int64Value final :
public:
inline Int64Value() : Int64Value(nullptr) {}
~Int64Value() override;
- explicit constexpr Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Int64Value(const Int64Value& from);
Int64Value(Int64Value&& from) noexcept
@@ -496,9 +481,6 @@ class PROTOBUF_EXPORT Int64Value final :
protected:
explicit Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -540,7 +522,7 @@ class PROTOBUF_EXPORT UInt64Value final :
public:
inline UInt64Value() : UInt64Value(nullptr) {}
~UInt64Value() override;
- explicit constexpr UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UInt64Value(const UInt64Value& from);
UInt64Value(UInt64Value&& from) noexcept
@@ -642,9 +624,6 @@ class PROTOBUF_EXPORT UInt64Value final :
protected:
explicit UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -686,7 +665,7 @@ class PROTOBUF_EXPORT Int32Value final :
public:
inline Int32Value() : Int32Value(nullptr) {}
~Int32Value() override;
- explicit constexpr Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Int32Value(const Int32Value& from);
Int32Value(Int32Value&& from) noexcept
@@ -788,9 +767,6 @@ class PROTOBUF_EXPORT Int32Value final :
protected:
explicit Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -832,7 +808,7 @@ class PROTOBUF_EXPORT UInt32Value final :
public:
inline UInt32Value() : UInt32Value(nullptr) {}
~UInt32Value() override;
- explicit constexpr UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UInt32Value(const UInt32Value& from);
UInt32Value(UInt32Value&& from) noexcept
@@ -934,9 +910,6 @@ class PROTOBUF_EXPORT UInt32Value final :
protected:
explicit UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -978,7 +951,7 @@ class PROTOBUF_EXPORT BoolValue final :
public:
inline BoolValue() : BoolValue(nullptr) {}
~BoolValue() override;
- explicit constexpr BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
BoolValue(const BoolValue& from);
BoolValue(BoolValue&& from) noexcept
@@ -1080,9 +1053,6 @@ class PROTOBUF_EXPORT BoolValue final :
protected:
explicit BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1124,7 +1094,7 @@ class PROTOBUF_EXPORT StringValue final :
public:
inline StringValue() : StringValue(nullptr) {}
~StringValue() override;
- explicit constexpr StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
StringValue(const StringValue& from);
StringValue(StringValue&& from) noexcept
@@ -1226,9 +1196,6 @@ class PROTOBUF_EXPORT StringValue final :
protected:
explicit StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1275,7 +1242,7 @@ class PROTOBUF_EXPORT BytesValue final :
public:
inline BytesValue() : BytesValue(nullptr) {}
~BytesValue() override;
- explicit constexpr BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
BytesValue(const BytesValue& from);
BytesValue(BytesValue&& from) noexcept
@@ -1377,9 +1344,6 @@ class PROTOBUF_EXPORT BytesValue final :
protected:
explicit BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1610,7 +1574,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void StringValue::set_value(ArgT0&& arg0, ArgT... args) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.StringValue.value)
}
inline TProtoStringType* StringValue::mutable_value() {
@@ -1623,15 +1587,15 @@ inline const TProtoStringType& StringValue::_internal_value() const {
}
inline void StringValue::_internal_set_value(const TProtoStringType& value) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* StringValue::_internal_mutable_value() {
- return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* StringValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.StringValue.value)
- return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return value_.Release();
}
inline void StringValue::set_allocated_value(TProtoStringType* value) {
if (value != nullptr) {
@@ -1639,11 +1603,10 @@ inline void StringValue::set_allocated_value(TProtoStringType* value) {
} else {
}
- value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
- GetArenaForAllocation());
+ value_.SetAllocated(value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (value_.IsDefault()) {
+ value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)
@@ -1665,7 +1628,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void BytesValue::set_value(ArgT0&& arg0, ArgT... args) {
- value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value)
}
inline TProtoStringType* BytesValue::mutable_value() {
@@ -1678,15 +1641,15 @@ inline const TProtoStringType& BytesValue::_internal_value() const {
}
inline void BytesValue::_internal_set_value(const TProtoStringType& value) {
- value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* BytesValue::_internal_mutable_value() {
- return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return value_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* BytesValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value)
- return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ return value_.Release();
}
inline void BytesValue::set_allocated_value(TProtoStringType* value) {
if (value != nullptr) {
@@ -1694,11 +1657,10 @@ inline void BytesValue::set_allocated_value(TProtoStringType* value) {
} else {
}
- value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
- GetArenaForAllocation());
+ value_.SetAllocated(value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (value_.IsDefault()) {
+ value_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)
diff --git a/contrib/libs/protobuf/ya.make b/contrib/libs/protobuf/ya.make
index 0909d6b3b4..38219b164d 100644
--- a/contrib/libs/protobuf/ya.make
+++ b/contrib/libs/protobuf/ya.make
@@ -11,25 +11,34 @@ LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PROVIDES(protobuf)
-VERSION(3.19.0)
+VERSION(3.20.2)
-ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.19.0.tar.gz)
+ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.20.2.tar.gz)
IF (OPENSOURCE_REPLACE_PROTOBUF AND EXPORT_CMAKE)
-
OPENSOURCE_EXPORT_REPLACEMENT(
- CMAKE Protobuf
- CMAKE_TARGET protobuf::libprotobuf protobuf::libprotoc
- CONAN protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan-requires" protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan_require_tool" protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan-tool_requires" protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan_import \"bin, protoc* -> ./bin\" && conan-imports \"bin, protoc* -> ./bin\" && vanilla_protobuf"
+ CMAKE
+ Protobuf
+ CMAKE_TARGET
+ protobuf::libprotobuf
+ protobuf::libprotoc
+ CONAN
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan-requires"
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan_require_tool"
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan-tool_requires"
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan_import \"bin, protoc* -> ./bin\" && conan-imports 'bin, protoc* -> ./bin' && vanilla_protobuf"
)
-
ELSE()
-
ADDINCL(
GLOBAL contrib/libs/protobuf/src
- GLOBAL FOR proto contrib/libs/protobuf/src
+ GLOBAL FOR
+ proto
+ contrib/libs/protobuf/src
)
-
ENDIF()
PEERDIR(
@@ -57,6 +66,7 @@ SRCS(
src/google/protobuf/api.pb.cc
src/google/protobuf/arena.cc
src/google/protobuf/arenastring.cc
+ src/google/protobuf/arenaz_sampler.cc
src/google/protobuf/descriptor.cc
src/google/protobuf/descriptor.pb.cc
src/google/protobuf/descriptor_database.cc
@@ -69,8 +79,6 @@ SRCS(
src/google/protobuf/generated_enum_util.cc
src/google/protobuf/generated_message_bases.cc
src/google/protobuf/generated_message_reflection.cc
- src/google/protobuf/generated_message_table_driven.cc
- src/google/protobuf/generated_message_table_driven_lite.cc
src/google/protobuf/generated_message_tctable_full.cc
src/google/protobuf/generated_message_tctable_lite.cc
src/google/protobuf/implicit_weak_message.cc
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
index 9ad4d14ef1..f714df372a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
@@ -76,13 +76,13 @@ GeneratorContext::~GeneratorContext() {}
io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend(
const TProtoStringType& filename) {
- return NULL;
+ return nullptr;
}
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
const TProtoStringType& filename, const TProtoStringType& insertion_point) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
- return NULL; // make compiler happy
+ return nullptr; // make compiler happy
}
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
index a65c381842..81f0ea748e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
@@ -43,6 +43,7 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
index 7731c611d1..e1cbfee896 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
@@ -53,10 +53,11 @@
#endif
#include <ctype.h>
#include <errno.h>
+
#include <fstream>
#include <iostream>
-#include <limits.h> //For PATH_MAX
+#include <limits.h> // For PATH_MAX
#include <memory>
@@ -68,7 +69,6 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/compiler/subprocess.h>
#include <google/protobuf/compiler/zip_writer.h>
#include <google/protobuf/compiler/plugin.pb.h>
@@ -81,12 +81,14 @@
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/io/io_win32.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -195,7 +197,7 @@ bool TryCreateParentDirectory(const TProtoStringType& prefix,
bool GetProtocAbsolutePath(TProtoStringType* path) {
#ifdef _WIN32
char buffer[MAX_PATH];
- int len = GetModuleFileNameA(NULL, buffer, MAX_PATH);
+ int len = GetModuleFileNameA(nullptr, buffer, MAX_PATH);
#elif defined(__APPLE__)
char buffer[PATH_MAX];
int len = 0;
@@ -210,7 +212,7 @@ bool GetProtocAbsolutePath(TProtoStringType* path) {
char buffer[PATH_MAX];
size_t len = PATH_MAX;
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
- if (sysctl(mib, 4, &buffer, &len, NULL, 0) != 0) {
+ if (sysctl(mib, 4, &buffer, &len, nullptr, 0) != 0) {
len = 0;
}
#else
@@ -289,12 +291,12 @@ class CommandLineInterface::ErrorPrinter
public io::ErrorCollector,
public DescriptorPool::ErrorCollector {
public:
- ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL)
+ ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = nullptr)
: format_(format),
tree_(tree),
found_errors_(false),
found_warnings_(false) {}
- ~ErrorPrinter() {}
+ ~ErrorPrinter() override {}
// implements MultiFileErrorCollector ------------------------------
void AddError(const TProtoStringType& filename, int line, int column,
@@ -341,8 +343,8 @@ class CommandLineInterface::ErrorPrinter
std::ostream& out) {
// Print full path when running under MSVS
TProtoStringType dfile;
- if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && tree_ != NULL &&
- tree_->VirtualFileToDiskFile(filename, &dfile)) {
+ if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
+ tree_ != nullptr && tree_->VirtualFileToDiskFile(filename, &dfile)) {
out << dfile;
} else {
out << filename;
@@ -434,7 +436,7 @@ class CommandLineInterface::MemoryOutputStream
const TProtoStringType& filename,
const TProtoStringType& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
- virtual ~MemoryOutputStream();
+ ~MemoryOutputStream() override;
// implements ZeroCopyOutputStream ---------------------------------
bool Next(void** data, int* size) override {
@@ -1116,7 +1118,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
FileDescriptorProto file;
file.set_name("empty_message.proto");
file.add_message_type()->set_name("EmptyMessage");
- GOOGLE_CHECK(pool.BuildFile(file) != NULL);
+ GOOGLE_CHECK(pool.BuildFile(file) != nullptr);
codec_type_ = "EmptyMessage";
if (!EncodeOrDecode(&pool)) {
return 1;
@@ -1270,7 +1272,7 @@ bool CommandLineInterface::ParseInputFiles(
// Import the file.
const FileDescriptor* parsed_file =
descriptor_pool->FindFileByName(input_file);
- if (parsed_file == NULL) {
+ if (parsed_file == nullptr) {
result = false;
break;
}
@@ -1496,7 +1498,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
for (std::vector<OutputDirective>::const_iterator j =
output_directives_.begin();
j != output_directives_.end(); ++j) {
- if (j->generator == NULL) {
+ if (j->generator == nullptr) {
TProtoStringType plugin_name = PluginName(plugin_prefix_, j->name);
if (plugin_name == i->first) {
foundImplicitPlugin = true;
@@ -1613,7 +1615,7 @@ bool CommandLineInterface::ParseArgument(const char* arg, TProtoStringType* name
// Two dashes: Multi-character name, with '=' separating name and
// value.
const char* equals_pos = strchr(arg, '=');
- if (equals_pos != NULL) {
+ if (equals_pos != nullptr) {
*name = TProtoStringType(arg, equals_pos - arg);
*value = equals_pos + 1;
parsed_value = true;
@@ -1681,8 +1683,9 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
// On Windows, the shell (typically cmd.exe) does not expand wildcards in
// file names (e.g. foo\*.proto), so we do it ourselves.
switch (google::protobuf::io::win32::ExpandWildcards(
- value,
- [this](const string& path) { this->input_files_.push_back(path); })) {
+ value, [this](const TProtoStringType& path) {
+ this->input_files_.push_back(path);
+ })) {
case google::protobuf::io::win32::ExpandWildcardsResult::kSuccess:
break;
case google::protobuf::io::win32::ExpandWildcardsResult::
@@ -1982,11 +1985,11 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
// Some other flag. Look it up in the generators list.
const GeneratorInfo* generator_info =
FindOrNull(generators_by_flag_name_, name);
- if (generator_info == NULL &&
+ if (generator_info == nullptr &&
(plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) {
// Check if it's a generator option flag.
generator_info = FindOrNull(generators_by_option_name_, name);
- if (generator_info != NULL) {
+ if (generator_info != nullptr) {
TProtoStringType* parameters =
&generator_parameters_[generator_info->flag_name];
if (!parameters->empty()) {
@@ -2015,8 +2018,8 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
OutputDirective directive;
directive.name = name;
- if (generator_info == NULL) {
- directive.generator = NULL;
+ if (generator_info == nullptr) {
+ directive.generator = nullptr;
} else {
directive.generator = generator_info->generator;
}
@@ -2176,7 +2179,7 @@ bool CommandLineInterface::GenerateOutput(
GeneratorContext* generator_context) {
// Call the generator.
TProtoStringType error;
- if (output_directive.generator == NULL) {
+ if (output_directive.generator == nullptr) {
// This is a plugin.
GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") &&
HasSuffixString(output_directive.name, "_out"))
@@ -2344,7 +2347,7 @@ bool CommandLineInterface::GeneratePluginOutput(
if (!output_file.insertion_point().empty()) {
TProtoStringType filename = output_file.name();
// Open a file for insert.
- // We reset current_output to NULL first so that the old file is closed
+ // We reset current_output to nullptr first so that the old file is closed
// before the new one is opened.
current_output.reset();
current_output.reset(
@@ -2353,11 +2356,11 @@ bool CommandLineInterface::GeneratePluginOutput(
output_file.generated_code_info()));
} else if (!output_file.name().empty()) {
// Starting a new file. Open it.
- // We reset current_output to NULL first so that the old file is closed
+ // We reset current_output to nullptr first so that the old file is closed
// before the new one is opened.
current_output.reset();
current_output.reset(generator_context->Open(output_file.name()));
- } else if (current_output == NULL) {
+ } else if (current_output == nullptr) {
*error = strings::Substitute(
"$0: First file chunk returned by plugin did not specify a file "
"name.",
@@ -2387,7 +2390,7 @@ bool CommandLineInterface::GeneratePluginOutput(
bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
// Look up the type.
const Descriptor* type = pool->FindMessageTypeByName(codec_type_);
- if (type == NULL) {
+ if (type == nullptr) {
std::cerr << "Type not defined: " << codec_type_ << std::endl;
return false;
}
@@ -2650,7 +2653,8 @@ void FormatFreeFieldNumbers(const TProtoStringType& name,
StringAppendF(&output, " %d", next_free_number);
} else {
// Range
- StringAppendF(&output, " %d-%d", next_free_number, i->first - 1);
+ StringAppendF(&output, " %d-%d", next_free_number,
+ i->first - 1);
}
}
next_free_number = i->second;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h
index a5f1fc7008..a2a3dffe4b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h
@@ -49,6 +49,8 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
index 4ecd6a9cf7..960dfcadf7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
@@ -38,10 +38,10 @@
#include <limits>
#include <map>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_names.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/cpp_names.h>
namespace google {
namespace protobuf {
@@ -88,7 +88,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
variables_["nested_name"] = descriptor_->name();
variables_["resolved_name"] = ResolveKeyword(descriptor_->name());
variables_["prefix"] =
- (descriptor_->containing_type() == NULL) ? "" : classname_ + "_";
+ (descriptor_->containing_type() == nullptr) ? "" : classname_ + "_";
}
EnumGenerator::~EnumGenerator() {}
@@ -405,7 +405,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
descriptor_->value_count());
}
- if (descriptor_->containing_type() != NULL) {
+ if (descriptor_->containing_type() != nullptr) {
TProtoStringType parent = ClassName(descriptor_->containing_type(), false);
// Before C++17, we must define the static constants which were
// declared in the header, to give the linker a place to put them.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
index 43f1e5f4a5..652a26b6db 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
@@ -38,8 +38,9 @@
#include <map>
#include <set>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 79fa488b5f..f50fca4926 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -33,10 +33,11 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/cpp/cpp_enum_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
namespace google {
namespace protobuf {
@@ -53,6 +54,9 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["type"] = QualifiedClassName(descriptor->enum_type(), options);
(*variables)["default"] = Int32ToString(default_value->number());
(*variables)["full_name"] = descriptor->full_name();
+ (*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor);
+ (*variables)["cached_byte_size_field"] =
+ MakeVarintCachedSizeFieldName(descriptor);
}
} // namespace
@@ -90,7 +94,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_);
format(
"inline $type$ $classname$::_internal_$name$() const {\n"
- " return static_cast< $type$ >($name$_);\n"
+ " return static_cast< $type$ >($field$);\n"
"}\n"
"inline $type$ $classname$::$name$() const {\n"
"$annotate_get$"
@@ -103,7 +107,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
}
format(
" $set_hasbit$\n"
- " $name$_ = value;\n"
+ " $field$ = value;\n"
"}\n"
"inline void $classname$::set_$name$($type$ value) {\n"
" _internal_set_$name$(value);\n"
@@ -114,7 +118,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_ = $default$;\n");
+ format("$field$ = $default$;\n");
}
void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
@@ -124,18 +128,18 @@ void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("swap($name$_, other->$name$_);\n");
+ format("swap($field$, other->$field$);\n");
}
void EnumFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_ = $default$;\n");
+ format("$field$ = $default$;\n");
}
void EnumFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_ = from.$name$_;\n");
+ format("$field$ = from.$field$;\n");
}
void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -143,7 +147,7 @@ void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
Formatter format(printer, variables_);
format(
"target = stream->EnsureSpace(target);\n"
- "target = ::$proto_ns$::internal::WireFormatLite::WriteEnumToArray(\n"
+ "target = ::_pbi::WireFormatLite::WriteEnumToArray(\n"
" $number$, this->_internal_$name$(), target);\n");
}
@@ -151,9 +155,7 @@ void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"total_size += $tag_size$ +\n"
- " "
- "::$proto_ns$::internal::WireFormatLite::EnumSize(this->_internal_$name$("
- "));\n");
+ " ::_pbi::WireFormatLite::EnumSize(this->_internal_$name$());\n");
}
void EnumFieldGenerator::GenerateConstinitInitializer(
@@ -178,7 +180,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline $type$ $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n"
- " return static_cast< $type$ >($field_member$);\n"
+ " return static_cast< $type$ >($field$);\n"
" }\n"
" return static_cast< $type$ >($default$);\n"
"}\n"
@@ -196,7 +198,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" }\n"
- " $field_member$ = value;\n"
+ " $field$ = value;\n"
"}\n"
"inline void $classname$::set_$name$($type$ value) {\n"
" _internal_set_$name$(value);\n"
@@ -207,7 +209,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void EnumOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field_member$ = $default$;\n");
+ format("$field$ = $default$;\n");
}
void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@@ -217,7 +219,7 @@ void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
void EnumOneofFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$ns$::_$classname$_default_instance_.$name$_ = $default$;\n");
+ format("$ns$::_$classname$_default_instance_.$field$ = $default$;\n");
}
// ===================================================================
@@ -236,7 +238,7 @@ void RepeatedEnumFieldGenerator::GeneratePrivateMembers(
format("::$proto_ns$::RepeatedField<int> $name$_;\n");
if (descriptor_->is_packed() &&
HasGeneratedMethods(descriptor_->file(), options_)) {
- format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
+ format("mutable std::atomic<int> $cached_byte_size_name$;\n");
}
}
@@ -265,7 +267,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_);
format(
"inline $type$ $classname$::_internal_$name$(int index) const {\n"
- " return static_cast< $type$ >($name$_.Get(index));\n"
+ " return static_cast< $type$ >($field$.Get(index));\n"
"}\n"
"inline $type$ $classname$::$name$(int index) const {\n"
"$annotate_get$"
@@ -277,7 +279,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
format(" assert($type$_IsValid(value));\n");
}
format(
- " $name$_.Set(index, value);\n"
+ " $field$.Set(index, value);\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
@@ -286,7 +288,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
format(" assert($type$_IsValid(value));\n");
}
format(
- " $name$_.Add(value);\n"
+ " $field$.Add(value);\n"
"}\n"
"inline void $classname$::add_$name$($type$ value) {\n"
" _internal_add_$name$(value);\n"
@@ -297,11 +299,11 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
"$classname$::$name$() const {\n"
"$annotate_list$"
" // @@protoc_insertion_point(field_list:$full_name$)\n"
- " return $name$_;\n"
+ " return $field$;\n"
"}\n"
"inline ::$proto_ns$::RepeatedField<int>*\n"
"$classname$::_internal_mutable_$name$() {\n"
- " return &$name$_;\n"
+ " return &$field$;\n"
"}\n"
"inline ::$proto_ns$::RepeatedField<int>*\n"
"$classname$::mutable_$name$() {\n"
@@ -314,19 +316,19 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
void RepeatedEnumFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.Clear();\n");
+ format("$field$.Clear();\n");
}
void RepeatedEnumFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.MergeFrom(from.$name$_);\n");
+ format("$field$.MergeFrom(from.$field$);\n");
}
void RepeatedEnumFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.InternalSwap(&other->$name$_);\n");
+ format("$field$.InternalSwap(&other->$field$);\n");
}
void RepeatedEnumFieldGenerator::GenerateConstructorCode(
@@ -342,17 +344,17 @@ void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format(
"{\n"
" int byte_size = "
- "_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n"
+ "$cached_byte_size_field$.load(std::memory_order_relaxed);\n"
" if (byte_size > 0) {\n"
" target = stream->WriteEnumPacked(\n"
- " $number$, $name$_, byte_size, target);\n"
+ " $number$, $field$, byte_size, target);\n"
" }\n"
"}\n");
} else {
format(
"for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n"
" target = stream->EnsureSpace(target);\n"
- " target = ::$proto_ns$::internal::WireFormatLite::WriteEnumToArray(\n"
+ " target = ::_pbi::WireFormatLite::WriteEnumToArray(\n"
" $number$, this->_internal_$name$(i), target);\n"
"}\n");
}
@@ -368,7 +370,7 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
format.Indent();
format(
"for (unsigned int i = 0; i < count; i++) {\n"
- " data_size += ::$proto_ns$::internal::WireFormatLite::EnumSize(\n"
+ " data_size += ::_pbi::WireFormatLite::EnumSize(\n"
" this->_internal_$name$(static_cast<int>(i)));\n"
"}\n");
@@ -376,11 +378,11 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
format(
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
- " ::$proto_ns$::internal::WireFormatLite::Int32Size(\n"
- " static_cast<$int32$>(data_size));\n"
+ " "
+ "::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
"}\n"
- "int cached_size = ::$proto_ns$::internal::ToCachedSize(data_size);\n"
- "_$name$_cached_byte_size_.store(cached_size,\n"
+ "int cached_size = ::_pbi::ToCachedSize(data_size);\n"
+ "$cached_byte_size_field$.store(cached_size,\n"
" std::memory_order_relaxed);\n"
"total_size += data_size;\n");
} else {
@@ -396,7 +398,7 @@ void RepeatedEnumFieldGenerator::GenerateConstinitInitializer(
format("$name$_()");
if (descriptor_->is_packed() &&
HasGeneratedMethods(descriptor_->file(), options_)) {
- format("\n, _$name$_cached_byte_size_(0)");
+ format("\n, $cached_byte_size_name$(0)");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
index e65ec0f5c0..2a4ca5162b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/cpp/cpp_field.h>
namespace google {
@@ -47,7 +48,7 @@ namespace cpp {
class EnumFieldGenerator : public FieldGenerator {
public:
EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
- ~EnumFieldGenerator();
+ ~EnumFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
@@ -71,7 +72,7 @@ class EnumOneofFieldGenerator : public EnumFieldGenerator {
public:
EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~EnumOneofFieldGenerator();
+ ~EnumOneofFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
@@ -87,7 +88,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator {
public:
RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~RepeatedEnumFieldGenerator();
+ ~RepeatedEnumFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
index 72893b81c9..ef6cc81241 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
@@ -33,11 +33,13 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/cpp/cpp_extension.h>
+
#include <map>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/descriptor.pb.h>
+
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/descriptor.pb.h>
namespace google {
namespace protobuf {
@@ -76,6 +78,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
break;
}
SetCommonVars(options, &variables_);
+ SetCommonMessageDataVariables(&variables_);
variables_["extendee"] =
QualifiedClassName(descriptor_->containing_type(), options_);
variables_["type_traits"] = type_traits_;
@@ -91,6 +94,19 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["scope"] = scope;
variables_["scoped_name"] = ExtensionName(descriptor_);
variables_["number"] = StrCat(descriptor_->number());
+
+ bool add_verify_fn =
+ // Only verify msgs.
+ descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
+ // Options say to verify.
+ ShouldVerify(descriptor_->message_type(), options_, scc_analyzer_) &&
+ ShouldVerify(descriptor_->containing_type(), options_, scc_analyzer_);
+
+ variables_["verify_fn"] =
+ add_verify_fn
+ ? StrCat("&", FieldMessageTypeName(descriptor_, options_),
+ "::InternalVerify")
+ : "nullptr";
}
ExtensionGenerator::~ExtensionGenerator() {}
@@ -164,23 +180,11 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
}
format(
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY "
+ "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 "
"::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
- " ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$ >\n"
- " $scoped_name$($constant_name$, $1$);\n",
+ " ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$>\n"
+ " $scoped_name$($constant_name$, $1$, $verify_fn$);\n",
default_str);
-
- // Register extension verify function if needed.
- if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- ShouldVerify(descriptor_->message_type(), options_, scc_analyzer_) &&
- ShouldVerify(descriptor_->containing_type(), options_, scc_analyzer_)) {
- format(
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY "
- "::$proto_ns$::internal::RegisterExtensionVerify< $extendee$,\n"
- " $1$, $number$> $2$_$name$_register;\n",
- ClassName(descriptor_->message_type(), true),
- IsScoped() ? ClassName(descriptor_->extension_scope(), false) : "");
- }
}
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
index 5f167a4d01..895f094c70 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
@@ -38,19 +38,19 @@
#include <memory>
#include <string>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
#include <google/protobuf/compiler/cpp/cpp_string_field.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
#include <google/protobuf/compiler/cpp/cpp_enum_field.h>
#include <google/protobuf/compiler/cpp/cpp_map_field.h>
#include <google/protobuf/compiler/cpp/cpp_message_field.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
namespace google {
namespace protobuf {
@@ -81,7 +81,7 @@ TProtoStringType GenerateTemplateForOneofString(const FieldDescriptor* descripto
TProtoStringType field_name = google::protobuf::compiler::cpp::FieldName(descriptor);
TProtoStringType field_pointer =
descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
- ? "$0.GetPointer()"
+ ? "$0.UnsafeGetPointer()"
: "$0";
if (descriptor->default_value_string().empty()) {
@@ -103,7 +103,7 @@ TProtoStringType GenerateTemplateForOneofString(const FieldDescriptor* descripto
return strings::Substitute(
StrCat("_internal_has_", field_name, "() ? ", field_pointer, " : ",
default_value_pointer),
- field_member, MakeDefaultName(descriptor));
+ field_member, MakeDefaultFieldName(descriptor));
}
TProtoStringType GenerateTemplateForSingleString(const FieldDescriptor* descriptor,
@@ -114,8 +114,8 @@ TProtoStringType GenerateTemplateForSingleString(const FieldDescriptor* descript
if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) {
return strings::Substitute(
- "$0.IsDefault(nullptr) ? &$1.get() : $0.GetPointer()", field_member,
- MakeDefaultName(descriptor));
+ "$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()", field_member,
+ MakeDefaultFieldName(descriptor));
}
return StrCat("&", field_member);
@@ -150,14 +150,12 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor,
google::protobuf::FileOptions::LITE_RUNTIME) {
return;
}
- TProtoStringType field_member = (*variables)["field_member"];
+ TProtoStringType field_member = (*variables)["field"];
const google::protobuf::OneofDescriptor* oneof_member =
descriptor->real_containing_oneof();
- if (oneof_member) {
- field_member = StrCat(oneof_member->name(), "_.", field_member);
- }
const TProtoStringType proto_ns = (*variables)["proto_ns"];
- const TProtoStringType substitute_template_prefix = " _tracker_.$1<$0>(this, ";
+ const TProtoStringType substitute_template_prefix =
+ StrCat(" ", (*variables)["tracker"], ".$1<$0>(this, ");
TProtoStringType prepared_template;
// Flat template is needed if the prepared one is introspecting the values
@@ -178,7 +176,7 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor,
} else if (descriptor->is_map()) {
prepared_template = "nullptr";
} else if (descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
- !descriptor->options().lazy()) {
+ !IsExplicitLazy(descriptor)) {
prepared_template = "nullptr";
} else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
if (oneof_member) {
@@ -238,13 +236,15 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
const Options& options) {
SetCommonVars(options, variables);
+ SetCommonMessageDataVariables(variables);
+
(*variables)["ns"] = Namespace(descriptor, options);
(*variables)["name"] = FieldName(descriptor);
(*variables)["index"] = StrCat(descriptor->index());
(*variables)["number"] = StrCat(descriptor->number());
(*variables)["classname"] = ClassName(FieldScope(descriptor), false);
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
- (*variables)["field_member"] = FieldName(descriptor) + "_";
+ (*variables)["field"] = FieldMemberName(descriptor);
(*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
@@ -254,7 +254,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["clear_hasbit"] = "";
if (HasHasbit(descriptor)) {
(*variables)["set_hasbit_io"] =
- "_Internal::set_has_" + FieldName(descriptor) + "(&_has_bits_);";
+ StrCat("_Internal::set_has_", FieldName(descriptor), "(&",
+ (*variables)["has_bits"], ");");
} else {
(*variables)["set_hasbit_io"] = "";
}
@@ -275,10 +276,10 @@ void FieldGenerator::SetHasBitIndex(arc_i32 has_bit_index) {
return;
}
variables_["set_hasbit"] = StrCat(
- "_has_bits_[", has_bit_index / 32, "] |= 0x",
+ variables_["has_bits"], "[", has_bit_index / 32, "] |= 0x",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
variables_["clear_hasbit"] = StrCat(
- "_has_bits_[", has_bit_index / 32, "] &= ~0x",
+ variables_["has_bits"], "[", has_bit_index / 32, "] &= ~0x",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
}
@@ -287,12 +288,17 @@ void FieldGenerator::SetInlinedStringIndex(arc_i32 inlined_string_index) {
GOOGLE_CHECK_EQ(inlined_string_index, -1);
return;
}
+ // The first bit is the tracking bit for on demand registering ArenaDtor.
+ GOOGLE_CHECK_GT(inlined_string_index, 0)
+ << "_inlined_string_donated_'s bit 0 is reserved for arena dtor tracking";
variables_["inlined_string_donated"] = StrCat(
- "(_inlined_string_donated_[", inlined_string_index / 32, "] & 0x",
+ "(", variables_["inlined_string_donated_array"], "[",
+ inlined_string_index / 32, "] & 0x",
strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8),
"u) != 0;");
variables_["donating_states_word"] =
- StrCat("_inlined_string_donated_[", inlined_string_index / 32, "]");
+ StrCat(variables_["inlined_string_donated_array"], "[",
+ inlined_string_index / 32, "]");
variables_["mask_for_undonate"] = StrCat(
"~0x", strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8),
"u");
@@ -303,8 +309,6 @@ void SetCommonOneofFieldVariables(
std::map<TProtoStringType, TProtoStringType>* variables) {
const TProtoStringType prefix = descriptor->containing_oneof()->name() + "_.";
(*variables)["oneof_name"] = descriptor->containing_oneof()->name();
- (*variables)["field_member"] =
- StrCat(prefix, (*variables)["name"], "_");
}
FieldGenerator::~FieldGenerator() {}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
index e3386f446a..9c3ec7fde4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
@@ -40,9 +40,9 @@
#include <memory>
#include <string>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
-#include <google/protobuf/descriptor.h>
namespace google {
namespace protobuf {
@@ -158,11 +158,10 @@ class FieldGenerator {
// Generate a manual destructor invocation for use when the message is on an
// arena. The code that this method generates will be executed inside a
// shared-for-the-whole-message-class method registered with
- // OwnDestructor(). The method should return |true| if it generated any code
- // that requires a call; this allows the message generator to eliminate the
- // OwnDestructor() registration if no fields require it.
- virtual bool GenerateArenaDestructorCode(io::Printer* printer) const {
- return false;
+ // OwnDestructor().
+ virtual void GenerateArenaDestructorCode(io::Printer* printer) const {
+ GOOGLE_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone)
+ << descriptor_->cpp_type_name();
}
// Generate initialization code for private members declared by
@@ -187,6 +186,10 @@ class FieldGenerator {
virtual bool IsInlined() const { return false; }
+ virtual ArenaDtorNeeds NeedsArenaDestructor() const {
+ return ArenaDtorNeeds::kNone;
+ }
+
void SetHasBitIndex(arc_i32 has_bit_index);
void SetInlinedStringIndex(arc_i32 inlined_string_index);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
index 2a98ad0b02..f27d876e2a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -43,16 +43,16 @@
#include <unordered_set>
#include <vector>
+#include <google/protobuf/compiler/scc.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/cpp/cpp_enum.h>
#include <google/protobuf/compiler/cpp/cpp_extension.h>
#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_message.h>
#include <google/protobuf/compiler/cpp/cpp_service.h>
-#include <google/protobuf/compiler/scc.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
// Must be last.
#include <google/protobuf/port_def.inc>
@@ -88,6 +88,23 @@ std::vector<const T*> Sorted(const std::unordered_set<const T*>& vals) {
return sorted;
}
+// TODO(b/203101078): remove pragmas that suppresses uninitialized warnings when
+// clang bug is fixed.
+inline void MuteWuninitialized(Formatter& format) {
+ format(
+ "#if defined(__llvm__)\n"
+ " #pragma clang diagnostic push\n"
+ " #pragma clang diagnostic ignored \"-Wuninitialized\"\n"
+ "#endif // __llvm__\n");
+}
+
+inline void UnmuteWuninitialized(Formatter& format) {
+ format(
+ "#if defined(__llvm__)\n"
+ " #pragma clang diagnostic pop\n"
+ "#endif // __llvm__\n");
+}
+
} // namespace
FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
@@ -347,7 +364,14 @@ void FileGenerator::DoIncludeFile(const TProtoStringType& google3_name,
options_.runtime_include_base, path);
}
} else {
- format("#include \"$1$\"", google3_name);
+ TProtoStringType path = google3_name;
+ // The bootstrapped proto generated code needs to use the
+ // third_party/protobuf header paths to avoid circular dependencies.
+ if (options_.bootstrap) {
+ path = StringReplace(google3_name, "net/proto2/public",
+ "third_party/protobuf", false);
+ }
+ format("#include \"$1$\"", path);
}
if (do_export) {
@@ -444,12 +468,28 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) {
format("// @@protoc_insertion_point(includes)\n");
IncludeFile("net/proto2/public/port_def.inc", printer);
+}
+
+void FileGenerator::GenerateSourcePrelude(io::Printer* printer) {
+ Formatter format(printer, variables_);
// For MSVC builds, we use #pragma init_seg to move the initialization of our
// libraries to happen before the user code.
// This worksaround the fact that MSVC does not do constant initializers when
// required by the standard.
format("\nPROTOBUF_PRAGMA_INIT_SEG\n");
+
+ // Generate convenience aliases.
+ format(
+ "\n"
+ "namespace _pb = ::$1$;\n"
+ "namespace _pbi = _pb::internal;\n",
+ ProtobufNamespace(options_));
+ if (HasGeneratedMethods(file_, options_) &&
+ options_.tctable_mode != Options::kTCTableNever) {
+ format("namespace _fl = _pbi::field_layout;\n");
+ }
+ format("\n");
}
void FileGenerator::GenerateSourceDefaultInstance(int idx,
@@ -462,8 +502,8 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
// destructor that we need to elide.
format(
"struct $1$ {\n"
- " constexpr $1$()\n"
- " : _instance(::$proto_ns$::internal::ConstantInitialized{}) {}\n"
+ " PROTOBUF_CONSTEXPR $1$()\n"
+ " : _instance(::_pbi::ConstantInitialized{}) {}\n"
" ~$1$() {}\n"
" union {\n"
" $2$ _instance;\n"
@@ -475,7 +515,8 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
// enough. However, the empty destructor fails to be elided in some
// configurations (like non-opt or with certain sanitizers). NO_DESTROY is
// there just to improve performance and binary size in these builds.
- format("PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT $1$ $2$;\n",
+ format("PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT "
+ "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n",
DefaultInstanceType(generator->descriptor_, options_),
DefaultInstanceName(generator->descriptor_, options_));
@@ -484,19 +525,21 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
if (IsStringInlined(field, options_)) {
// Force the initialization of the inlined string in the default instance.
format(
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY std::true_type "
+ "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type "
"$1$::_init_inline_$2$_ = "
- "($3$._instance.$2$_.Init(), std::true_type{});\n",
+ "($3$._instance.$4$.Init(), std::true_type{});\n",
ClassName(generator->descriptor_), FieldName(field),
- DefaultInstanceName(generator->descriptor_, options_));
+ DefaultInstanceName(generator->descriptor_, options_),
+ FieldMemberName(field));
}
}
if (options_.lite_implicit_weak_fields) {
- format("$1$* $2$ = &$3$;\n",
- DefaultInstanceType(generator->descriptor_, options_),
- DefaultInstancePtr(generator->descriptor_, options_),
- DefaultInstanceName(generator->descriptor_, options_));
+ format(
+ "PROTOBUF_CONSTINIT const void* $1$ =\n"
+ " &$2$;\n",
+ DefaultInstancePtr(generator->descriptor_, options_),
+ DefaultInstanceName(generator->descriptor_, options_));
}
}
@@ -550,11 +593,10 @@ void FileGenerator::GenerateInternalForwardDeclarations(
for (auto instance : Sorted(refs.weak_default_instances)) {
ns.ChangeTo(Namespace(instance, options_));
if (options_.lite_implicit_weak_fields) {
- format("extern $1$ $2$;\n", DefaultInstanceType(instance, options_),
- DefaultInstanceName(instance, options_));
- format("__attribute__((weak)) $1$* $2$ = nullptr;\n",
- DefaultInstanceType(instance, options_),
- DefaultInstancePtr(instance, options_));
+ format(
+ "PROTOBUF_CONSTINIT __attribute__((weak)) const void* $1$ =\n"
+ " &::_pbi::implicit_weak_message_default_instance;\n",
+ DefaultInstancePtr(instance, options_));
} else {
format("extern __attribute__((weak)) $1$ $2$;\n",
DefaultInstanceType(instance, options_),
@@ -565,8 +607,7 @@ void FileGenerator::GenerateInternalForwardDeclarations(
for (auto file : Sorted(refs.weak_reflection_files)) {
format(
- "extern __attribute__((weak)) const "
- "::$proto_ns$::internal::DescriptorTable $1$;\n",
+ "extern __attribute__((weak)) const ::_pbi::DescriptorTable $1$;\n",
DescriptorTableName(file, options_));
}
}
@@ -574,6 +615,9 @@ void FileGenerator::GenerateInternalForwardDeclarations(
void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
Formatter format(printer, variables_);
GenerateSourceIncludes(printer);
+ GenerateSourcePrelude(printer);
+
+ if (IsAnyMessage(file_, options_)) MuteWuninitialized(format);
CrossFileReferences refs;
ForEachField(message_generators_[idx]->descriptor_,
@@ -602,6 +646,8 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
message_generators_[idx]->GenerateSourceInProto2Namespace(printer);
}
+ if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format);
+
format(
"\n"
"// @@protoc_insertion_point(global_scope)\n");
@@ -610,6 +656,7 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* printer) {
Formatter format(printer, variables_);
GenerateSourceIncludes(printer);
+ GenerateSourcePrelude(printer);
NamespaceOpener ns(Namespace(file_, options_), format);
extension_generators_[idx]->GenerateDefinition(printer);
}
@@ -617,10 +664,9 @@ void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* printer) {
void FileGenerator::GenerateGlobalSource(io::Printer* printer) {
Formatter format(printer, variables_);
GenerateSourceIncludes(printer);
+ GenerateSourcePrelude(printer);
{
- GenerateTables(printer);
-
// Define the code to initialize reflection. This code uses a global
// constructor to register reflection data with the runtime pre-main.
if (HasDescriptorMethods(file_, options_)) {
@@ -639,10 +685,13 @@ void FileGenerator::GenerateGlobalSource(io::Printer* printer) {
void FileGenerator::GenerateSource(io::Printer* printer) {
Formatter format(printer, variables_);
GenerateSourceIncludes(printer);
+ GenerateSourcePrelude(printer);
CrossFileReferences refs;
GetCrossFileReferencesForFile(file_, &refs);
GenerateInternalForwardDeclarations(refs, printer);
+ if (IsAnyMessage(file_, options_)) MuteWuninitialized(format);
+
{
NamespaceOpener ns(Namespace(file_, options_), format);
@@ -653,8 +702,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
}
{
- GenerateTables(printer);
-
if (HasDescriptorMethods(file_, options_)) {
// Define the code to initialize reflection. This code uses a global
// constructor to register reflection data with the runtime pre-main.
@@ -711,6 +758,8 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"\n"
"// @@protoc_insertion_point(global_scope)\n");
+ if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format);
+
IncludeFile("net/proto2/public/port_undef.inc", printer);
}
@@ -718,31 +767,30 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
Formatter format(printer, variables_);
if (!message_generators_.empty()) {
- format("static ::$proto_ns$::Metadata $file_level_metadata$[$1$];\n",
+ format("static ::_pb::Metadata $file_level_metadata$[$1$];\n",
message_generators_.size());
}
if (!enum_generators_.empty()) {
format(
- "static "
- "const ::$proto_ns$::EnumDescriptor* "
+ "static const ::_pb::EnumDescriptor* "
"$file_level_enum_descriptors$[$1$];\n",
enum_generators_.size());
} else {
format(
"static "
- "constexpr ::$proto_ns$::EnumDescriptor const** "
+ "constexpr ::_pb::EnumDescriptor const** "
"$file_level_enum_descriptors$ = nullptr;\n");
}
if (HasGenericServices(file_, options_) && file_->service_count() > 0) {
format(
"static "
- "const ::$proto_ns$::ServiceDescriptor* "
+ "const ::_pb::ServiceDescriptor* "
"$file_level_service_descriptors$[$1$];\n",
file_->service_count());
} else {
format(
"static "
- "constexpr ::$proto_ns$::ServiceDescriptor const** "
+ "constexpr ::_pb::ServiceDescriptor const** "
"$file_level_service_descriptors$ = nullptr;\n");
}
@@ -760,7 +808,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
format.Outdent();
format(
"};\n"
- "static const ::$proto_ns$::internal::MigrationSchema schemas[] "
+ "static const ::_pbi::MigrationSchema schemas[] "
"PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
{
@@ -774,16 +822,13 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
format.Outdent();
format(
"};\n"
- "\nstatic "
- "::$proto_ns$::Message const * const file_default_instances[] = {\n");
+ "\nstatic const ::_pb::Message* const file_default_instances[] = {\n");
format.Indent();
for (int i = 0; i < message_generators_.size(); i++) {
const Descriptor* descriptor = message_generators_[i]->descriptor_;
- format(
- "reinterpret_cast<const "
- "::$proto_ns$::Message*>(&$1$::_$2$_default_instance_),\n",
- Namespace(descriptor, options_), // 1
- ClassName(descriptor)); // 2
+ format("&$1$::_$2$_default_instance_._instance,\n",
+ Namespace(descriptor, options_), // 1
+ ClassName(descriptor)); // 2
}
format.Outdent();
format(
@@ -794,10 +839,8 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
format(
// MSVC doesn't like empty arrays, so we add a dummy.
"const $uint32$ $tablename$::offsets[1] = {};\n"
- "static constexpr ::$proto_ns$::internal::MigrationSchema* schemas = "
- "nullptr;"
- "\n"
- "static constexpr ::$proto_ns$::Message* const* "
+ "static constexpr ::_pbi::MigrationSchema* schemas = nullptr;\n"
+ "static constexpr ::_pb::Message* const* "
"file_default_instances = nullptr;\n"
"\n");
}
@@ -852,7 +895,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// Build array of DescriptorTable deps.
if (num_deps > 0) {
format(
- "static const ::$proto_ns$::internal::DescriptorTable*const "
+ "static const ::_pbi::DescriptorTable* const "
"$desc_table$_deps[$1$] = {\n",
num_deps);
@@ -872,13 +915,14 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// so disable for now.
bool eager = false;
format(
- "static ::$proto_ns$::internal::once_flag $desc_table$_once;\n"
- "const ::$proto_ns$::internal::DescriptorTable $desc_table$ = {\n"
- " false, $1$, $2$, $3$, \"$filename$\", \n"
- " &$desc_table$_once, $4$, $5$, $6$,\n"
- " schemas, file_default_instances, $tablename$::offsets,\n"
- " $7$, $file_level_enum_descriptors$, "
- "$file_level_service_descriptors$,\n"
+ "static ::_pbi::once_flag $desc_table$_once;\n"
+ "const ::_pbi::DescriptorTable $desc_table$ = {\n"
+ " false, $1$, $2$, $3$,\n"
+ " \"$filename$\",\n"
+ " &$desc_table$_once, $4$, $5$, $6$,\n"
+ " schemas, file_default_instances, $tablename$::offsets,\n"
+ " $7$, $file_level_enum_descriptors$,\n"
+ " $file_level_service_descriptors$,\n"
"};\n"
// This function exists to be marked as weak.
// It can significantly speed up compilation by breaking up LLVM's SCC in
@@ -891,7 +935,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// vtables -> GetMetadata
// By adding a weak function here we break the connection from the
// individual vtables back into the descriptor table.
- "PROTOBUF_ATTRIBUTE_WEAK const ::$proto_ns$::internal::DescriptorTable* "
+ "PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* "
"$desc_table$_getter() {\n"
" return &$desc_table$;\n"
"}\n"
@@ -909,123 +953,12 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
if (file_->name() != "net/proto2/proto/descriptor.proto") {
format(
"// Force running AddDescriptors() at dynamic initialization time.\n"
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY "
- "static ::$proto_ns$::internal::AddDescriptorsRunner "
- "$1$(&$desc_table$);\n",
+ "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 "
+ "static ::_pbi::AddDescriptorsRunner $1$(&$desc_table$);\n",
UniqueName("dynamic_init_dummy", file_, options_));
}
}
-void FileGenerator::GenerateTables(io::Printer* printer) {
- Formatter format(printer, variables_);
- if (options_.table_driven_parsing) {
- // TODO(ckennelly): Gate this with the same options flag to enable
- // table-driven parsing.
- format(
- "PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTableField\n"
- " const $tablename$::entries[] "
- "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
- format.Indent();
-
- std::vector<size_t> entries;
- size_t count = 0;
- for (int i = 0; i < message_generators_.size(); i++) {
- size_t value = message_generators_[i]->GenerateParseOffsets(printer);
- entries.push_back(value);
- count += value;
- }
-
- // We need these arrays to exist, and MSVC does not like empty arrays.
- if (count == 0) {
- format("{0, 0, 0, ::$proto_ns$::internal::kInvalidMask, 0, 0},\n");
- }
-
- format.Outdent();
- format(
- "};\n"
- "\n"
- "PROTOBUF_CONSTEXPR_VAR "
- "::$proto_ns$::internal::AuxiliaryParseTableField\n"
- " const $tablename$::aux[] "
- "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
- format.Indent();
-
- std::vector<size_t> aux_entries;
- count = 0;
- for (int i = 0; i < message_generators_.size(); i++) {
- size_t value = message_generators_[i]->GenerateParseAuxTable(printer);
- aux_entries.push_back(value);
- count += value;
- }
-
- if (count == 0) {
- format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n");
- }
-
- format.Outdent();
- format(
- "};\n"
- "PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTable const\n"
- " $tablename$::schema[] "
- "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
- format.Indent();
-
- size_t offset = 0;
- size_t aux_offset = 0;
- for (int i = 0; i < message_generators_.size(); i++) {
- message_generators_[i]->GenerateParseTable(printer, offset, aux_offset);
- offset += entries[i];
- aux_offset += aux_entries[i];
- }
-
- if (message_generators_.empty()) {
- format("{ nullptr, nullptr, 0, -1, -1, false },\n");
- }
-
- format.Outdent();
- format(
- "};\n"
- "\n");
- }
-
- if (!message_generators_.empty() && options_.table_driven_serialization) {
- format(
- "const ::$proto_ns$::internal::FieldMetadata "
- "$tablename$::field_metadata[] "
- "= {\n");
- format.Indent();
- std::vector<int> field_metadata_offsets;
- int idx = 0;
- for (int i = 0; i < message_generators_.size(); i++) {
- field_metadata_offsets.push_back(idx);
- idx += message_generators_[i]->GenerateFieldMetadata(printer);
- }
- field_metadata_offsets.push_back(idx);
- format.Outdent();
- format(
- "};\n"
- "const ::$proto_ns$::internal::SerializationTable "
- "$tablename$::serialization_table[] = {\n");
- format.Indent();
- // We rely on the order we layout the tables to match the order we
- // calculate them with FlattenMessagesInFile, so we check here that
- // these match exactly.
- std::vector<const Descriptor*> calculated_order =
- FlattenMessagesInFile(file_);
- GOOGLE_CHECK_EQ(calculated_order.size(), message_generators_.size());
- for (int i = 0; i < message_generators_.size(); i++) {
- GOOGLE_CHECK_EQ(calculated_order[i], message_generators_[i]->descriptor_);
- format("{$1$, $tablename$::field_metadata + $2$},\n",
- field_metadata_offsets[i + 1] - field_metadata_offsets[i], // 1
- field_metadata_offsets[i]); // 2
- }
- format.Outdent();
- format(
- "};\n"
- "\n");
- }
-}
-
class FileGenerator::ForwardDeclarations {
public:
void AddMessage(const Descriptor* d) { classes_[ClassName(d)] = d; }
@@ -1229,7 +1162,6 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
if (HasSimpleBaseClasses(file_, options_)) {
IncludeFile("net/proto2/public/generated_message_bases.h", printer);
}
- IncludeFile("net/proto2/public/generated_message_table_driven.h", printer);
if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
IncludeFile("net/proto2/public/generated_message_tctable_decl.h", printer);
@@ -1362,20 +1294,8 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
"\n"
"// Internal implementation detail -- do not use these members.\n"
"struct $dllexport_decl $$tablename$ {\n"
- // These tables describe how to serialize and parse messages. Used
- // for table driven code.
- " static const ::$proto_ns$::internal::ParseTableField entries[]\n"
- " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
- " static const ::$proto_ns$::internal::AuxiliaryParseTableField aux[]\n"
- " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
- " static const ::$proto_ns$::internal::ParseTable schema[$1$]\n"
- " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
- " static const ::$proto_ns$::internal::FieldMetadata field_metadata[];\n"
- " static const ::$proto_ns$::internal::SerializationTable "
- "serialization_table[];\n"
" static const $uint32$ offsets[];\n"
- "};\n",
- std::max(size_t(1), message_generators_.size()));
+ "};\n");
if (HasDescriptorMethods(file_, options_)) {
format(
"$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable "
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
index 041d5ea4ab..d8eff2feed 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -40,11 +40,12 @@
#include <set>
#include <string>
#include <vector>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/compiler/scc.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
namespace protobuf {
@@ -123,11 +124,11 @@ class FileGenerator {
void GenerateInternalForwardDeclarations(const CrossFileReferences& refs,
io::Printer* printer);
void GenerateSourceIncludes(io::Printer* printer);
+ void GenerateSourcePrelude(io::Printer* printer);
void GenerateSourceDefaultInstance(int idx, io::Printer* printer);
void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs,
io::Printer* printer);
- void GenerateTables(io::Printer* printer);
void GenerateReflectionInitializationCode(io::Printer* printer);
// For other imports, generates their forward-declarations.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
index 3673c09a61..69443f5bf2 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -40,11 +40,11 @@
#include <vector>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/compiler/cpp/cpp_file.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
namespace google {
namespace protobuf {
@@ -82,6 +82,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
// FOO_EXPORT is a macro which should expand to __declspec(dllexport) or
// __declspec(dllimport) depending on what is being compiled.
//
+ // If the proto_h option is passed to the compiler, we will generate all
+ // classes and enums so that they can be forward-declared from files that
+ // need them from imports.
+ //
+ // If the lite option is passed to the compiler, we will generate the
+ // current files and all transitive dependencies using the LITE runtime.
Options file_options;
file_options.opensource_runtime = opensource_runtime_;
@@ -109,8 +115,10 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options.lite_implicit_weak_fields = true;
if (!options[i].second.empty()) {
file_options.num_cc_files =
- strto32(options[i].second.c_str(), NULL, 10);
+ strto32(options[i].second.c_str(), nullptr, 10);
}
+ } else if (options[i].first == "proto_h") {
+ file_options.proto_h = true;
} else if (options[i].first == "annotate_accessor") {
file_options.annotate_accessor = true;
} else if (options[i].first == "inject_field_listener_events") {
@@ -127,14 +135,14 @@ bool CppGenerator::Generate(const FileDescriptor* file,
.insert(options[i].second.substr(pos, next_pos - pos));
pos = next_pos + 1;
} while (pos < options[i].second.size());
+ } else if (options[i].first == "verified_lazy_message_sets") {
+ file_options.unverified_lazy_message_sets = false;
+ } else if (options[i].first == "unverified_lazy_message_sets") {
+ file_options.unverified_lazy_message_sets = true;
} else if (options[i].first == "eagerly_verified_lazy") {
file_options.eagerly_verified_lazy = true;
} else if (options[i].first == "force_eagerly_verified_lazy") {
file_options.force_eagerly_verified_lazy = true;
- } else if (options[i].first == "table_driven_parsing") {
- file_options.table_driven_parsing = true;
- } else if (options[i].first == "table_driven_serialization") {
- file_options.table_driven_serialization = true;
} else if (options[i].first == "experimental_tail_call_table_mode") {
if (options[i].second == "never") {
file_options.tctable_mode = Options::kTCTableNever;
@@ -185,7 +193,7 @@ bool CppGenerator::Generate(const FileDescriptor* file,
TProtoStringType info_path = basename + ".proto.h.meta";
io::Printer printer(
output.get(), '$',
- file_options.annotate_headers ? &annotation_collector : NULL);
+ file_options.annotate_headers ? &annotation_collector : nullptr);
file_generator.GenerateProtoHeader(
&printer, file_options.annotate_headers ? info_path : "");
if (file_options.annotate_headers) {
@@ -204,7 +212,7 @@ bool CppGenerator::Generate(const FileDescriptor* file,
TProtoStringType info_path = basename + ".pb.h.meta";
io::Printer printer(
output.get(), '$',
- file_options.annotate_headers ? &annotation_collector : NULL);
+ file_options.annotate_headers ? &annotation_collector : nullptr);
file_generator.GeneratePBHeader(
&printer, file_options.annotate_headers ? info_path : "");
if (file_options.annotate_headers) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
index 235d02325f..aa63845d30 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
@@ -40,6 +40,7 @@
#include <string>
#include <google/protobuf/compiler/code_generator.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -54,7 +55,7 @@ namespace cpp {
class PROTOC_EXPORT CppGenerator : public CodeGenerator {
public:
CppGenerator();
- ~CppGenerator();
+ ~CppGenerator() override;
enum class Runtime {
kGoogle3, // Use the internal google3 runtime.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index 5191a7e730..f726d0fc9b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -44,10 +44,10 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/compiler/cpp/cpp_names.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/compiler/scc.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
@@ -233,6 +233,18 @@ void SetCommonVars(const Options& options,
(*variables)["string"] = "TProtoStringType";
}
+void SetCommonMessageDataVariables(
+ std::map<TProtoStringType, TProtoStringType>* variables) {
+ (*variables)["any_metadata"] = "_any_metadata_";
+ (*variables)["cached_size"] = "_cached_size_";
+ (*variables)["extensions"] = "_extensions_";
+ (*variables)["has_bits"] = "_has_bits_";
+ (*variables)["inlined_string_donated_array"] = "_inlined_string_donated_";
+ (*variables)["oneof_case"] = "_oneof_case_";
+ (*variables)["tracker"] = "_tracker_";
+ (*variables)["weak_field_map"] = "_weak_field_map_";
+}
+
void SetUnknownFieldsVariable(const Descriptor* descriptor,
const Options& options,
std::map<TProtoStringType, TProtoStringType>* variables) {
@@ -457,6 +469,14 @@ TProtoStringType FieldName(const FieldDescriptor* field) {
return result;
}
+TProtoStringType FieldMemberName(const FieldDescriptor* field) {
+ if (field->real_containing_oneof() == nullptr) {
+ return StrCat(FieldName(field), "_");
+ }
+ return StrCat(field->containing_oneof()->name(), "_.", FieldName(field),
+ "_");
+}
+
TProtoStringType OneofCaseConstantName(const FieldDescriptor* field) {
GOOGLE_DCHECK(field->containing_oneof());
TProtoStringType field_name = UnderscoresToCamelCase(field->name(), true);
@@ -1151,7 +1171,6 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
return UsingImplicitWeakFields(field->file(), options) &&
field->type() == FieldDescriptor::TYPE_MESSAGE &&
!field->is_required() && !field->is_map() && !field->is_extension() &&
- !field->real_containing_oneof() &&
!IsWellKnownMessage(field->message_type()->file()) &&
field->message_type()->file()->name() !=
"net/proto2/proto/descriptor.proto" &&
@@ -1268,7 +1287,7 @@ bool GetBootstrapBasename(const Options& options, const TProtoStringType& basena
std::unordered_map<TProtoStringType, TProtoStringType> bootstrap_mapping{
{"net/proto2/proto/descriptor",
- "net/proto2/internal/descriptor"},
+ "third_party/protobuf/descriptor"},
{"net/proto2/compiler/proto/plugin",
"net/proto2/compiler/proto/plugin"},
{"net/proto2/compiler/proto/profile",
@@ -1301,7 +1320,7 @@ bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
*basename = bootstrap_basename;
return false;
} else {
- TProtoStringType forward_to_basename = bootstrap_basename;
+ const TProtoStringType& forward_to_basename = bootstrap_basename;
// Generate forwarding headers and empty .pb.cc.
{
@@ -1490,8 +1509,9 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
return FileOptions::SPEED;
}
-bool EnableMessageOwnedArena(const Descriptor* desc) {
+bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options) {
(void)desc;
+ (void)options;
return false;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
index ceb9a54f38..f7735da12f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -41,10 +41,10 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
-#include <google/protobuf/compiler/cpp/cpp_names.h>
#include <google/protobuf/compiler/scc.h>
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/compiler/cpp/cpp_names.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
@@ -59,6 +59,8 @@ namespace protobuf {
namespace compiler {
namespace cpp {
+enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 };
+
inline TProtoStringType ProtobufNamespace(const Options& /* options */) {
return "PROTOBUF_NAMESPACE_ID";
}
@@ -85,6 +87,10 @@ extern const char kThinSeparator[];
void SetCommonVars(const Options& options,
std::map<TProtoStringType, TProtoStringType>* variables);
+// Variables to access message data from the message scope.
+void SetCommonMessageDataVariables(
+ std::map<TProtoStringType, TProtoStringType>* variables);
+
void SetUnknownFieldsVariable(const Descriptor* descriptor,
const Options& options,
std::map<TProtoStringType, TProtoStringType>* variables);
@@ -186,6 +192,9 @@ TProtoStringType ResolveKeyword(const TProtoStringType& name);
// anyway, so normally this just returns field->name().
TProtoStringType FieldName(const FieldDescriptor* field);
+// Returns the (unqualified) private member name for this field in C++ code.
+TProtoStringType FieldMemberName(const FieldDescriptor* field);
+
// Returns an estimate of the compiler's alignment for the field. This
// can't guarantee to be correct because the generated code could be compiled on
// different systems with different alignment rules. The estimates below assume
@@ -348,9 +357,16 @@ bool HasLazyFields(const FileDescriptor* file, const Options& options,
bool IsLazy(const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
+// Is this an explicit (non-profile driven) lazy field, as denoted by
+// lazy/unverified_lazy in the descriptor?
+inline bool IsExplicitLazy(const FieldDescriptor* field) {
+ return field->options().lazy() || field->options().unverified_lazy();
+}
+
inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
const Options& options) {
- return field->options().lazy() && !field->is_repeated() &&
+ // TODO(b/211906113): Make lazy() imply eagerly verified lazy.
+ return IsExplicitLazy(field) && !field->is_repeated() &&
field->type() == FieldDescriptor::TYPE_MESSAGE &&
GetOptimizeFor(field->file(), options) != FileOptions::LITE_RUNTIME &&
!options.opensource_runtime;
@@ -359,7 +375,8 @@ inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
inline bool IsEagerlyVerifiedLazy(const FieldDescriptor* field,
const Options& options,
MessageSCCAnalyzer* scc_analyzer) {
- return IsLazy(field, options, scc_analyzer) && !field->options().lazy();
+ // TODO(b/211906113): Make lazy() imply eagerly verified lazy.
+ return IsLazy(field, options, scc_analyzer) && !IsExplicitLazy(field);
}
inline bool IsFieldUsed(const FieldDescriptor* /* field */,
@@ -472,6 +489,43 @@ inline TProtoStringType MakeDefaultName(const FieldDescriptor* field) {
"_";
}
+// Semantically distinct from MakeDefaultName in that it gives the C++ code
+// referencing a default field from the message scope, rather than just the
+// variable name.
+// For example, declarations of default variables should always use just
+// MakeDefaultName to produce code like:
+// Type _i_give_permission_to_break_this_code_default_field_;
+//
+// Code that references these should use MakeDefaultFieldName, in case the field
+// exists at some nested level like:
+// internal_container_._i_give_permission_to_break_this_code_default_field_;
+inline TProtoStringType MakeDefaultFieldName(const FieldDescriptor* field) {
+ return MakeDefaultName(field);
+}
+
+inline TProtoStringType MakeVarintCachedSizeName(const FieldDescriptor* field) {
+ return StrCat("_", FieldName(field), "_cached_byte_size_");
+}
+
+// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++
+// code referencing the object from the message scope, rather than just the
+// variable name.
+// For example, declarations of default variables should always use just
+// MakeVarintCachedSizeName to produce code like:
+// Type _field_cached_byte_size_;
+//
+// Code that references these variables should use
+// MakeVarintCachedSizeFieldName, in case the field exists at some nested level
+// like:
+// internal_container_._field_cached_byte_size_;
+inline TProtoStringType MakeVarintCachedSizeFieldName(const FieldDescriptor* field) {
+ return StrCat("_", FieldName(field), "_cached_byte_size_");
+}
+
+// Note: A lot of libraries detect Any protos based on Descriptor::full_name()
+// while the two functions below use FileDescriptor::name(). In a sane world the
+// two approaches should be equivalent. But if you are dealing with descriptors
+// from untrusted sources, you might need to match semantics across libraries.
bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
@@ -956,7 +1010,7 @@ inline OneOfRangeImpl OneOfRange(const Descriptor* desc) { return {desc}; }
PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
-bool EnableMessageOwnedArena(const Descriptor* desc);
+bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options);
bool ShouldVerify(const Descriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index c5028fdb1d..4d3e00ac89 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -30,10 +30,10 @@
#include <google/protobuf/compiler/cpp/cpp_map_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
namespace google {
@@ -53,10 +53,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
(*variables)["type"] = ClassName(descriptor->message_type(), false);
(*variables)["full_name"] = descriptor->full_name();
- const FieldDescriptor* key =
- descriptor->message_type()->FindFieldByName("key");
- const FieldDescriptor* val =
- descriptor->message_type()->FindFieldByName("value");
+ const FieldDescriptor* key = descriptor->message_type()->map_key();
+ const FieldDescriptor* val = descriptor->message_type()->map_value();
(*variables)["key_cpp"] = PrimitiveTypeName(options, key->cpp_type());
switch (val->cpp_type()) {
case FieldDescriptor::CPPTYPE_MESSAGE:
@@ -128,7 +126,7 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n"
"$classname$::_internal_$name$() const {\n"
- " return $name$_.GetMap();\n"
+ " return $field$.GetMap();\n"
"}\n"
"inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n"
"$classname$::$name$() const {\n"
@@ -138,7 +136,7 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
"$classname$::_internal_mutable_$name$() {\n"
- " return $name$_.MutableMap();\n"
+ " return $field$.MutableMap();\n"
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
"$classname$::mutable_$name$() {\n"
@@ -150,17 +148,17 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions(
void MapFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.Clear();\n");
+ format("$field$.Clear();\n");
}
void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.MergeFrom(from.$name$_);\n");
+ format("$field$.MergeFrom(from.$field$);\n");
}
void MapFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.InternalSwap(&other->$name$_);\n");
+ format("$field$.InternalSwap(&other->$field$);\n");
}
void MapFieldGenerator::GenerateCopyConstructorCode(
@@ -169,35 +167,27 @@ void MapFieldGenerator::GenerateCopyConstructorCode(
GenerateMergingCode(printer);
}
-static void GenerateSerializationLoop(const Formatter& format, bool string_key,
+static void GenerateSerializationLoop(Formatter& format, bool string_key,
bool string_value,
bool is_deterministic) {
- TProtoStringType ptr;
if (is_deterministic) {
- format("for (size_type i = 0; i < n; i++) {\n");
- ptr = string_key ? "items[static_cast<ptrdiff_t>(i)]"
- : "items[static_cast<ptrdiff_t>(i)].second";
- } else {
format(
- "for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n"
- " it = this->_internal_$name$().begin();\n"
- " it != this->_internal_$name$().end(); ++it) {\n");
- ptr = "it";
+ "for (const auto& entry : "
+ "::_pbi::MapSorter$1$<MapType>(map_field)) {\n",
+ (string_key ? "Ptr" : "Flat"));
+ } else {
+ format("for (const auto& entry : map_field) {\n");
}
- format.Indent();
+ {
+ auto loop_scope = format.ScopedIndent();
+ format(
+ "target = WireHelper::InternalSerialize($number$, "
+ "entry.first, entry.second, target, stream);\n");
- format(
- "target = $map_classname$::Funcs::InternalSerialize($number$, "
- "$1$->first, $1$->second, target, stream);\n",
- ptr);
-
- if (string_key || string_value) {
- // ptr is either an actual pointer or an iterator, either way we can
- // create a pointer by taking the address after de-referencing it.
- format("Utf8Check::Check(&(*$1$));\n", ptr);
+ if (string_key || string_value) {
+ format("check_utf8(entry);\n");
+ }
}
-
- format.Outdent();
format("}\n");
}
@@ -206,77 +196,53 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray(
Formatter format(printer, variables_);
format("if (!this->_internal_$name$().empty()) {\n");
format.Indent();
- const FieldDescriptor* key_field =
- descriptor_->message_type()->FindFieldByName("key");
- const FieldDescriptor* value_field =
- descriptor_->message_type()->FindFieldByName("value");
+ const FieldDescriptor* key_field = descriptor_->message_type()->map_key();
+ const FieldDescriptor* value_field = descriptor_->message_type()->map_value();
const bool string_key = key_field->type() == FieldDescriptor::TYPE_STRING;
const bool string_value = value_field->type() == FieldDescriptor::TYPE_STRING;
format(
- "typedef ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_pointer\n"
- " ConstPtr;\n");
- if (string_key) {
- format(
- "typedef ConstPtr SortItem;\n"
- "typedef ::$proto_ns$::internal::"
- "CompareByDerefFirst<SortItem> Less;\n");
- } else {
- format(
- "typedef ::$proto_ns$::internal::SortItem< $key_cpp$, ConstPtr > "
- "SortItem;\n"
- "typedef ::$proto_ns$::internal::CompareByFirstField<SortItem> "
- "Less;\n");
- }
+ "using MapType = ::_pb::Map<$key_cpp$, $val_cpp$>;\n"
+ "using WireHelper = $map_classname$::Funcs;\n"
+ "const auto& map_field = this->_internal_$name$();\n");
bool utf8_check = string_key || string_value;
if (utf8_check) {
- format(
- "struct Utf8Check {\n"
- " static void Check(ConstPtr p) {\n"
- // p may be unused when GetUtf8CheckMode evaluates to kNone,
- // thus disabling the validation.
- " (void)p;\n");
- format.Indent();
- format.Indent();
- if (string_key) {
- GenerateUtf8CheckCodeForString(
- key_field, options_, false,
- "p->first.data(), static_cast<int>(p->first.length()),\n", format);
+ format("auto check_utf8 = [](const MapType::value_type& entry) {\n");
+ {
+ auto check_scope = format.ScopedIndent();
+ // p may be unused when GetUtf8CheckMode evaluates to kNone,
+ // thus disabling the validation.
+ format("(void)entry;\n");
+ if (string_key) {
+ GenerateUtf8CheckCodeForString(
+ key_field, options_, false,
+ "entry.first.data(), static_cast<int>(entry.first.length()),\n",
+ format);
+ }
+ if (string_value) {
+ GenerateUtf8CheckCodeForString(
+ value_field, options_, false,
+ "entry.second.data(), static_cast<int>(entry.second.length()),\n",
+ format);
+ }
}
- if (string_value) {
- GenerateUtf8CheckCodeForString(
- value_field, options_, false,
- "p->second.data(), static_cast<int>(p->second.length()),\n", format);
- }
- format.Outdent();
- format.Outdent();
format(
- " }\n"
"};\n");
}
format(
"\n"
- "if (stream->IsSerializationDeterministic() &&\n"
- " this->_internal_$name$().size() > 1) {\n"
- " ::std::unique_ptr<SortItem[]> items(\n"
- " new SortItem[this->_internal_$name$().size()]);\n"
- " typedef ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::size_type "
- "size_type;\n"
- " size_type n = 0;\n"
- " for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n"
- " it = this->_internal_$name$().begin();\n"
- " it != this->_internal_$name$().end(); ++it, ++n) {\n"
- " items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n"
- " }\n"
- " ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n");
- format.Indent();
- GenerateSerializationLoop(format, string_key, string_value, true);
- format.Outdent();
+ "if (stream->IsSerializationDeterministic() && "
+ "map_field.size() > 1) {\n");
+ {
+ auto deterministic_scope = format.ScopedIndent();
+ GenerateSerializationLoop(format, string_key, string_value, true);
+ }
format("} else {\n");
- format.Indent();
- GenerateSerializationLoop(format, string_key, string_value, false);
- format.Outdent();
+ {
+ auto map_order_scope = format.ScopedIndent();
+ GenerateSerializationLoop(format, string_key, string_value, false);
+ }
format("}\n");
format.Outdent();
format("}\n");
@@ -301,7 +267,7 @@ void MapFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
- "if (!::$proto_ns$::internal::AllAreInitialized($name$_)) return "
+ "if (!::$proto_ns$::internal::AllAreInitialized($field$)) return "
"false;\n");
}
@@ -315,17 +281,28 @@ void MapFieldGenerator::GenerateConstinitInitializer(
}
}
-bool MapFieldGenerator::GenerateArenaDestructorCode(
- io::Printer* printer) const {
+void MapFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
+ GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
+
Formatter format(printer, variables_);
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- // _this is the object being destructed (we are inside a static method
- // here).
- format("_this->$name$_. ~MapField();\n");
- return true;
- } else {
- return false;
+ format("$field$.Destruct();\n");
+}
+
+void MapFieldGenerator::GenerateArenaDestructorCode(
+ io::Printer* printer) const {
+ if (NeedsArenaDestructor() == ArenaDtorNeeds::kNone) {
+ return;
}
+
+ Formatter format(printer, variables_);
+ // _this is the object being destructed (we are inside a static method here).
+ format("_this->$field$.Destruct();\n");
+}
+
+ArenaDtorNeeds MapFieldGenerator::NeedsArenaDestructor() const {
+ return HasDescriptorMethods(descriptor_->file(), options_)
+ ? ArenaDtorNeeds::kRequired
+ : ArenaDtorNeeds::kNone;
}
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
index c01ae498b1..9e71267c0f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
@@ -62,7 +62,9 @@ class MapFieldGenerator : public FieldGenerator {
void GenerateByteSize(io::Printer* printer) const override;
void GenerateIsInitialized(io::Printer* printer) const override;
void GenerateConstinitInitializer(io::Printer* printer) const override;
- bool GenerateArenaDestructorCode(io::Printer* printer) const override;
+ void GenerateDestructorCode(io::Printer* printer) const override;
+ void GenerateArenaDestructorCode(io::Printer* printer) const override;
+ ArenaDtorNeeds NeedsArenaDestructor() const override;
private:
const bool has_required_fields_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
index 4b5e0f2e95..a56c6fbda1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -44,22 +44,21 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/cpp/cpp_enum.h>
-#include <google/protobuf/compiler/cpp/cpp_extension.h>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_padding_optimizer.h>
-#include <google/protobuf/compiler/cpp/cpp_parse_function_generator.h>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/map_entry_lite.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/compiler/cpp/cpp_enum.h>
+#include <google/protobuf/compiler/cpp/cpp_extension.h>
+#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/cpp_padding_optimizer.h>
+#include <google/protobuf/compiler/cpp/cpp_parse_function_generator.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/stubs/hash.h>
@@ -109,7 +108,7 @@ void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field,
int has_bit_index = has_bit_indices[field->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);
+ format("cached_has_bits = $has_bits$[$1$];\n", *cached_has_word_index);
}
const TProtoStringType mask =
StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
@@ -276,8 +275,8 @@ void CollectMapInfo(const Options& options, const Descriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables) {
GOOGLE_CHECK(IsMapEntryMessage(descriptor));
std::map<TProtoStringType, TProtoStringType>& vars = *variables;
- const FieldDescriptor* key = descriptor->FindFieldByName("key");
- const FieldDescriptor* val = descriptor->FindFieldByName("value");
+ const FieldDescriptor* key = descriptor->map_key();
+ const FieldDescriptor* val = descriptor->map_value();
vars["key_cpp"] = PrimitiveTypeName(options, key->cpp_type());
switch (val->cpp_type()) {
case FieldDescriptor::CPPTYPE_MESSAGE:
@@ -323,64 +322,6 @@ bool ShouldSerializeInOrder(const Descriptor* descriptor,
return true;
}
-bool TableDrivenParsingEnabled(const Descriptor* descriptor,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
- if (!options.table_driven_parsing) {
- return false;
- }
-
- // Consider table-driven parsing. We only do this if:
- // - We have has_bits for fields. This avoids a check on every field we set
- // when are present (the common case).
- bool has_hasbit = false;
- for (int i = 0; i < descriptor->field_count(); i++) {
- if (HasHasbit(descriptor->field(i))) {
- has_hasbit = true;
- break;
- }
- }
-
- if (!has_hasbit) return false;
-
- const double table_sparseness = 0.5;
- int max_field_number = 0;
- for (auto field : FieldRange(descriptor)) {
- if (max_field_number < field->number()) {
- max_field_number = field->number();
- }
-
- // - There are no weak fields.
- if (IsWeak(field, options)) {
- return false;
- }
-
- // - There are no lazy fields (they require the non-lite library).
- if (IsLazy(field, options, scc_analyzer)) {
- return false;
- }
- }
-
- // - There range of field numbers is "small"
- if (max_field_number >= (2 << 14)) {
- return false;
- }
-
- // - Field numbers are relatively dense within the actual number of fields.
- // We check for strictly greater than in the case where there are no fields
- // (only extensions) so max_field_number == descriptor->field_count() == 0.
- if (max_field_number * table_sparseness > descriptor->field_count()) {
- return false;
- }
-
- // - This is not a MapEntryMessage.
- if (IsMapEntryMessage(descriptor)) {
- return false;
- }
-
- return true;
-}
-
bool IsCrossFileMapField(const FieldDescriptor* field) {
if (!field->is_map()) {
return false;
@@ -406,8 +347,8 @@ bool IsRequired(const std::vector<const FieldDescriptor*>& v) {
bool HasSingularString(const Descriptor* desc, const Options& options) {
for (const auto* field : FieldRange(desc)) {
- if (IsString(field, options) && !IsStringInlined(field, options) &&
- !field->is_repeated() && !field->real_containing_oneof()) {
+ if (IsString(field, options) && !field->is_repeated() &&
+ !field->real_containing_oneof()) {
return true;
}
}
@@ -470,6 +411,7 @@ class ColdChunkSkipper {
access_info_map_(options.access_info_map),
cold_threshold_(cold_threshold) {
SetCommonVars(options, &variables_);
+ SetCommonMessageDataVariables(&variables_);
}
// May open an external if check for a batch of cold fields. "from" is the
@@ -610,6 +552,8 @@ void GenerateExtensionAnnotations(
google::protobuf::FileOptions::LITE_RUNTIME) {
return;
}
+ StringPiece tracker = (*variables)["tracker"];
+ StringPiece extensions = (*variables)["extensions"];
for (const auto& annotation : accessor_annotations_to_hooks) {
const TProtoStringType& annotation_name = annotation.first;
const TProtoStringType& listener_call = annotation.second;
@@ -619,29 +563,29 @@ void GenerateExtensionAnnotations(
// Primitive fields accessors.
// "Has" is here as users calling "has" on a repeated field is a mistake.
(*variables)[annotation_name] = StrCat(
- " _tracker_.", listener_call,
- "(this, id.number(), _proto_TypeTraits::GetPtr(id.number(), "
- "_extensions_, id.default_value_ref()));");
+ " ", tracker, ".", listener_call,
+ "(this, id.number(), _proto_TypeTraits::GetPtr(id.number(), ",
+ extensions, ", id.default_value_ref()));");
} else if (StrContains(annotation_name, "repeated") &&
!StrContains(annotation_name, "list") &&
!StrContains(annotation_name, "size")) {
// Repeated index accessors.
TProtoStringType str_index = "index";
if (StrContains(annotation_name, "add")) {
- str_index = "_extensions_.ExtensionSize(id.number()) - 1";
+ str_index = StrCat(extensions, ".ExtensionSize(id.number()) - 1");
}
(*variables)[annotation_name] =
- StrCat(" _tracker_.", listener_call,
+ StrCat(" ", tracker, ".", listener_call,
"(this, id.number(), "
- "_proto_TypeTraits::GetPtr(id.number(), _extensions_, ",
- str_index, "));");
+ "_proto_TypeTraits::GetPtr(id.number(), ",
+ extensions, ", ", str_index, "));");
} else if (StrContains(annotation_name, "list") ||
StrContains(annotation_name, "size")) {
// Repeated full accessors.
(*variables)[annotation_name] = StrCat(
- " _tracker_.", listener_call,
- "(this, id.number(), _proto_TypeTraits::GetRepeatedPtr(id.number(), "
- "_extensions_));");
+ " ", tracker, ".", listener_call,
+ "(this, id.number(), _proto_TypeTraits::GetRepeatedPtr(id.number(), ",
+ extensions, "));");
} else {
// Generic accessors such as "clear".
// TODO(b/190614678): Generalize clear from both repeated and non repeated
@@ -673,6 +617,7 @@ MessageGenerator::MessageGenerator(
if (!message_layout_helper_) {
message_layout_helper_.reset(new PaddingOptimizer());
}
+ SetCommonMessageDataVariables(&variables_);
// Variables that apply to this class
variables_["classname"] = classname_;
@@ -688,7 +633,8 @@ MessageGenerator::MessageGenerator(
if (options.field_listener_options.inject_field_listener_events &&
descriptor->file()->options().optimize_for() !=
google::protobuf::FileOptions::LITE_RUNTIME) {
- const TProtoStringType injector_template = " _tracker_.";
+ const TProtoStringType injector_template =
+ StrCat(" ", variables_["tracker"], ".");
MaySetAnnotationVariable(options, "serialize", injector_template,
"OnSerialize(this);\n", &variables_);
@@ -738,6 +684,9 @@ MessageGenerator::MessageGenerator(
if (IsStringInlined(field, options_)) {
if (inlined_string_indices_.empty()) {
inlined_string_indices_.resize(descriptor_->field_count(), kNoHasbit);
+ // The bitset[0] is for arena dtor tracking. Donating states start from
+ // bitset[1];
+ max_inlined_string_index_++;
}
inlined_string_indices_[field->index()] = max_inlined_string_index_++;
}
@@ -758,8 +707,6 @@ MessageGenerator::MessageGenerator(
}
}
- table_driven_ =
- TableDrivenParsingEnabled(descriptor_, options_, scc_analyzer_);
parse_function_generator_.reset(new ParseFunctionGenerator(
descriptor_, max_has_bit_index_, has_bit_indices_,
inlined_string_indices_, options_, scc_analyzer_, variables_));
@@ -903,7 +850,7 @@ inline bool HasExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_extension_has$
- return _extensions_.Has(id.number());
+ return $extensions$.Has(id.number());
}
template <typename _proto_TypeTraits,
@@ -912,7 +859,7 @@ template <typename _proto_TypeTraits,
inline void ClearExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
- _extensions_.ClearExtension(id.number());
+ $extensions$.ClearExtension(id.number());
$annotate_extension_clear$
}
@@ -923,7 +870,7 @@ inline int ExtensionSize(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_extension_repeated_size$
- return _extensions_.ExtensionSize(id.number());
+ return $extensions$.ExtensionSize(id.number());
}
template <typename _proto_TypeTraits,
@@ -933,7 +880,7 @@ inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_extension_get$
- return _proto_TypeTraits::Get(id.number(), _extensions_,
+ return _proto_TypeTraits::Get(id.number(), $extensions$,
id.default_value());
}
@@ -945,7 +892,7 @@ inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_extension_mutable$
return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_extensions_);
+ &$extensions$);
}
template <typename _proto_TypeTraits,
@@ -955,7 +902,7 @@ inline void SetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
- _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_);
+ _proto_TypeTraits::Set(id.number(), _field_type, value, &$extensions$);
$annotate_extension_set$
}
@@ -967,7 +914,7 @@ inline void SetAllocatedExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
- &_extensions_);
+ &$extensions$);
$annotate_extension_set$
}
template <typename _proto_TypeTraits,
@@ -978,7 +925,7 @@ inline void UnsafeArenaSetAllocatedExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
- value, &_extensions_);
+ value, &$extensions$);
$annotate_extension_set$
}
template <typename _proto_TypeTraits,
@@ -991,7 +938,7 @@ PROTOBUF_NODISCARD inline
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_extension_release$
return _proto_TypeTraits::Release(id.number(), _field_type,
- &_extensions_);
+ &$extensions$);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
@@ -1002,7 +949,7 @@ UnsafeArenaReleaseExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_extension_release$
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
- &_extensions_);
+ &$extensions$);
}
template <typename _proto_TypeTraits,
@@ -1013,7 +960,7 @@ inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
int index) const {
$annotate_repeated_extension_get$
- return _proto_TypeTraits::Get(id.number(), _extensions_, index);
+ return _proto_TypeTraits::Get(id.number(), $extensions$, index);
}
template <typename _proto_TypeTraits,
@@ -1024,7 +971,7 @@ inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
int index) {
$annotate_repeated_extension_mutable$
- return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_);
+ return _proto_TypeTraits::Mutable(id.number(), index, &$extensions$);
}
template <typename _proto_TypeTraits,
@@ -1034,7 +981,7 @@ inline void SetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
- _proto_TypeTraits::Set(id.number(), index, value, &_extensions_);
+ _proto_TypeTraits::Set(id.number(), index, value, &$extensions$);
$annotate_repeated_extension_set$
}
@@ -1045,7 +992,7 @@ inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
- _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_);
+ _proto_TypeTraits::Add(id.number(), _field_type, &$extensions$);
$annotate_repeated_extension_add_mutable$
return to_add;
}
@@ -1058,7 +1005,7 @@ inline void AddExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
- &_extensions_);
+ &$extensions$);
$annotate_repeated_extension_add$
}
@@ -1070,7 +1017,7 @@ GetRepeatedExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_repeated_extension_list$
- return _proto_TypeTraits::GetRepeated(id.number(), _extensions_);
+ return _proto_TypeTraits::GetRepeated(id.number(), $extensions$);
}
template <typename _proto_TypeTraits,
@@ -1082,7 +1029,7 @@ MutableRepeatedExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_repeated_extension_list_mutable$
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
- _is_packed, &_extensions_);
+ _is_packed, &$extensions$);
}
)");
@@ -1119,7 +1066,7 @@ void MessageGenerator::GenerateSingularFieldHasBits(
format(
"inline bool $classname$::has_$name$() const {\n"
"$annotate_has$"
- " return _weak_field_map_.Has($number$);\n"
+ " return $weak_field_map$.Has($number$);\n"
"}\n");
return;
}
@@ -1133,14 +1080,14 @@ void MessageGenerator::GenerateSingularFieldHasBits(
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
" bool value = "
- "(_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n");
+ "($has_bits$[$has_array_index$] & 0x$has_mask$u) != 0;\n");
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!IsLazy(field, options_, scc_analyzer_)) {
// We maintain the invariant that for a submessage x, has_x() returning
// true implies that x_ is not null. By giving this information to the
// compiler, we allow it to eliminate unnecessary null checks later on.
- format(" PROTOBUF_ASSUME(!value || $name$_ != nullptr);\n");
+ format(" PROTOBUF_ASSUME(!value || $field$ != nullptr);\n");
}
format(
@@ -1155,13 +1102,13 @@ void MessageGenerator::GenerateSingularFieldHasBits(
if (IsLazy(field, options_, scc_analyzer_)) {
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
- " return !$name$_.IsCleared();\n"
+ " return !$field$.IsCleared();\n"
"}\n");
} else {
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
" return this != internal_default_instance() "
- "&& $name$_ != nullptr;\n"
+ "&& $field$ != nullptr;\n"
"}\n");
}
format(
@@ -1183,7 +1130,7 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
" return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n"
"}\n"
"inline void $classname$::clear_has_$oneof_name$() {\n"
- " _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n"
+ " $oneof_case$[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n"
"}\n");
}
}
@@ -1229,7 +1176,7 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
// annotated.
format(
"inline void $classname$::set_has_$name$() {\n"
- " _oneof_case_[$oneof_index$] = k$field_name$;\n"
+ " $oneof_case$[$oneof_index$] = k$field_name$;\n"
"}\n");
}
@@ -1264,7 +1211,7 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
format.Set("has_array_index", has_bit_index / 32);
format.Set("has_mask",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
- format("_has_bits_[$has_array_index$] &= ~0x$has_mask$u;\n");
+ format("$has_bits$[$has_array_index$] &= ~0x$has_mask$u;\n");
}
}
format("$annotate_clear$");
@@ -1298,12 +1245,13 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
} else {
format(
"inline int $classname$::_internal_$name$_size() const {\n"
- " return $name$_$1$.size();\n"
+ " return $1$$2$.size();\n"
"}\n"
"inline int $classname$::$name$_size() const {\n"
"$annotate_size$"
" return _internal_$name$_size();\n"
"}\n",
+ FieldMemberName(field),
IsImplicitWeakField(field, options_, scc_analyzer_) &&
field->message_type()
? ".weak"
@@ -1360,7 +1308,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> "
"SuperType;\n"
" $classname$();\n"
- " explicit constexpr $classname$(\n"
+ " explicit PROTOBUF_CONSTEXPR $classname$(\n"
" ::$proto_ns$::internal::ConstantInitialized);\n"
" explicit $classname$(::$proto_ns$::Arena* arena);\n"
" void MergeFrom(const $classname$& other);\n"
@@ -1432,7 +1380,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
""
" ::$proto_ns$::Metadata GetMetadata() const final;\n");
}
- format("};\n");
+ format(
+ " friend struct ::$tablename$;\n"
+ "};\n");
return;
}
@@ -1444,11 +1394,10 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(" public:\n");
format.Indent();
- if (EnableMessageOwnedArena(descriptor_)) {
+ if (EnableMessageOwnedArena(descriptor_, options_)) {
format(
"inline $classname$() : $classname$("
- "::$proto_ns$::Arena::InternalHelper<$classname$>::\n"
- " CreateMessageOwnedArena(), true) {}\n");
+ "::$proto_ns$::Arena::InternalCreateMessageOwnedArena(), true) {}\n");
} else {
format("inline $classname$() : $classname$(nullptr) {}\n");
}
@@ -1456,7 +1405,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format("~$classname$() override;\n");
}
format(
- "explicit constexpr "
+ "explicit PROTOBUF_CONSTEXPR "
"$classname$(::$proto_ns$::internal::ConstantInitialized);\n"
"\n"
"$classname$(const $classname$& from);\n"
@@ -1484,14 +1433,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"}\n"
"\n");
- if (options_.table_driven_serialization) {
- format(
- "private:\n"
- "const void* InternalGetTable() const override;\n"
- "public:\n"
- "\n");
- }
-
if (PublicUnknownFieldsAccessors(descriptor_)) {
format(
"inline const $unknown_fields_type$& unknown_fields() const {\n"
@@ -1569,16 +1510,16 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"bool PackFrom(const ::$proto_ns$::Message& message) {\n"
- " return _any_metadata_.PackFrom(GetArena(), message);\n"
+ " return $any_metadata$.PackFrom(GetArena(), message);\n"
"}\n"
"bool PackFrom(const ::$proto_ns$::Message& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
- " return _any_metadata_.PackFrom(GetArena(), message, "
+ " return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
"}\n"
"bool UnpackTo(::$proto_ns$::Message* message) const {\n"
- " return _any_metadata_.UnpackTo(message);\n"
+ " return $any_metadata$.UnpackTo(message);\n"
"}\n"
"static bool GetAnyFieldDescriptors(\n"
" const ::$proto_ns$::Message& message,\n"
@@ -1588,7 +1529,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
"::value>::type>\n"
"bool PackFrom(const T& message) {\n"
- " return _any_metadata_.PackFrom<T>(GetArena(), message);\n"
+ " return $any_metadata$.PackFrom<T>(GetArena(), message);\n"
"}\n"
"template <typename T, class = typename std::enable_if<"
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
@@ -1596,36 +1537,36 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"bool PackFrom(const T& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
- " return _any_metadata_.PackFrom<T>(GetArena(), message, "
+ " return $any_metadata$.PackFrom<T>(GetArena(), message, "
"type_url_prefix);"
"}\n"
"template <typename T, class = typename std::enable_if<"
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
"::value>::type>\n"
"bool UnpackTo(T* message) const {\n"
- " return _any_metadata_.UnpackTo<T>(message);\n"
+ " return $any_metadata$.UnpackTo<T>(message);\n"
"}\n");
} else {
format(
"template <typename T>\n"
"bool PackFrom(const T& message) {\n"
- " return _any_metadata_.PackFrom(GetArena(), message);\n"
+ " return $any_metadata$.PackFrom(GetArena(), message);\n"
"}\n"
"template <typename T>\n"
"bool PackFrom(const T& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
- " return _any_metadata_.PackFrom(GetArena(), message, "
+ " return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
"}\n"
"template <typename T>\n"
"bool UnpackTo(T* message) const {\n"
- " return _any_metadata_.UnpackTo(message);\n"
+ " return $any_metadata$.UnpackTo(message);\n"
"}\n");
}
format(
"template<typename T> bool Is() const {\n"
- " return _any_metadata_.Is<T>();\n"
+ " return $any_metadata$.Is<T>();\n"
"}\n"
"static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url,\n"
@@ -1732,7 +1673,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (!HasSimpleBaseClass(descriptor_, options_)) {
format(
- "int GetCachedSize() const final { return _cached_size_.Get(); }"
+ "int GetCachedSize() const final { return "
+ "$cached_size$.Get(); }"
"\n\nprivate:\n"
"void SharedCtor();\n"
"void SharedDtor();\n"
@@ -1756,13 +1698,32 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// we rely on.
"protected:\n"
"explicit $classname$(::$proto_ns$::Arena* arena,\n"
- " bool is_message_owned = false);\n"
- "private:\n");
+ " bool is_message_owned = false);\n");
- if (!HasSimpleBaseClass(descriptor_, options_)) {
- format(
- "static void ArenaDtor(void* object);\n"
- "inline void RegisterArenaDtor(::$proto_ns$::Arena* arena);\n");
+ switch (NeedsArenaDestructor()) {
+ case ArenaDtorNeeds::kOnDemand:
+ format(
+ "private:\n"
+ "static void ArenaDtor(void* object);\n"
+ "inline void OnDemandRegisterArenaDtor(::$proto_ns$::Arena* arena) "
+ "override {\n"
+ " if (arena == nullptr || ($inlined_string_donated_array$[0] & "
+ "0x1u) "
+ "== "
+ "0) {\n"
+ " return;\n"
+ " }\n"
+ " $inlined_string_donated_array$[0] &= 0xFFFFFFFEu;\n"
+ " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
+ "}\n");
+ break;
+ case ArenaDtorNeeds::kRequired:
+ format(
+ "private:\n"
+ "static void ArenaDtor(void* object);\n");
+ break;
+ case ArenaDtorNeeds::kNone:
+ break;
}
format(
@@ -1866,7 +1827,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// Prepare decls for _cached_size_ and _has_bits_. Their position in the
// output will be determined later.
- bool need_to_emit_cached_size = true;
+ bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_);
const TProtoStringType cached_size_decl =
"mutable ::$proto_ns$::internal::CachedSize _cached_size_;\n";
@@ -1917,8 +1878,10 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// _cached_size_ together with _has_bits_ improves cache locality despite
// potential alignment padding.
format(has_bits_decl.c_str());
- format(cached_size_decl.c_str());
- need_to_emit_cached_size = false;
+ if (need_to_emit_cached_size) {
+ format(cached_size_decl.c_str());
+ need_to_emit_cached_size = false;
+ }
}
// Field members:
@@ -2001,73 +1964,12 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
"inline $classname$::$camel_oneof_name$Case $classname$::"
"${1$$oneof_name$_case$}$() const {\n"
" return $classname$::$camel_oneof_name$Case("
- "_oneof_case_[$oneof_index$]);\n"
+ "$oneof_case$[$oneof_index$]);\n"
"}\n",
oneof);
}
}
-bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
- size_t aux_offset) {
- Formatter format(printer, variables_);
-
- if (!table_driven_) {
- format("{ nullptr, nullptr, 0, -1, -1, -1, -1, nullptr, false },\n");
- return false;
- }
-
- int max_field_number = 0;
- for (auto field : FieldRange(descriptor_)) {
- if (max_field_number < field->number()) {
- max_field_number = field->number();
- }
- }
-
- format("{\n");
- format.Indent();
-
- format(
- "$tablename$::entries + $1$,\n"
- "$tablename$::aux + $2$,\n"
- "$3$,\n",
- offset, aux_offset, max_field_number);
-
- if (has_bit_indices_.empty()) {
- // If no fields have hasbits, then _has_bits_ does not exist.
- format("-1,\n");
- } else {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n");
- }
-
- if (descriptor_->real_oneof_decl_count() > 0) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_),\n");
- } else {
- format("-1, // no _oneof_case_\n");
- }
-
- if (descriptor_->extension_range_count() > 0) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n");
- } else {
- format("-1, // no _extensions_\n");
- }
-
- // TODO(ckennelly): Consolidate this with the calculation for
- // AuxiliaryParseTableField.
- format(
- "PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n"
- "&$package_ns$::_$classname$_default_instance_,\n");
-
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- format("true,\n");
- } else {
- format("false,\n");
- }
-
- format.Outdent();
- format("},\n");
- return true;
-}
-
void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
int has_offset) {
Formatter format(printer, variables_);
@@ -2087,218 +1989,6 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
inlined_string_indices_offset);
}
-namespace {
-
-// We need to calculate for each field what function the table driven code
-// should use to serialize it. This returns the index in a lookup table.
-arc_ui32 CalcFieldNum(const FieldGenerator& generator,
- const FieldDescriptor* field, const Options& options) {
- bool is_a_map = IsMapEntryMessage(field->containing_type());
- int type = field->type();
- if (type == FieldDescriptor::TYPE_STRING ||
- type == FieldDescriptor::TYPE_BYTES) {
- // string field
- if (generator.IsInlined()) {
- type = internal::FieldMetadata::kInlinedType;
- } else if (IsCord(field, options)) {
- type = internal::FieldMetadata::kCordType;
- } else if (IsStringPiece(field, options)) {
- type = internal::FieldMetadata::kStringPieceType;
- }
- }
-
- if (field->real_containing_oneof()) {
- return internal::FieldMetadata::CalculateType(
- type, internal::FieldMetadata::kOneOf);
- } else if (field->is_packed()) {
- return internal::FieldMetadata::CalculateType(
- type, internal::FieldMetadata::kPacked);
- } else if (field->is_repeated()) {
- return internal::FieldMetadata::CalculateType(
- type, internal::FieldMetadata::kRepeated);
- } else if (HasHasbit(field) || field->real_containing_oneof() || is_a_map) {
- return internal::FieldMetadata::CalculateType(
- type, internal::FieldMetadata::kPresence);
- } else {
- return internal::FieldMetadata::CalculateType(
- type, internal::FieldMetadata::kNoPresence);
- }
-}
-
-int FindMessageIndexInFile(const Descriptor* descriptor) {
- std::vector<const Descriptor*> flatten =
- FlattenMessagesInFile(descriptor->file());
- return std::find(flatten.begin(), flatten.end(), descriptor) -
- flatten.begin();
-}
-
-} // namespace
-
-int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
- Formatter format(printer, variables_);
- if (!options_.table_driven_serialization) {
- return 0;
- }
-
- std::vector<const FieldDescriptor*> sorted = SortFieldsByNumber(descriptor_);
- if (IsMapEntryMessage(descriptor_)) {
- for (int i = 0; i < 2; i++) {
- const FieldDescriptor* field = sorted[i];
- const FieldGenerator& generator = field_generators_.get(field);
-
- arc_ui32 tag = internal::WireFormatLite::MakeTag(
- field->number(), WireFormat::WireTypeForFieldType(field->type()));
-
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["classtype"] = QualifiedClassName(descriptor_, options_);
- vars["field_name"] = FieldName(field);
- vars["tag"] = StrCat(tag);
- vars["hasbit"] = StrCat(i);
- vars["type"] = StrCat(CalcFieldNum(generator, field, options_));
- vars["ptr"] = "nullptr";
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- GOOGLE_CHECK(!IsMapEntryMessage(field->message_type()));
- vars["ptr"] =
- "::" + UniqueName("TableStruct", field->message_type(), options_) +
- "::serialization_table + " +
- StrCat(FindMessageIndexInFile(field->message_type()));
- }
- Formatter::SaveState saver(&format);
- format.AddMap(vars);
- format(
- "{PROTOBUF_FIELD_OFFSET("
- "::$proto_ns$::internal::MapEntryHelper<$classtype$::"
- "SuperType>, $field_name$_), $tag$,"
- "PROTOBUF_FIELD_OFFSET("
- "::$proto_ns$::internal::MapEntryHelper<$classtype$::"
- "SuperType>, _has_bits_) * 8 + $hasbit$, $type$, "
- "$ptr$},\n");
- }
- return 2;
- }
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, _cached_size_),"
- " 0, 0, 0, nullptr},\n");
- std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
- sorted_extensions.reserve(descriptor_->extension_range_count());
- for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
- sorted_extensions.push_back(descriptor_->extension_range(i));
- }
- std::sort(sorted_extensions.begin(), sorted_extensions.end(),
- ExtensionRangeSorter());
- for (int i = 0, extension_idx = 0; /* no range */; i++) {
- for (; extension_idx < sorted_extensions.size() &&
- (i == sorted.size() ||
- sorted_extensions[extension_idx]->start < sorted[i]->number());
- extension_idx++) {
- const Descriptor::ExtensionRange* range =
- sorted_extensions[extension_idx];
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, _extensions_), "
- "$1$, $2$, ::$proto_ns$::internal::FieldMetadata::kSpecial, "
- "reinterpret_cast<const "
- "void*>(::$proto_ns$::internal::ExtensionSerializer)},\n",
- range->start, range->end);
- }
- if (i == sorted.size()) break;
- const FieldDescriptor* field = sorted[i];
-
- arc_ui32 tag = internal::WireFormatLite::MakeTag(
- field->number(), WireFormat::WireTypeForFieldType(field->type()));
- if (field->is_packed()) {
- tag = internal::WireFormatLite::MakeTag(
- field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
- }
-
- TProtoStringType classfieldname = FieldName(field);
- if (field->real_containing_oneof()) {
- classfieldname = field->containing_oneof()->name();
- }
- format.Set("field_name", classfieldname);
- TProtoStringType ptr = "nullptr";
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- if (IsMapEntryMessage(field->message_type())) {
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$, $2$, "
- "::$proto_ns$::internal::FieldMetadata::kSpecial, "
- "reinterpret_cast<const void*>(static_cast< "
- "::$proto_ns$::internal::SpecialSerializer>("
- "::$proto_ns$::internal::MapFieldSerializer< "
- "::$proto_ns$::internal::MapEntryToMapField<"
- "$3$>::MapFieldType, "
- "$tablename$::serialization_table>))},\n",
- tag, FindMessageIndexInFile(field->message_type()),
- QualifiedClassName(field->message_type(), options_));
- continue;
- } else if (!field->message_type()->options().message_set_wire_format()) {
- // message_set doesn't have the usual table and we need to
- // dispatch to generated serializer, hence ptr stays zero.
- ptr =
- "::" + UniqueName("TableStruct", field->message_type(), options_) +
- "::serialization_table + " +
- StrCat(FindMessageIndexInFile(field->message_type()));
- }
- }
-
- const FieldGenerator& generator = field_generators_.get(field);
- int type = CalcFieldNum(generator, field, options_);
-
- if (IsLazy(field, options_, scc_analyzer_)) {
- type = internal::FieldMetadata::kSpecial;
- ptr = "reinterpret_cast<const void*>(::" + variables_["proto_ns"] +
- "::internal::LazyFieldSerializer";
- if (field->real_containing_oneof()) {
- ptr += "OneOf";
- } else if (!HasHasbit(field)) {
- ptr += "NoPresence";
- }
- ptr += ")";
- }
-
- if (field->options().weak()) {
- // TODO(gerbens) merge weak fields into ranges
- format(
- "{PROTOBUF_FIELD_OFFSET("
- "$classtype$, _weak_field_map_), $1$, $1$, "
- "::$proto_ns$::internal::FieldMetadata::kSpecial, "
- "reinterpret_cast<const "
- "void*>(::$proto_ns$::internal::WeakFieldSerializer)},\n",
- tag);
- } else if (field->real_containing_oneof()) {
- format.Set("oneofoffset",
- sizeof(arc_ui32) * field->containing_oneof()->index());
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$,"
- " PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_) + "
- "$oneofoffset$, $2$, $3$},\n",
- tag, type, ptr);
- } else if (HasHasbit(field)) {
- format.Set("hasbitsoffset", has_bit_indices_[field->index()]);
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), "
- "$1$, PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_) * 8 + "
- "$hasbitsoffset$, $2$, $3$},\n",
- tag, type, ptr);
- } else {
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), "
- "$1$, ~0u, $2$, $3$},\n",
- tag, type, ptr);
- }
- }
- int num_field_metadata = 1 + sorted.size() + sorted_extensions.size();
- num_field_metadata++;
- TProtoStringType serializer = UseUnknownFieldSet(descriptor_->file(), options_)
- ? "UnknownFieldSetSerializer"
- : "UnknownFieldSerializerLite";
- format(
- "{PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_), 0, ~0u, "
- "::$proto_ns$::internal::FieldMetadata::kSpecial, reinterpret_cast<const "
- "void*>(::$proto_ns$::internal::$1$)},\n",
- serializer);
- return num_field_metadata;
-}
-
void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
Formatter format(printer, variables_);
if (IsMapEntryMessage(descriptor_)) {
@@ -2314,7 +2004,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format(
"::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
"$annotate_reflection$"
- " return ::$proto_ns$::internal::AssignDescriptors(\n"
+ " return ::_pbi::AssignDescriptors(\n"
" &$desc_table$_getter, &$desc_table$_once,\n"
" $file_level_metadata$[$1$]);\n"
"}\n",
@@ -2322,7 +2012,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
} else {
format(
"::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
- " return ::$proto_ns$::internal::AssignDescriptors(\n"
+ " return ::_pbi::AssignDescriptors(\n"
" &$desc_table$_getter, &$desc_table$_once,\n"
" $file_level_metadata$[$1$]);\n"
"}\n",
@@ -2339,7 +2029,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
" const ::$proto_ns$::Message& message,\n"
" const ::$proto_ns$::FieldDescriptor** type_url_field,\n"
" const ::$proto_ns$::FieldDescriptor** value_field) {\n"
- " return ::$proto_ns$::internal::GetAnyFieldDescriptors(\n"
+ " return ::_pbi::GetAnyFieldDescriptors(\n"
" message, type_url_field, value_field);\n"
"}\n");
}
@@ -2347,8 +2037,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
"bool $classname$::ParseAnyTypeUrl(\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n"
" TProtoStringType* full_type_name) {\n"
- " return ::$proto_ns$::internal::ParseAnyTypeUrl(type_url,\n"
- " full_type_name);\n"
+ " return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n"
"}\n"
"\n");
}
@@ -2359,7 +2048,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format.Indent();
if (!has_bit_indices_.empty()) {
format(
- "using HasBits = decltype(std::declval<$classname$>()._has_bits_);\n");
+ "using HasBits = "
+ "decltype(std::declval<$classname$>().$has_bits$);\n");
}
for (auto field : FieldRange(descriptor_)) {
field_generators_.get(field).GenerateInternalAccessorDeclarations(printer);
@@ -2455,20 +2145,12 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
GenerateSwap(printer);
format("\n");
- if (options_.table_driven_serialization) {
- format(
- "const void* $classname$::InternalGetTable() const {\n"
- " return ::$tablename$::serialization_table + $1$;\n"
- "}\n"
- "\n",
- index_in_file_messages_);
- }
if (HasDescriptorMethods(descriptor_->file(), options_)) {
if (!descriptor_->options().map_entry()) {
format(
"::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
"$annotate_reflection$"
- " return ::$proto_ns$::internal::AssignDescriptors(\n"
+ " return ::_pbi::AssignDescriptors(\n"
" &$desc_table$_getter, &$desc_table$_once,\n"
" $file_level_metadata$[$1$]);\n"
"}\n",
@@ -2476,7 +2158,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
} else {
format(
"::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
- " return ::$proto_ns$::internal::AssignDescriptors(\n"
+ " return ::_pbi::AssignDescriptors(\n"
" &$desc_table$_getter, &$desc_table$_once,\n"
" $file_level_metadata$[$1$]);\n"
"}\n",
@@ -2495,234 +2177,40 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
google::protobuf::FileOptions::LITE_RUNTIME) {
format(
"::$proto_ns$::AccessListener<$classtype$> "
- "$1$::_tracker_(&FullMessageName);\n",
+ "$1$::$tracker$(&FullMessageName);\n",
ClassName(descriptor_));
}
}
-size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) {
- Formatter format(printer, variables_);
-
- if (!table_driven_) {
- return 0;
- }
-
- // Field "0" is special: We use it in our switch statement of processing
- // types to handle the successful end tag case.
- format("{0, 0, 0, ::$proto_ns$::internal::kInvalidMask, 0, 0},\n");
- int last_field_number = 1;
-
- std::vector<const FieldDescriptor*> ordered_fields =
- SortFieldsByNumber(descriptor_);
-
- for (auto field : ordered_fields) {
- Formatter::SaveState saver(&format);
- GOOGLE_CHECK_GE(field->number(), last_field_number);
-
- for (; last_field_number < field->number(); last_field_number++) {
- format(
- "{ 0, 0, ::$proto_ns$::internal::kInvalidMask,\n"
- " ::$proto_ns$::internal::kInvalidMask, 0, 0 },\n");
- }
- last_field_number++;
-
- unsigned char normal_wiretype, packed_wiretype, processing_type;
- normal_wiretype = WireFormat::WireTypeForFieldType(field->type());
-
- if (field->is_packable()) {
- packed_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
- } else {
- packed_wiretype = internal::kNotPackedMask;
- }
-
- processing_type = static_cast<unsigned>(field->type());
- const FieldGenerator& generator = field_generators_.get(field);
- if (field->type() == FieldDescriptor::TYPE_STRING) {
- switch (EffectiveStringCType(field, options_)) {
- case FieldOptions::STRING:
- if (generator.IsInlined()) {
- processing_type = internal::TYPE_STRING_INLINED;
- }
- break;
- case FieldOptions::CORD:
- processing_type = internal::TYPE_STRING_CORD;
- break;
- case FieldOptions::STRING_PIECE:
- processing_type = internal::TYPE_STRING_STRING_PIECE;
- break;
- }
- } else if (field->type() == FieldDescriptor::TYPE_BYTES) {
- switch (EffectiveStringCType(field, options_)) {
- case FieldOptions::STRING:
- if (generator.IsInlined()) {
- processing_type = internal::TYPE_BYTES_INLINED;
- }
- break;
- case FieldOptions::CORD:
- processing_type = internal::TYPE_BYTES_CORD;
- break;
- case FieldOptions::STRING_PIECE:
- processing_type = internal::TYPE_BYTES_STRING_PIECE;
- break;
- }
- }
-
- processing_type |= static_cast<unsigned>(
- field->is_repeated() ? internal::kRepeatedMask : 0);
- processing_type |= static_cast<unsigned>(
- field->real_containing_oneof() ? internal::kOneofMask : 0);
-
- if (field->is_map()) {
- processing_type = internal::TYPE_MAP;
- }
-
- const unsigned char tag_size =
- WireFormat::TagSize(field->number(), field->type());
-
- std::map<TProtoStringType, TProtoStringType> vars;
- if (field->real_containing_oneof()) {
- vars["name"] = field->containing_oneof()->name();
- vars["presence"] = StrCat(field->containing_oneof()->index());
- } else {
- vars["name"] = FieldName(field);
- vars["presence"] = StrCat(has_bit_indices_[field->index()]);
- }
- vars["nwtype"] = StrCat(normal_wiretype);
- vars["pwtype"] = StrCat(packed_wiretype);
- vars["ptype"] = StrCat(processing_type);
- vars["tag_size"] = StrCat(tag_size);
-
- format.AddMap(vars);
-
- format(
- "{\n"
- " PROTOBUF_FIELD_OFFSET($classtype$, $name$_),\n"
- " static_cast<$uint32$>($presence$),\n"
- " $nwtype$, $pwtype$, $ptype$, $tag_size$\n"
- "},\n");
- }
-
- return last_field_number;
-}
-
-size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
- Formatter format(printer, variables_);
-
- if (!table_driven_) {
- return 0;
- }
-
- std::vector<const FieldDescriptor*> ordered_fields =
- SortFieldsByNumber(descriptor_);
-
- format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n");
- int last_field_number = 1;
- for (auto field : ordered_fields) {
- Formatter::SaveState saver(&format);
-
- GOOGLE_CHECK_GE(field->number(), last_field_number);
- for (; last_field_number < field->number(); last_field_number++) {
- format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n");
- }
-
- std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
- format.AddMap(vars);
-
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_ENUM:
- if (HasPreservingUnknownEnumSemantics(field)) {
- format(
- "{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{"
- "nullptr}},\n");
- } else {
- format(
- "{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{"
- "$1$_IsValid}},\n",
- ClassName(field->enum_type(), true));
- }
- last_field_number++;
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE: {
- if (field->is_map()) {
- format(
- "{::$proto_ns$::internal::AuxiliaryParseTableField::map_"
- "aux{&::$proto_ns$::internal::ParseMap<$1$>}},\n",
- QualifiedClassName(field->message_type(), options_));
- last_field_number++;
- break;
- }
- format.Set("field_classname", ClassName(field->message_type(), false));
- format.Set("default_instance", QualifiedDefaultInstanceName(
- field->message_type(), options_));
-
- format(
- "{::$proto_ns$::internal::AuxiliaryParseTableField::message_aux{\n"
- " &$default_instance$}},\n");
- last_field_number++;
- break;
- }
- case FieldDescriptor::CPPTYPE_STRING: {
- TProtoStringType default_val;
- switch (EffectiveStringCType(field, options_)) {
- case FieldOptions::STRING:
- default_val = field->default_value_string().empty()
- ? "&::" + variables_["proto_ns"] +
- "::internal::fixed_address_empty_string"
- : "&" +
- QualifiedClassName(descriptor_, options_) +
- "::" + MakeDefaultName(field);
- break;
- case FieldOptions::CORD:
- case FieldOptions::STRING_PIECE:
- default_val =
- "\"" + CEscape(field->default_value_string()) + "\"";
- break;
- }
- format(
- "{::$proto_ns$::internal::AuxiliaryParseTableField::string_aux{\n"
- " $1$,\n"
- " \"$2$\"\n"
- "}},\n",
- default_val, field->full_name());
- last_field_number++;
- break;
- }
- default:
- break;
- }
- }
-
- return last_field_number;
-}
-
std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
io::Printer* printer) {
Formatter format(printer, variables_);
if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $has_bits$),\n");
} else {
format("~0u, // no _has_bits_\n");
}
format("PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n");
if (descriptor_->extension_range_count() > 0) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $extensions$),\n");
} else {
format("~0u, // no _extensions_\n");
}
if (descriptor_->real_oneof_decl_count() > 0) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_[0]),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $oneof_case$[0]),\n");
} else {
format("~0u, // no _oneof_case_\n");
}
if (num_weak_fields_ > 0) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _weak_field_map_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $weak_field_map$),\n");
} else {
format("~0u, // no _weak_field_map_\n");
}
if (!inlined_string_indices_.empty()) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, _inlined_string_donated_),\n");
+ format(
+ "PROTOBUF_FIELD_OFFSET($classtype$, "
+ "$inlined_string_donated_array$),\n");
} else {
format("~0u, // no _inlined_string_donated_\n");
}
@@ -2740,9 +2228,9 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
if (field->options().weak() || field->real_containing_oneof()) {
// Mark the field to prevent unintentional access through reflection.
// Don't use the top bit because that is for unused fields.
- format("::$proto_ns$::internal::kInvalidFieldOffsetTag");
+ format("::_pbi::kInvalidFieldOffsetTag");
} else {
- format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_)", FieldName(field));
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $1$)", FieldMemberName(field));
}
// Some information about a field is in the pdproto profile. The profile is
@@ -2750,11 +2238,6 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
// offset of the field, so that the information is available when
// reflectively accessing the field at run time.
//
- // Embed whether the field is used to the MSB of the offset.
- if (!IsFieldUsed(field, options_)) {
- format(" | 0x80000000u // unused\n");
- }
-
// Embed whether the field is eagerly verified lazy or inlined string to the
// LSB of the offset.
if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) {
@@ -2787,11 +2270,12 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
}
if (!inlined_string_indices_.empty()) {
entries += inlined_string_indices_.size();
- for (int inlined_string_indice : inlined_string_indices_) {
- const TProtoStringType index = inlined_string_indice >= 0
- ? StrCat(inlined_string_indice)
- : "~0u";
- format("$1$,\n", index);
+ for (int inlined_string_index : inlined_string_indices_) {
+ const TProtoStringType index =
+ inlined_string_index >= 0
+ ? StrCat(inlined_string_index, ", // inlined_string_index")
+ : "~0u,";
+ format("$1$\n", index);
}
}
@@ -2837,7 +2321,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
}
if (num_weak_fields_) {
- format("_weak_field_map_.ClearAll();\n");
+ format("$weak_field_map$.ClearAll();\n");
}
format.Outdent();
format(
@@ -2845,8 +2329,20 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
"\n");
}
+ArenaDtorNeeds MessageGenerator::NeedsArenaDestructor() const {
+ if (HasSimpleBaseClass(descriptor_, options_)) return ArenaDtorNeeds::kNone;
+ ArenaDtorNeeds needs = ArenaDtorNeeds::kNone;
+ for (const auto* field : FieldRange(descriptor_)) {
+ if (IsFieldStripped(field, options_)) continue;
+ needs =
+ std::max(needs, field_generators_.get(field).NeedsArenaDestructor());
+ }
+ return needs;
+}
+
void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
- if (HasSimpleBaseClass(descriptor_, options_)) return;
+ GOOGLE_CHECK(NeedsArenaDestructor() > ArenaDtorNeeds::kNone);
+
Formatter format(printer, variables_);
// Generate the ArenaDtor() method. Track whether any fields actually produced
@@ -2858,56 +2354,33 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
// since that simplifies Arena's destructor list (ordinary function pointers
// rather than member function pointers). _this is the object being
// destructed.
- format(
- "$classname$* _this = reinterpret_cast< $classname$* >(object);\n"
- // avoid an "unused variable" warning in case no fields have dtor code.
- "(void)_this;\n");
+ format("$classname$* _this = reinterpret_cast< $classname$* >(object);\n");
- bool need_registration = false;
// Process non-oneof fields first.
for (auto field : optimized_order_) {
- if (field_generators_.get(field).GenerateArenaDestructorCode(printer)) {
- need_registration = true;
- }
+ if (IsFieldStripped(field, options_)) continue;
+ const FieldGenerator& fg = field_generators_.get(field);
+ fg.GenerateArenaDestructorCode(printer);
}
// Process oneof fields.
- //
- // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything
- // and returns false for oneof fields.
for (auto oneof : OneOfRange(descriptor_)) {
for (auto field : FieldRange(oneof)) {
- if (!IsFieldStripped(field, options_) &&
- field_generators_.get(field).GenerateArenaDestructorCode(printer)) {
- need_registration = true;
- }
+ if (IsFieldStripped(field, options_)) continue;
+ field_generators_.get(field).GenerateArenaDestructorCode(printer);
}
}
format.Outdent();
format("}\n");
-
- if (need_registration) {
- format(
- "inline void $classname$::RegisterArenaDtor(::$proto_ns$::Arena* "
- "arena) {\n"
- " if (arena != nullptr) {\n"
- " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
- " }\n"
- "}\n");
- } else {
- format(
- "void $classname$::RegisterArenaDtor(::$proto_ns$::Arena*) {\n"
- "}\n");
- }
}
void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
Formatter format(printer, variables_);
format(
- "constexpr $classname$::$classname$(\n"
- " ::$proto_ns$::internal::ConstantInitialized)");
+ "PROTOBUF_CONSTEXPR $classname$::$classname$(\n"
+ " ::_pbi::ConstantInitialized)");
format.Indent();
const char* field_sep = ":";
const auto put_sep = [&] {
@@ -2953,16 +2426,16 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
TProtoStringType pod_template;
if (copy_constructor) {
pod_template =
- "::memcpy(&$first$_, &from.$first$_,\n"
- " static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n"
- " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n";
+ "::memcpy(&$first$, &from.$first$,\n"
+ " static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n"
+ " reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n";
} else {
pod_template =
"::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(\n"
- " reinterpret_cast<char*>(&$first$_) - "
+ " reinterpret_cast<char*>(&$first$) - "
"reinterpret_cast<char*>(this)),\n"
- " 0, static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n"
- " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n";
+ " 0, static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n"
+ " reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n";
}
for (int i = 0; i < optimized_order_.size(); ++i) {
@@ -2978,9 +2451,9 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
if (it != runs.end() && it->second > 1) {
// Use a memset, then skip run_length fields.
const size_t run_length = it->second;
- const TProtoStringType first_field_name = FieldName(field);
+ const TProtoStringType first_field_name = FieldMemberName(field);
const TProtoStringType last_field_name =
- FieldName(optimized_order_[i + run_length - 1]);
+ FieldMemberName(optimized_order_[i + run_length - 1]);
format.Set("first", first_field_name);
format.Set("last", last_field_name);
@@ -3049,19 +2522,37 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
if (!inlined_string_indices_.empty()) {
// Donate inline string fields.
- format(" if (arena != nullptr) {\n");
- for (size_t i = 0; i < InlinedStringDonatedSize(); ++i) {
- format(" _inlined_string_donated_[$1$] = ~0u;\n", i);
+ format.Indent();
+ // The last bit is the tracking bit for registering ArenaDtor. The bit is 1
+ // means ArenaDtor is not registered on construction, and on demand register
+ // is needed.
+ format("if (arena != nullptr) {\n");
+ if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) {
+ format(
+ " if (!is_message_owned) {\n"
+ " $inlined_string_donated_array$[0] = ~0u;\n"
+ " } else {\n"
+ // We should not register ArenaDtor for MOA.
+ " $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n"
+ " }\n");
+ } else {
+ format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n");
}
- format(" }\n");
+ for (size_t i = 1; i < InlinedStringDonatedSize(); ++i) {
+ format(" $inlined_string_donated_array$[$1$] = ~0u;\n", i);
+ }
+ format("}\n");
+ format.Outdent();
}
if (!HasSimpleBaseClass(descriptor_, options_)) {
- format(
- " SharedCtor();\n"
- " if (!is_message_owned) {\n"
- " RegisterArenaDtor(arena);\n"
- " }\n");
+ format(" SharedCtor();\n");
+ if (NeedsArenaDestructor() == ArenaDtorNeeds::kRequired) {
+ format(
+ " if (arena != nullptr && !is_message_owned) {\n"
+ " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
+ " }\n");
+ }
}
format(
" // @@protoc_insertion_point(arena_constructor:$full_name$)\n"
@@ -3126,8 +2617,8 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
format(
- "_extensions_.MergeFrom(internal_default_instance(), "
- "from._extensions_);\n");
+ "$extensions$.MergeFrom(internal_default_instance(), "
+ "from.$extensions$);\n");
}
GenerateConstructorBody(printer, processed, true);
@@ -3172,10 +2663,19 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
if (!HasSimpleBaseClass(descriptor_, options_)) {
format(
"$classname$::~$classname$() {\n"
- " // @@protoc_insertion_point(destructor:$full_name$)\n"
- " if (GetArenaForAllocation() != nullptr) return;\n"
+ " // @@protoc_insertion_point(destructor:$full_name$)\n");
+ format(
+ " if (auto *arena = "
+ "_internal_metadata_.DeleteReturnArena<$unknown_fields_type$>()) {\n"
+ " (void)arena;\n");
+ if (NeedsArenaDestructor() > ArenaDtorNeeds::kNone) {
+ format(" ArenaDtor(this);\n");
+ }
+ format(
+ " return;\n"
+ " }\n");
+ format(
" SharedDtor();\n"
- " _internal_metadata_.Delete<$unknown_fields_type$>();\n"
"}\n"
"\n");
} else {
@@ -3190,13 +2690,15 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
GenerateSharedDestructorCode(printer);
// Generate the arena-specific destructor code.
- GenerateArenaDestructorCode(printer);
+ if (NeedsArenaDestructor() > ArenaDtorNeeds::kNone) {
+ GenerateArenaDestructorCode(printer);
+ }
if (!HasSimpleBaseClass(descriptor_, options_)) {
// Generate SetCachedSize.
format(
"void $classname$::SetCachedSize(int size) const {\n"
- " _cached_size_.Set(size);\n"
+ " $cached_size$.Set(size);\n"
"}\n");
}
}
@@ -3205,8 +2707,8 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
Formatter format(printer, variables_);
format(
"template<> "
- "PROTOBUF_NOINLINE "
- "$classtype$* Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n"
+ "PROTOBUF_NOINLINE $classtype$*\n"
+ "Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n"
" return Arena::CreateMessageInternal< $classtype$ >(arena);\n"
"}\n");
}
@@ -3232,7 +2734,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
"(void) cached_has_bits;\n\n");
if (descriptor_->extension_range_count() > 0) {
- format("_extensions_.Clear();\n");
+ format("$extensions$.Clear();\n");
}
// Collect fields into chunks. Each chunk may have an if() condition that
@@ -3305,7 +2807,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
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("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index);
}
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format.Indent();
@@ -3318,10 +2820,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
.GenerateMessageClearingCode(printer);
} else {
format(
- "::memset(&$1$_, 0, static_cast<size_t>(\n"
- " reinterpret_cast<char*>(&$2$_) -\n"
- " reinterpret_cast<char*>(&$1$_)) + sizeof($2$_));\n",
- FieldName(memset_start), FieldName(memset_end));
+ "::memset(&$1$, 0, static_cast<size_t>(\n"
+ " reinterpret_cast<char*>(&$2$) -\n"
+ " reinterpret_cast<char*>(&$1$)) + sizeof($2$));\n",
+ FieldMemberName(memset_start), FieldMemberName(memset_end));
}
}
@@ -3367,14 +2869,14 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
}
if (num_weak_fields_) {
- format("_weak_field_map_.ClearAll();\n");
+ format("$weak_field_map$.ClearAll();\n");
}
// We don't clear donated status.
if (!has_bit_indices_.empty()) {
// Step 5: Everything else.
- format("_has_bits_.Clear();\n");
+ format("$has_bits$.Clear();\n");
}
std::map<TProtoStringType, TProtoStringType> vars;
@@ -3420,7 +2922,7 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
format.Outdent();
format(
"}\n"
- "_oneof_case_[$1$] = $2$_NOT_SET;\n",
+ "$oneof_case$[$1$] = $2$_NOT_SET;\n",
i, ToUpper(oneof->name()));
format.Outdent();
format(
@@ -3440,7 +2942,9 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
if (HasGeneratedMethods(descriptor_->file(), options_)) {
if (descriptor_->extension_range_count() > 0) {
- format("_extensions_.InternalSwap(&other->_extensions_);\n");
+ format(
+ "$extensions$.InternalSwap(&other->$extensions$);"
+ "\n");
}
std::map<TProtoStringType, TProtoStringType> vars;
@@ -3455,7 +2959,7 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
if (!has_bit_indices_.empty()) {
for (int i = 0; i < HasBitsSize(); ++i) {
- format("swap(_has_bits_[$1$], other->_has_bits_[$1$]);\n", i);
+ format("swap($has_bits$[$1$], other->$has_bits$[$1$]);\n", i);
}
}
@@ -3475,20 +2979,20 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
if (it != runs.end() && it->second > 1) {
// Use a memswap, then skip run_length fields.
const size_t run_length = it->second;
- const TProtoStringType first_field_name = FieldName(field);
+ const TProtoStringType first_field_name = FieldMemberName(field);
const TProtoStringType last_field_name =
- FieldName(optimized_order_[i + run_length - 1]);
+ FieldMemberName(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<char*>(&$first$_),\n"
- " reinterpret_cast<char*>(&other->$first$_));\n");
+ " PROTOBUF_FIELD_OFFSET($classname$, $last$)\n"
+ " + sizeof($classname$::$last$)\n"
+ " - PROTOBUF_FIELD_OFFSET($classname$, $first$)>(\n"
+ " reinterpret_cast<char*>(&$first$),\n"
+ " reinterpret_cast<char*>(&other->$first$));\n");
i += run_length - 1;
// ++i at the top of the loop.
@@ -3502,11 +3006,25 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
- format("swap(_oneof_case_[$1$], other->_oneof_case_[$1$]);\n", i);
+ format(
+ "swap($oneof_case$[$1$], "
+ "other->$oneof_case$[$1$]);\n",
+ i);
}
if (num_weak_fields_) {
- format("_weak_field_map_.UnsafeArenaSwap(&other->_weak_field_map_);\n");
+ format(
+ "$weak_field_map$.UnsafeArenaSwap(&other->$weak_field_map$)"
+ ";\n");
+ }
+
+ if (!inlined_string_indices_.empty()) {
+ for (size_t i = 0; i < InlinedStringDonatedSize(); ++i) {
+ format(
+ "swap($inlined_string_donated_array$[$1$], "
+ "other->$inlined_string_donated_array$[$1$]);\n",
+ i);
+ }
}
} else {
format("GetReflection()->Swap(this, other);");
@@ -3549,7 +3067,7 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
format(
"void $classname$::CheckTypeAndMergeFrom(\n"
" const ::$proto_ns$::MessageLite& from) {\n"
- " MergeFrom(*::$proto_ns$::internal::DownCast<const $classname$*>(\n"
+ " MergeFrom(*::_pbi::DownCast<const $classname$*>(\n"
" &from));\n"
"}\n");
}
@@ -3619,7 +3137,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
- format("cached_has_bits = from._has_bits_[$1$];\n",
+ format("cached_has_bits = from.$has_bits$[$1$];\n",
cached_has_word_index);
}
@@ -3680,7 +3198,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
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);
+ format("$has_bits$[$1$] |= cached_has_bits;\n", cached_has_word_index);
}
format.Outdent();
@@ -3716,15 +3234,17 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
format("}\n");
}
if (num_weak_fields_) {
- format("_weak_field_map_.MergeFrom(from._weak_field_map_);\n");
+ format(
+ "$weak_field_map$.MergeFrom(from.$weak_field_map$);"
+ "\n");
}
// Merging of extensions and unknown fields is done last, to maximize
// the opportunity for tail calls.
if (descriptor_->extension_range_count() > 0) {
format(
- "_extensions_.MergeFrom(internal_default_instance(), "
- "from._extensions_);\n");
+ "$extensions$.MergeFrom(internal_default_instance(), "
+ "from.$extensions$);\n");
}
format(
@@ -3860,7 +3380,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange(
Formatter format(printer, vars);
format("// Extension range [$start$, $end$)\n");
format(
- "target = _extensions_._InternalSerialize(\n"
+ "target = $extensions$._InternalSerialize(\n"
"internal_default_instance(), $start$, $end$, target, stream);\n\n");
}
@@ -3875,14 +3395,14 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
"const {\n"
"$annotate_serialize$"
- " target = _extensions_."
+ " target = $extensions$."
"InternalSerializeMessageSetWithCachedSizesToArray(\n" //
"internal_default_instance(), target, stream);\n");
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
format(
- " target = ::$proto_ns$::internal::"
+ " target = ::_pbi::"
"InternalSerializeUnknownMessageSetItemsToArray(\n"
" $unknown_fields$, target, stream);\n");
format(
@@ -4077,8 +3597,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
ExtensionRangeSorter());
if (num_weak_fields_) {
format(
- "::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer("
- "_weak_field_map_);\n");
+ "::_pbi::WeakFieldMap::FieldWriter field_writer("
+ "$weak_field_map$);\n");
}
format(
@@ -4126,7 +3646,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
format(
"target = "
- "::$proto_ns$::internal::WireFormat::"
+ "::_pbi::WireFormat::"
"InternalSerializeUnknownFieldsToArray(\n"
" $unknown_fields$, target, stream);\n");
} else {
@@ -4167,8 +3687,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
if (num_weak_fields_) {
format(
- "::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer("
- "_weak_field_map_);\n");
+ "::_pbi::WeakFieldMap::FieldWriter field_writer("
+ "$weak_field_map$);\n");
}
format("for (int i = $1$; i >= 0; i-- ) {\n", num_fields - 1);
@@ -4218,7 +3738,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
format(
"target = "
- "::$proto_ns$::internal::WireFormat::"
+ "::_pbi::WireFormat::"
"InternalSerializeUnknownFieldsToArray(\n"
" $unknown_fields$, target, stream);\n");
} else {
@@ -4259,13 +3779,13 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
"size_t $classname$::ByteSizeLong() const {\n"
"$annotate_bytesize$"
"// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n"
- " size_t total_size = _extensions_.MessageSetByteSize();\n"
+ " size_t total_size = $extensions$.MessageSetByteSize();\n"
" if ($have_unknown_fields$) {\n"
- " total_size += ::$proto_ns$::internal::\n"
+ " total_size += ::_pbi::\n"
" ComputeUnknownMessageSetItemsSize($unknown_fields$);\n"
" }\n"
" int cached_size = "
- "::$proto_ns$::internal::ToCachedSize(total_size);\n"
+ "::_pbi::ToCachedSize(total_size);\n"
" SetCachedSize(cached_size);\n"
" return total_size;\n"
"}\n");
@@ -4312,7 +3832,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
format(
- "total_size += _extensions_.ByteSize();\n"
+ "total_size += $extensions$.ByteSize();\n"
"\n");
}
@@ -4393,7 +3913,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
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("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index);
}
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format.Indent();
@@ -4473,7 +3993,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (num_weak_fields_) {
// TagSize + MessageSize
- format("total_size += _weak_field_map_.ByteSizeLong();\n");
+ format("total_size += $weak_field_map$.ByteSizeLong();\n");
}
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
@@ -4481,7 +4001,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// unknown fields in tail position. This allows for better code generation
// of this function for simple protos.
format(
- "return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);\n");
+ "return MaybeComputeUnknownFieldsSize(total_size, &$cached_size$);\n");
} else {
format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n");
format(" total_size += $unknown_fields$.size();\n");
@@ -4496,7 +4016,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// where even relaxed memory order might have perf impact to replace it with
// ordinary loads and stores.
format(
- "int cached_size = ::$proto_ns$::internal::ToCachedSize(total_size);\n"
+ "int cached_size = ::_pbi::ToCachedSize(total_size);\n"
"SetCachedSize(cached_size);\n"
"return total_size;\n");
}
@@ -4513,14 +4033,14 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
format(
- "if (!_extensions_.IsInitialized()) {\n"
+ "if (!$extensions$.IsInitialized()) {\n"
" return false;\n"
"}\n\n");
}
if (num_required_fields_ > 0) {
format(
- "if (_Internal::MissingRequiredFields(_has_bits_))"
+ "if (_Internal::MissingRequiredFields($has_bits$))"
" return false;\n");
}
@@ -4530,7 +4050,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
}
if (num_weak_fields_) {
// For Weak fields.
- format("if (!_weak_field_map_.IsInitialized()) return false;\n");
+ format("if (!$weak_field_map$.IsInitialized()) return false;\n");
}
// Go through the oneof fields, emitting a switch if any might have required
// fields.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
index 939f21a1da..5e4bbe84b8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -96,22 +96,10 @@ class MessageGenerator {
void GenerateFieldAccessorDeclarations(io::Printer* printer);
void GenerateFieldAccessorDefinitions(io::Printer* printer);
- // Generate the table-driven parsing array. Returns the number of entries
- // generated.
- size_t GenerateParseOffsets(io::Printer* printer);
- size_t GenerateParseAuxTable(io::Printer* printer);
- // Generates a ParseTable entry. Returns whether the proto uses
- // table-driven parsing.
- bool GenerateParseTable(io::Printer* printer, size_t offset,
- size_t aux_offset);
-
// Generate the field offsets array. Returns the a pair of the total number
// of entries generated and the index of the first has_bit entry.
std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer);
void GenerateSchema(io::Printer* printer, int offset, int has_offset);
- // For each field generates a table entry describing the field for the
- // table driven serializer.
- int GenerateFieldMetadata(io::Printer* printer);
// Generate constructors and destructor.
void GenerateStructors(io::Printer* printer);
@@ -177,6 +165,18 @@ class MessageGenerator {
std::vector<bool> already_processed,
bool copy_constructor) const;
+ // Returns the level that this message needs ArenaDtor. If the message has
+ // a field that is not arena-exclusive, it needs an ArenaDtor
+ // (go/proto-destructor).
+ //
+ // - Returning kNone means we don't need to generate ArenaDtor.
+ // - Returning kOnDemand means we need to generate ArenaDtor, but don't need
+ // to register ArenaDtor at construction. Such as when the message's
+ // ArenaDtor code is only for destructing inlined string.
+ // - Returning kRequired means we meed to generate ArenaDtor and register it
+ // at construction.
+ ArenaDtorNeeds NeedsArenaDestructor() const;
+
size_t HasBitsSize() const;
size_t InlinedStringDonatedSize() const;
int HasBitIndex(const FieldDescriptor* a) const;
@@ -200,7 +200,8 @@ class MessageGenerator {
int max_has_bit_index_;
// A map from field index to inlined_string index. For non-inlined-string
- // fields, the element is -1.
+ // fields, the element is -1. If there is no inlined string in the message,
+ // this is empty.
std::vector<int> inlined_string_indices_;
// The count of inlined_string fields in the message.
int max_inlined_string_index_;
@@ -209,8 +210,6 @@ class MessageGenerator {
std::vector<const ExtensionGenerator*> extension_generators_;
int num_required_fields_;
int num_weak_fields_;
- // table_driven_ indicates the generated message uses table-driven parsing.
- bool table_driven_;
std::unique_ptr<MessageLayoutHelper> message_layout_helper_;
std::unique_ptr<ParseFunctionGenerator> parse_function_generator_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
index 04f45492c3..3b9f09c8c8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
@@ -33,8 +33,9 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/cpp/cpp_message_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+
#include <google/protobuf/io/printer.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/stubs/strutil.h>
@@ -60,11 +61,16 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = FieldMessageTypeName(descriptor, options);
(*variables)["casted_member"] = ReinterpretCast(
- (*variables)["type"] + "*", (*variables)["name"] + "_", implicit_weak);
+ (*variables)["type"] + "*", (*variables)["field"], implicit_weak);
+ (*variables)["casted_member_const"] =
+ ReinterpretCast("const " + (*variables)["type"] + "&",
+ "*" + (*variables)["field"], implicit_weak);
(*variables)["type_default_instance"] =
QualifiedDefaultInstanceName(descriptor->message_type(), options);
- (*variables)["type_default_instance_ptr"] =
- QualifiedDefaultInstancePtr(descriptor->message_type(), options);
+ (*variables)["type_default_instance_ptr"] = ReinterpretCast(
+ "const ::PROTOBUF_NAMESPACE_ID::MessageLite*",
+ QualifiedDefaultInstancePtr(descriptor->message_type(), options),
+ implicit_weak);
(*variables)["type_reference_function"] =
implicit_weak ? (" ::" + (*variables)["proto_ns"] +
"::internal::StrongReference(reinterpret_cast<const " +
@@ -176,14 +182,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
// 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 (GetArenaForAllocation() == nullptr) {\n"
- " delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n"
+ " delete reinterpret_cast<::$proto_ns$::MessageLite*>($field$);\n"
" }\n");
if (implicit_weak_field_) {
format(
- " $name$_ = "
- "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
+ " $field$ = reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
} else {
- format(" $name$_ = $name$;\n");
+ format(" $field$ = $name$;\n");
}
format(
" if ($name$) {\n"
@@ -201,7 +206,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_release$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
- " $name$_ = nullptr;\n"
+ " $field$ = nullptr;\n"
"#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" auto* old = reinterpret_cast<::$proto_ns$::MessageLite*>(temp);\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
@@ -219,7 +224,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$type_reference_function$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
- " $name$_ = nullptr;\n"
+ " $field$ = nullptr;\n"
" return temp;\n"
"}\n");
@@ -227,12 +232,12 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline $type$* $classname$::_internal_mutable_$name$() {\n"
"$type_reference_function$"
" $set_hasbit$\n"
- " if ($name$_ == nullptr) {\n"
+ " if ($field$ == nullptr) {\n"
" auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n");
if (implicit_weak_field_) {
- format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n");
+ format(" $field$ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n");
} else {
- format(" $name$_ = p;\n");
+ format(" $field$ = p;\n");
}
format(
" }\n"
@@ -253,9 +258,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(" if (message_arena == nullptr) {\n");
if (IsCrossFileMessage(descriptor_)) {
format(
- " delete reinterpret_cast< ::$proto_ns$::MessageLite*>($name$_);\n");
+ " delete reinterpret_cast< ::$proto_ns$::MessageLite*>($field$);\n");
} else {
- format(" delete $name$_;\n");
+ format(" delete $field$;\n");
}
format(
" }\n"
@@ -265,14 +270,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
// isn't defined in this file.
format(
" ::$proto_ns$::Arena* submessage_arena =\n"
- " ::$proto_ns$::Arena::InternalHelper<\n"
- " ::$proto_ns$::MessageLite>::GetOwningArena(\n"
+ " ::$proto_ns$::Arena::InternalGetOwningArena(\n"
" reinterpret_cast<::$proto_ns$::MessageLite*>("
"$name$));\n");
} else {
format(
" ::$proto_ns$::Arena* submessage_arena =\n"
- " ::$proto_ns$::Arena::InternalHelper<$type$>::GetOwningArena("
+ " ::$proto_ns$::Arena::InternalGetOwningArena("
"$name$);\n");
}
format(
@@ -285,9 +289,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n"
" }\n");
if (implicit_weak_field_) {
- format(" $name$_ = reinterpret_cast<MessageLite*>($name$);\n");
+ format(" $field$ = reinterpret_cast<MessageLite*>($name$);\n");
} else {
- format(" $name$_ = $name$;\n");
+ format(" $field$ = $name$;\n");
}
format(
"$annotate_set$"
@@ -322,14 +326,10 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
format(
"const ::$proto_ns$::MessageLite& $classname$::_Internal::$name$(\n"
" const $classname$* msg) {\n"
- " if (msg->$name$_ != nullptr) {\n"
- " return *msg->$name$_;\n"
- " } else if ($type_default_instance_ptr$ != nullptr) {\n"
- " return *reinterpret_cast<const ::$proto_ns$::MessageLite*>(\n"
- " $type_default_instance_ptr$);\n"
+ " if (msg->$field$ != nullptr) {\n"
+ " return *msg->$field$;\n"
" } else {\n"
- " return "
- "*::$proto_ns$::internal::ImplicitWeakMessage::default_instance();\n"
+ " return *$type_default_instance_ptr$;\n"
" }\n"
"}\n");
format(
@@ -338,20 +338,19 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
if (HasHasbit(descriptor_)) {
format(" msg->$set_hasbit$\n");
}
+ if (descriptor_->real_containing_oneof() == nullptr) {
+ format(" if (msg->$field$ == nullptr) {\n");
+ } else {
+ format(
+ " if (!msg->_internal_has_$name$()) {\n"
+ " msg->clear_$oneof_name$();\n"
+ " msg->set_has_$name$();\n");
+ }
format(
- " if (msg->$name$_ == nullptr) {\n"
- " if ($type_default_instance_ptr$ == nullptr) {\n"
- " msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n"
- " ::$proto_ns$::internal::ImplicitWeakMessage>(\n"
- " msg->GetArenaForAllocation());\n"
- " } else {\n"
- " msg->$name$_ = \n"
- " reinterpret_cast<const ::$proto_ns$::MessageLite*>(\n"
- " $type_default_instance_ptr$)->New(\n"
- " msg->GetArenaForAllocation());\n"
- " }\n"
+ " msg->$field$ = $type_default_instance_ptr$->New(\n"
+ " msg->GetArenaForAllocation());\n"
" }\n"
- " return msg->$name$_;\n"
+ " return msg->$field$;\n"
"}\n");
} else {
// This inline accessor directly returns member field and is used in
@@ -360,7 +359,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
format(
"const $type$&\n"
"$classname$::_Internal::$name$(const $classname$* msg) {\n"
- " return *msg->$field_member$;\n"
+ " return *msg->$field$;\n"
"}\n");
}
}
@@ -371,14 +370,14 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
if (!HasHasbit(descriptor_)) {
// If we don't have has-bits, message presence is indicated only by ptr !=
- // NULL. Thus on clear, we need to delete the object.
+ // nullptr. Thus on clear, we need to delete the object.
format(
- "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n"
- " delete $name$_;\n"
+ "if (GetArenaForAllocation() == nullptr && $field$ != nullptr) {\n"
+ " delete $field$;\n"
"}\n"
- "$name$_ = nullptr;\n");
+ "$field$ = nullptr;\n");
} else {
- format("if ($name$_ != nullptr) $name$_->Clear();\n");
+ format("if ($field$ != nullptr) $field$->Clear();\n");
}
}
@@ -389,16 +388,16 @@ void MessageFieldGenerator::GenerateMessageClearingCode(
Formatter format(printer, variables_);
if (!HasHasbit(descriptor_)) {
// If we don't have has-bits, message presence is indicated only by ptr !=
- // NULL. Thus on clear, we need to delete the object.
+ // nullptr. Thus on clear, we need to delete the object.
format(
- "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n"
- " delete $name$_;\n"
+ "if (GetArenaForAllocation() == nullptr && $field$ != nullptr) {\n"
+ " delete $field$;\n"
"}\n"
- "$name$_ = nullptr;\n");
+ "$field$ = nullptr;\n");
} else {
format(
- "$DCHK$($name$_ != nullptr);\n"
- "$name$_->Clear();\n");
+ "$DCHK$($field$ != nullptr);\n"
+ "$field$->Clear();\n");
}
}
@@ -421,7 +420,7 @@ void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format("swap($name$_, other->$name$_);\n");
+ format("swap($field$, other->$field$);\n");
}
void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
@@ -436,7 +435,7 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
// care when handling them.
format("if (this != internal_default_instance()) ");
}
- format("delete $name$_;\n");
+ format("delete $field$;\n");
}
void MessageFieldGenerator::GenerateConstructorCode(
@@ -444,7 +443,7 @@ void MessageFieldGenerator::GenerateConstructorCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format("$name$_ = nullptr;\n");
+ format("$field$ = nullptr;\n");
}
void MessageFieldGenerator::GenerateCopyConstructorCode(
@@ -454,9 +453,9 @@ void MessageFieldGenerator::GenerateCopyConstructorCode(
Formatter format(printer, variables_);
format(
"if (from._internal_has_$name$()) {\n"
- " $name$_ = new $type$(*from.$name$_);\n"
+ " $field$ = new $type$(*from.$field$);\n"
"} else {\n"
- " $name$_ = nullptr;\n"
+ " $field$ = nullptr;\n"
"}\n");
}
@@ -465,11 +464,18 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format(
- "target = stream->EnsureSpace(target);\n"
- "target = ::$proto_ns$::internal::WireFormatLite::\n"
- " InternalWrite$declared_type$(\n"
- " $number$, _Internal::$name$(this), target, stream);\n");
+ if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
+ format(
+ "target = ::$proto_ns$::internal::WireFormatLite::\n"
+ " InternalWrite$declared_type$($number$, _Internal::$name$(this),\n"
+ " _Internal::$name$(this).GetCachedSize(), target, stream);\n");
+ } else {
+ format(
+ "target = stream->EnsureSpace(target);\n"
+ "target = ::$proto_ns$::internal::WireFormatLite::\n"
+ " InternalWrite$declared_type$(\n"
+ " $number$, _Internal::$name$(this), target, stream);\n");
+ }
}
void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
@@ -479,7 +485,7 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
format(
"total_size += $tag_size$ +\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
- " *$field_member$);\n");
+ " *$field$);\n");
}
void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
@@ -490,7 +496,7 @@ void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"if (_internal_has_$name$()) {\n"
- " if (!$name$_->IsInitialized()) return false;\n"
+ " if (!$field$->IsInitialized()) return false;\n"
"}\n");
}
@@ -524,15 +530,13 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
// isn't defined in this file.
format(
" ::$proto_ns$::Arena* submessage_arena =\n"
- " ::$proto_ns$::Arena::InternalHelper<\n"
- " ::$proto_ns$::MessageLite>::GetOwningArena(\n"
+ " ::$proto_ns$::Arena::InternalGetOwningArena(\n"
" reinterpret_cast<::$proto_ns$::MessageLite*>("
"$name$));\n");
} else {
format(
" ::$proto_ns$::Arena* submessage_arena =\n"
- " ::$proto_ns$::Arena::InternalHelper<"
- "$type$>::GetOwningArena($name$);\n");
+ " ::$proto_ns$::Arena::InternalGetOwningArena($name$);\n");
}
format(
" if (message_arena != submessage_arena) {\n"
@@ -540,7 +544,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
" message_arena, $name$, submessage_arena);\n"
" }\n"
" set_has_$name$();\n"
- " $field_member$ = $name$;\n"
+ " $field$ = $name$;\n"
" }\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
@@ -554,13 +558,14 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"inline $type$* $classname$::$release_name$() {\n"
"$annotate_release$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
+ "$type_reference_function$"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
- " $type$* temp = $field_member$;\n"
+ " $type$* temp = $casted_member$;\n"
" if (GetArenaForAllocation() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n"
- " $field_member$ = nullptr;\n"
+ " $field$ = nullptr;\n"
" return temp;\n"
" } else {\n"
" return nullptr;\n"
@@ -569,8 +574,9 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline const $type$& $classname$::_internal_$name$() const {\n"
+ "$type_reference_function$"
" return _internal_has_$name$()\n"
- " ? *$field_member$\n"
+ " ? $casted_member_const$\n"
" : reinterpret_cast< $type$&>($type_default_instance$);\n"
"}\n"
"inline const $type$& $classname$::$name$() const {\n"
@@ -582,10 +588,11 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_release$"
" // @@protoc_insertion_point(field_unsafe_arena_release"
":$full_name$)\n"
+ "$type_reference_function$"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
- " $type$* temp = $field_member$;\n"
- " $field_member$ = nullptr;\n"
+ " $type$* temp = $casted_member$;\n"
+ " $field$ = nullptr;\n"
" return temp;\n"
" } else {\n"
" return nullptr;\n"
@@ -598,21 +605,38 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
// new value.
" clear_$oneof_name$();\n"
" if ($name$) {\n"
- " set_has_$name$();\n"
- " $field_member$ = $name$;\n"
+ " set_has_$name$();\n");
+ if (implicit_weak_field_) {
+ format(
+ " $field$ = "
+ "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
+ } else {
+ format(" $field$ = $name$;\n");
+ }
+ format(
" }\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
"$full_name$)\n"
"}\n"
"inline $type$* $classname$::_internal_mutable_$name$() {\n"
+ "$type_reference_function$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $field_member$ = CreateMaybeMessage< $type$ "
- ">(GetArenaForAllocation());\n"
+ " set_has_$name$();\n");
+ if (implicit_weak_field_) {
+ format(
+ " $field$ = "
+ "reinterpret_cast<::$proto_ns$::MessageLite*>(CreateMaybeMessage< "
+ "$type$ >(GetArenaForAllocation()));\n");
+ } else {
+ format(
+ " $field$ = CreateMaybeMessage< $type$ "
+ ">(GetArenaForAllocation());\n");
+ }
+ format(
" }\n"
- " return $field_member$;\n"
+ " return $casted_member$;\n"
"}\n"
"inline $type$* $classname$::mutable_$name$() {\n"
" $type$* _msg = _internal_mutable_$name$();\n"
@@ -629,7 +653,7 @@ void MessageOneofFieldGenerator::GenerateClearingCode(
Formatter format(printer, variables_);
format(
"if (GetArenaForAllocation() == nullptr) {\n"
- " delete $field_member$;\n"
+ " delete $field$;\n"
"}\n");
}
@@ -662,7 +686,7 @@ void MessageOneofFieldGenerator::GenerateIsInitialized(
Formatter format(printer, variables_);
format(
"if (_internal_has_$name$()) {\n"
- " if (!$field_member$->IsInitialized()) return false;\n"
+ " if (!$field$->IsInitialized()) return false;\n"
"}\n");
}
@@ -741,21 +765,21 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
// TODO(dlj): move insertion points
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
"$type_reference_function$"
- " return $name$_$weak$.Mutable(index);\n"
+ " return $field$$weak$.Mutable(index);\n"
"}\n"
"inline ::$proto_ns$::RepeatedPtrField< $type$ >*\n"
"$classname$::mutable_$name$() {\n"
"$annotate_mutable_list$"
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
"$type_reference_function$"
- " return &$name$_$weak$;\n"
+ " return &$field$$weak$;\n"
"}\n");
if (options_.safe_boundary_check) {
format(
"inline const $type$& $classname$::_internal_$name$(int index) const "
"{\n"
- " return $name$_$weak$.InternalCheckedGet(index,\n"
+ " return $field$$weak$.InternalCheckedGet(index,\n"
" reinterpret_cast<const $type$&>($type_default_instance$));\n"
"}\n");
} else {
@@ -763,7 +787,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline const $type$& $classname$::_internal_$name$(int index) const "
"{\n"
"$type_reference_function$"
- " return $name$_$weak$.Get(index);\n"
+ " return $field$$weak$.Get(index);\n"
"}\n");
}
@@ -774,7 +798,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
" return _internal_$name$(index);\n"
"}\n"
"inline $type$* $classname$::_internal_add_$name$() {\n"
- " return $name$_$weak$.Add();\n"
+ " return $field$$weak$.Add();\n"
"}\n"
"inline $type$* $classname$::add_$name$() {\n"
" $type$* _add = _internal_add_$name$();\n"
@@ -789,7 +813,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_list$"
" // @@protoc_insertion_point(field_list:$full_name$)\n"
"$type_reference_function$"
- " return $name$_$weak$;\n"
+ " return $field$$weak$;\n"
"}\n");
}
@@ -798,7 +822,7 @@ void RepeatedMessageFieldGenerator::GenerateClearingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format("$name$_.Clear();\n");
+ format("$field$.Clear();\n");
}
void RepeatedMessageFieldGenerator::GenerateMergingCode(
@@ -806,7 +830,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format("$name$_.MergeFrom(from.$name$_);\n");
+ format("$field$.MergeFrom(from.$field$);\n");
}
void RepeatedMessageFieldGenerator::GenerateSwappingCode(
@@ -814,7 +838,7 @@ void RepeatedMessageFieldGenerator::GenerateSwappingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format("$name$_.InternalSwap(&other->$name$_);\n");
+ format("$field$.InternalSwap(&other->$field$);\n");
}
void RepeatedMessageFieldGenerator::GenerateConstructorCode(
@@ -829,23 +853,41 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format(
- "for (auto it = this->$name$_.pointer_begin(),\n"
- " end = this->$name$_.pointer_end(); it < end; ++it) {\n"
- " target = stream->EnsureSpace(target);\n"
- " target = ::$proto_ns$::internal::WireFormatLite::\n"
- " InternalWrite$declared_type$($number$, **it, target, stream);\n"
- "}\n");
+ "for (auto it = this->$field$.pointer_begin(),\n"
+ " end = this->$field$.pointer_end(); it < end; ++it) {\n");
+ if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
+ format(
+ " target = ::$proto_ns$::internal::WireFormatLite::\n"
+ " InternalWrite$declared_type$($number$, "
+ "**it, (**it).GetCachedSize(), target, stream);\n");
+ } else {
+ format(
+ " target = stream->EnsureSpace(target);\n"
+ " target = ::$proto_ns$::internal::WireFormatLite::\n"
+ " InternalWrite$declared_type$($number$, **it, target, "
+ "stream);\n");
+ }
+ format("}\n");
} else {
format(
- "for (unsigned int i = 0,\n"
- " n = static_cast<unsigned int>(this->_internal_$name$_size()); i < "
- "n; i++) "
- "{\n"
- " target = stream->EnsureSpace(target);\n"
- " target = ::$proto_ns$::internal::WireFormatLite::\n"
- " InternalWrite$declared_type$($number$, "
- "this->_internal_$name$(i), target, stream);\n"
- "}\n");
+ "for (unsigned i = 0,\n"
+ " n = static_cast<unsigned>(this->_internal_$name$_size());"
+ " i < n; i++) {\n");
+ if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
+ format(
+ " const auto& repfield = this->_internal_$name$(i);\n"
+ " target = ::$proto_ns$::internal::WireFormatLite::\n"
+ " InternalWrite$declared_type$($number$, "
+ "repfield, repfield.GetCachedSize(), target, stream);\n"
+ "}\n");
+ } else {
+ format(
+ " target = stream->EnsureSpace(target);\n"
+ " target = ::$proto_ns$::internal::WireFormatLite::\n"
+ " InternalWrite$declared_type$($number$, "
+ "this->_internal_$name$(i), target, stream);\n"
+ "}\n");
+ }
}
}
@@ -856,7 +898,7 @@ void RepeatedMessageFieldGenerator::GenerateByteSize(
Formatter format(printer, variables_);
format(
"total_size += $tag_size$UL * this->_internal_$name$_size();\n"
- "for (const auto& msg : this->$name$_) {\n"
+ "for (const auto& msg : this->$field$) {\n"
" total_size +=\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(msg);\n"
"}\n");
@@ -871,11 +913,11 @@ void RepeatedMessageFieldGenerator::GenerateIsInitialized(
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format(
- "if (!::$proto_ns$::internal::AllAreInitializedWeak($name$_.weak))\n"
+ "if (!::$proto_ns$::internal::AllAreInitializedWeak($field$.weak))\n"
" return false;\n");
} else {
format(
- "if (!::$proto_ns$::internal::AllAreInitialized($name$_))\n"
+ "if (!::$proto_ns$::internal::AllAreInitialized($field$))\n"
" return false;\n");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
index 2beac6253b..528b419704 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h
index 9d8063d9ca..80860053f1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h
@@ -35,8 +35,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__
-#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h
index 8b745ff21c..39563cd0cd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h
@@ -33,6 +33,7 @@
#include <string>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
index 23adb91430..48512a64c8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
@@ -58,34 +58,39 @@ struct FieldListenerOptions {
// Generator options (see generator.cc for a description of each):
struct Options {
+ const AccessInfoMap* access_info_map = nullptr;
TProtoStringType dllexport_decl;
+ TProtoStringType runtime_include_base;
+ TProtoStringType annotation_pragma_name;
+ TProtoStringType annotation_guard_name;
+ FieldListenerOptions field_listener_options;
+ EnforceOptimizeMode enforce_mode = EnforceOptimizeMode::kNoEnforcement;
+ enum {
+ kTCTableNever,
+ kTCTableGuarded,
+ kTCTableAlways
+ } tctable_mode = kTCTableNever;
+ int num_cc_files = 0;
bool safe_boundary_check = false;
bool proto_h = false;
bool transitive_pb_h = true;
bool annotate_headers = false;
- EnforceOptimizeMode enforce_mode = EnforceOptimizeMode::kNoEnforcement;
- bool table_driven_parsing = false;
- bool table_driven_serialization = false;
bool lite_implicit_weak_fields = false;
bool bootstrap = false;
bool opensource_runtime = false;
bool annotate_accessor = false;
bool unused_field_stripping = false;
+ bool unverified_lazy_message_sets = true;
+ bool eagerly_verified_lazy = true;
bool profile_driven_inline_string = true;
- bool force_inline_string = false;
- TProtoStringType runtime_include_base;
- int num_cc_files = 0;
- TProtoStringType annotation_pragma_name;
- TProtoStringType annotation_guard_name;
- const AccessInfoMap* access_info_map = nullptr;
- enum {
- kTCTableNever,
- kTCTableGuarded,
- kTCTableAlways
- } tctable_mode = kTCTableNever;
- FieldListenerOptions field_listener_options;
- bool eagerly_verified_lazy = false;
+ bool force_split = false;
+#ifdef PROTOBUF_STABLE_EXPERIMENTS
+ bool force_eagerly_verified_lazy = true;
+ bool force_inline_string = true;
+#else // PROTOBUF_STABLE_EXPERIMENTS
bool force_eagerly_verified_lazy = false;
+ bool force_inline_string = false;
+#endif // !PROTOBUF_STABLE_EXPERIMENTS
};
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc
index 0b660c75b7..f48ba718a5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc
@@ -47,7 +47,7 @@ class FieldGroup {
FieldGroup() : preferred_location_(0) {}
// A group with a single field.
- FieldGroup(float preferred_location, const FieldDescriptor* field)
+ FieldGroup(double preferred_location, const FieldDescriptor* field)
: preferred_location_(preferred_location), fields_(1, field) {}
// Append the fields in 'other' to this group.
@@ -63,7 +63,7 @@ class FieldGroup {
fields_.insert(fields_.end(), other.fields_.begin(), other.fields_.end());
}
- void SetPreferredLocation(float location) { preferred_location_ = location; }
+ void SetPreferredLocation(double location) { preferred_location_ = location; }
const std::vector<const FieldDescriptor*>& fields() const { return fields_; }
// FieldGroup objects sort by their preferred location.
@@ -77,7 +77,7 @@ class FieldGroup {
// field in this group in the original ordering of fields. This is very
// approximate, but should put this group close to where its member fields
// originally went.
- float preferred_location_;
+ double preferred_location_;
std::vector<const FieldDescriptor*> fields_;
// We rely on the default copy constructor and operator= so this type can be
// used in a vector.
@@ -203,7 +203,7 @@ void PaddingOptimizer::OptimizeLayout(
field_group.SetPreferredLocation(-1);
} else {
// Move incomplete 4-byte block to the end.
- field_group.SetPreferredLocation(fields->size() + 1);
+ field_group.SetPreferredLocation(double{FieldDescriptor::kMaxNumber});
}
}
aligned_to_8[f].push_back(field_group);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
index 282d70e391..e033856f0c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
@@ -33,9 +33,10 @@
#include <algorithm>
#include <limits>
#include <string>
+#include <utility>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/wire_format.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
namespace google {
namespace protobuf {
@@ -43,7 +44,6 @@ namespace compiler {
namespace cpp {
namespace {
-using google::protobuf::internal::TcFieldData;
using google::protobuf::internal::WireFormat;
using google::protobuf::internal::WireFormatLite;
@@ -73,167 +73,351 @@ int TagSize(arc_ui32 field_number) {
return 2;
}
-const char* CodedTagType(int tag_size) {
- return tag_size == 1 ? "uint8_t" : "uint16_t";
-}
+TProtoStringType FieldParseFunctionName(
+ const TailCallTableInfo::FieldEntryInfo& entry, const Options& options);
+
+bool IsFieldEligibleForFastParsing(
+ const TailCallTableInfo::FieldEntryInfo& entry, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ const auto* field = entry.field;
+ // Map, oneof, weak, and lazy fields are not handled on the fast path.
+ if (field->is_map() || field->real_containing_oneof() ||
+ field->options().weak() ||
+ IsImplicitWeakField(field, options, scc_analyzer) ||
+ IsLazy(field, options, scc_analyzer)) {
+ return false;
+ }
-const char* TagType(const FieldDescriptor* field) {
- return CodedTagType(TagSize(field->number()));
-}
+ // We will check for a valid auxiliary index range later. However, we might
+ // want to change the value we check for inlined string fields.
+ int aux_idx = entry.aux_idx;
-TProtoStringType TcParserName(const Options& options) {
- return StrCat("::", ProtobufNamespace(options),
- "::internal::TcParser::");
-}
+ switch (field->type()) {
+ case FieldDescriptor::TYPE_ENUM:
+ // If enum values are not validated at parse time, then this field can be
+ // handled on the fast path like an int32.
+ if (HasPreservingUnknownEnumSemantics(field)) {
+ break;
+ }
+ if (field->is_repeated() && field->is_packed()) {
+ return false;
+ }
+ break;
+
+ // Some bytes fields can be handled on fast path.
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES:
+ if (field->options().ctype() != FieldOptions::STRING) {
+ return false;
+ }
+ if (IsStringInlined(field, options)) {
+ GOOGLE_CHECK(!field->is_repeated());
+ // For inlined strings, the donation state index is stored in the
+ // `aux_idx` field of the fast parsing info. We need to check the range
+ // of that value instead of the auxiliary index.
+ aux_idx = entry.inlined_string_idx;
+ }
+ break;
-TProtoStringType MessageTcParseFunctionName(const FieldDescriptor* field,
- const Options& options) {
- if (field->message_type()->field_count() == 0 ||
- !HasGeneratedMethods(field->message_type()->file(), options)) {
- // For files with `option optimize_for = CODE_SIZE`, or which derive from
- // `ZeroFieldsBase`, we need to call the `_InternalParse` function, because
- // there is no generated tailcall function. For tailcall parsing, this is
- // done by helpers in TcParser.
- return StrCat(TcParserName(options),
- (field->is_repeated() ? "Repeated" : "Singular"),
- "ParseMessage<",
- QualifiedClassName(field->message_type()), //
- ", ", TagType(field), ">");
+ default:
+ break;
}
- // This matches macros in generated_message_tctable_impl.h:
- return StrCat("PROTOBUF_TC_PARSE_",
- (field->is_repeated() ? "REPEATED" : "SINGULAR"),
- TagSize(field->number()), "(",
- QualifiedClassName(field->message_type()), ")");
+
+ if (HasHasbit(field)) {
+ // The tailcall parser can only update the first 32 hasbits. Fields with
+ // has-bits beyond the first 32 are handled by mini parsing/fallback.
+ GOOGLE_CHECK_GE(entry.hasbit_idx, 0) << field->DebugString();
+ if (entry.hasbit_idx >= 32) return false;
+ }
+
+ // If the field needs auxiliary data, then the aux index is needed. This
+ // must fit in a uint8_t.
+ if (aux_idx > std::numeric_limits<uint8_t>::max()) {
+ return false;
+ }
+
+ // The largest tag that can be read by the tailcall parser is two bytes
+ // when varint-coded. This allows 14 bits for the numeric tag value:
+ // byte 0 byte 1
+ // 1nnnnttt 0nnnnnnn
+ // ^^^^^^^ ^^^^^^^
+ if (field->number() >= 1 << 11) return false;
+
+ return true;
}
-TProtoStringType FieldParseFunctionName(const FieldDescriptor* field,
- const Options& options);
+std::vector<TailCallTableInfo::FastFieldInfo> SplitFastFieldsForSize(
+ const std::vector<TailCallTableInfo::FieldEntryInfo>& field_entries,
+ int table_size_log2, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ std::vector<TailCallTableInfo::FastFieldInfo> result(1 << table_size_log2);
+ const arc_ui32 idx_mask = result.size() - 1;
-} // namespace
+ for (const auto& entry : field_entries) {
+ if (!IsFieldEligibleForFastParsing(entry, options, scc_analyzer)) {
+ continue;
+ }
-TailCallTableInfo::TailCallTableInfo(const Descriptor* descriptor,
- const Options& options,
- const std::vector<int>& has_bit_indices,
- MessageSCCAnalyzer* scc_analyzer) {
- std::vector<const FieldDescriptor*> ordered_fields =
- GetOrderedFields(descriptor, options);
-
- // The table size is rounded up to the nearest power of 2, clamping at 2^5.
- // Note that this is a naive approach: a better approach should only consider
- // table-eligible fields. We may also want to push rarely-encountered fields
- // into the fallback, to make the table smaller.
- table_size_log2 = ordered_fields.size() >= 16 ? 5
- : ordered_fields.size() >= 8 ? 4
- : ordered_fields.size() >= 4 ? 3
- : ordered_fields.size() >= 2 ? 2
- : 1;
- const unsigned table_size = 1 << table_size_log2;
-
- // Construct info for each possible entry. Fields that do not use table-driven
- // parsing will still have an entry that nominates the fallback function.
- fast_path_fields.resize(table_size);
-
- for (const auto* field : ordered_fields) {
- // Eagerly assume slow path. If we can handle this field on the fast path,
- // we will pop its entry from `fallback_fields`.
- fallback_fields.push_back(field);
-
- // Anything difficult slow path:
- if (field->is_map()) continue;
- if (field->real_containing_oneof()) continue;
- if (field->options().weak()) continue;
- if (IsImplicitWeakField(field, options, scc_analyzer)) continue;
- if (IsLazy(field, options, scc_analyzer)) continue;
-
- // The largest tag that can be read by the tailcall parser is two bytes
- // when varint-coded. This allows 14 bits for the numeric tag value:
- // byte 0 byte 1
- // 1nnnnttt 0nnnnnnn
- // ^^^^^^^ ^^^^^^^
+ const auto* field = entry.field;
arc_ui32 tag = WireFormat::MakeTag(field);
- if (tag >= 1 << 14) {
- continue;
- } else if (tag >= 1 << 7) {
- tag = ((tag << 1) & 0x7F00) | 0x80 | (tag & 0x7F);
+
+ // Construct the varint-coded tag. If it is more than 7 bits, we need to
+ // shift the high bits and add a continue bit.
+ if (arc_ui32 hibits = tag & 0xFFFFFF80) {
+ tag = tag + hibits + 128; // tag = lobits + 2*hibits + 128
}
+
// The field index is determined by the low bits of the field number, where
// the table size determines the width of the mask. The largest table
// supported is 32 entries. The parse loop uses these bits directly, so that
// the dispatch does not require arithmetic:
- // byte 0 byte 1
- // 1nnnnttt 0nnnnnnn
- // ^^^^^
+ // byte 0 byte 1
+ // tag: 1nnnnttt 0nnnnnnn
+ // ^^^^^
+ // idx (table_size_log2=5)
// This means that any field number that does not fit in the lower 4 bits
- // will always have the top bit of its table index asserted:
- arc_ui32 idx = (tag >> 3) & (table_size - 1);
- // If this entry in the table is already used, then this field will be
- // handled by the generated fallback function.
- if (!fast_path_fields[idx].func_name.empty()) continue;
-
- // Determine the hasbit mask for this field, if needed. (Note that fields
- // without hasbits use different parse functions.)
- int hasbit_idx;
- if (HasHasbit(field)) {
- hasbit_idx = has_bit_indices[field->index()];
- GOOGLE_CHECK_NE(-1, hasbit_idx) << field->DebugString();
- // The tailcall parser can only update the first 32 hasbits. If this
- // field's has-bit is beyond that, then it will need to be handled by the
- // fallback parse function.
- if (hasbit_idx >= 32) continue;
+ // will always have the top bit of its table index asserted.
+ const arc_ui32 fast_idx = (tag >> 3) & idx_mask;
+
+ TailCallTableInfo::FastFieldInfo& info = result[fast_idx];
+ if (info.field != nullptr) {
+ // This field entry is already filled.
+ continue;
+ }
+
+ // Fill in this field's entry:
+ GOOGLE_CHECK(info.func_name.empty()) << info.func_name;
+ info.func_name = FieldParseFunctionName(entry, options);
+ info.field = field;
+ info.coded_tag = tag;
+ // If this field does not have presence, then it can set an out-of-bounds
+ // bit (tailcall parsing uses a arc_ui64 for hasbits, but only stores 32).
+ info.hasbit_idx = HasHasbit(field) ? entry.hasbit_idx : 63;
+ if (IsStringInlined(field, options)) {
+ GOOGLE_CHECK(!field->is_repeated());
+ info.aux_idx = static_cast<uint8_t>(entry.inlined_string_idx);
} else {
- // The tailcall parser only ever syncs 32 has-bits, so if there is no
- // presence, set a bit that will not be used.
- hasbit_idx = 63;
+ info.aux_idx = static_cast<uint8_t>(entry.aux_idx);
}
+ }
+ return result;
+}
- // Determine the name of the fastpath parse function to use for this field.
- TProtoStringType name;
+// Filter out fields that will be handled by mini parsing.
+std::vector<const FieldDescriptor*> FilterMiniParsedFields(
+ const std::vector<const FieldDescriptor*>& fields, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ std::vector<const FieldDescriptor*> generated_fallback_fields;
+ for (const auto* field : fields) {
+ bool handled = false;
switch (field->type()) {
- case FieldDescriptor::TYPE_MESSAGE:
- name = MessageTcParseFunctionName(field, options);
- break;
-
- case FieldDescriptor::TYPE_FIXED64:
- case FieldDescriptor::TYPE_FIXED32:
- case FieldDescriptor::TYPE_SFIXED64:
- case FieldDescriptor::TYPE_SFIXED32:
case FieldDescriptor::TYPE_DOUBLE:
case FieldDescriptor::TYPE_FLOAT:
- case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_SFIXED32:
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_BOOL:
+ case FieldDescriptor::TYPE_UINT32:
+ case FieldDescriptor::TYPE_SINT32:
case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_UINT64:
- case FieldDescriptor::TYPE_UINT32:
case FieldDescriptor::TYPE_SINT64:
- case FieldDescriptor::TYPE_SINT32:
- case FieldDescriptor::TYPE_BOOL:
- name = FieldParseFunctionName(field, options);
+ case FieldDescriptor::TYPE_INT64:
+ // These are handled by MiniParse, so we don't need any generated
+ // fallback code.
+ handled = true;
break;
- case FieldDescriptor::TYPE_BYTES:
- if (field->options().ctype() == FieldOptions::STRING &&
- field->default_value_string().empty() &&
- !IsStringInlined(field, options)) {
- name = FieldParseFunctionName(field, options);
+ case FieldDescriptor::TYPE_ENUM:
+ if (field->is_repeated() &&
+ !HasPreservingUnknownEnumSemantics(field)) {
+ // TODO(b/206890171): handle packed repeated closed enums
+ // Non-packed repeated can be handled using tables, but we still
+ // need to generate fallback code for all repeated enums in order to
+ // handle packed encoding. This is because of the lite/full split
+ // when handling invalid enum values in a packed field.
+ handled = false;
+ } else {
+ handled = true;
+ }
+ break;
+
+ case FieldDescriptor::TYPE_BYTES:
+ case FieldDescriptor::TYPE_STRING:
+ if (IsStringInlined(field, options)) {
+ // TODO(b/198211897): support InilnedStringField.
+ handled = false;
+ } else {
+ handled = true;
+ }
+ break;
+
+ case FieldDescriptor::TYPE_MESSAGE:
+ case FieldDescriptor::TYPE_GROUP:
+ // TODO(b/210762816): support remaining field types.
+ if (field->is_map() || IsWeak(field, options) ||
+ IsImplicitWeakField(field, options, scc_analyzer) ||
+ IsLazy(field, options, scc_analyzer)) {
+ handled = false;
+ } else {
+ handled = true;
}
break;
default:
+ handled = false;
break;
}
+ if (!handled) generated_fallback_fields.push_back(field);
+ }
- if (name.empty()) {
- continue;
+ return generated_fallback_fields;
+}
+
+} // namespace
+
+TailCallTableInfo::TailCallTableInfo(
+ const Descriptor* descriptor, const Options& options,
+ const std::vector<const FieldDescriptor*>& ordered_fields,
+ const std::vector<int>& has_bit_indices,
+ const std::vector<int>& inlined_string_indices,
+ MessageSCCAnalyzer* scc_analyzer) {
+ int oneof_count = descriptor->real_oneof_decl_count();
+ // If this message has any oneof fields, store the case offset in the first
+ // auxiliary entry.
+ if (oneof_count > 0) {
+ GOOGLE_LOG_IF(DFATAL, ordered_fields.empty())
+ << "Invalid message: " << descriptor->full_name() << " has "
+ << oneof_count << " oneof declarations, but no fields";
+ aux_entries.push_back(StrCat(
+ "_fl::Offset{offsetof(", ClassName(descriptor), ", _oneof_case_)}"));
+ }
+
+ // If this message has any inlined string fields, store the donation state
+ // offset in the second auxiliary entry.
+ if (!inlined_string_indices.empty()) {
+ aux_entries.resize(2); // pad if necessary
+ aux_entries[1] =
+ StrCat("_fl::Offset{offsetof(", ClassName(descriptor),
+ ", _inlined_string_donated_)}");
+ }
+
+ // Fill in mini table entries.
+ for (const FieldDescriptor* field : ordered_fields) {
+ field_entries.push_back(
+ {field, (HasHasbit(field) ? has_bit_indices[field->index()] : -1)});
+ auto& entry = field_entries.back();
+
+ if (field->type() == FieldDescriptor::TYPE_MESSAGE ||
+ field->type() == FieldDescriptor::TYPE_GROUP) {
+ // Message-typed fields have a FieldAux with the default instance pointer.
+ if (field->is_map()) {
+ // TODO(b/205904770): generate aux entries for maps
+ } else if (IsWeak(field, options)) {
+ // Don't generate anything for weak fields. They are handled by the
+ // generated fallback.
+ } else if (IsImplicitWeakField(field, options, scc_analyzer)) {
+ // Implicit weak fields don't need to store a default instance pointer.
+ } else if (IsLazy(field, options, scc_analyzer)) {
+ // Lazy fields are handled by the generated fallback function.
+ } else {
+ field_entries.back().aux_idx = aux_entries.size();
+ const Descriptor* field_type = field->message_type();
+ aux_entries.push_back(StrCat(
+ "reinterpret_cast<const ", QualifiedClassName(field_type, options),
+ "*>(&", QualifiedDefaultInstanceName(field_type, options), ")"));
+ }
+ } else if (field->type() == FieldDescriptor::TYPE_ENUM &&
+ !HasPreservingUnknownEnumSemantics(field)) {
+ // Enum fields which preserve unknown values (proto3 behavior) are
+ // effectively int32 fields with respect to parsing -- i.e., the value
+ // does not need to be validated at parse time.
+ //
+ // Enum fields which do not preserve unknown values (proto2 behavior) use
+ // a FieldAux to store validation information. If the enum values are
+ // sequential (and within a range we can represent), then the FieldAux
+ // entry represents the range using the minimum value (which must fit in
+ // an int16_t) and count (a uint16_t). Otherwise, the entry holds a
+ // pointer to the generated Name_IsValid function.
+
+ entry.aux_idx = aux_entries.size();
+ const EnumDescriptor* enum_type = field->enum_type();
+ GOOGLE_CHECK_GT(enum_type->value_count(), 0) << enum_type->DebugString();
+
+ // Check if the enum values are a single, contiguous range.
+ std::vector<int> enum_values;
+ for (int i = 0, N = enum_type->value_count(); i < N; ++i) {
+ enum_values.push_back(enum_type->value(i)->number());
+ }
+ auto values_begin = enum_values.begin();
+ auto values_end = enum_values.end();
+ std::sort(values_begin, values_end);
+ enum_values.erase(std::unique(values_begin, values_end), values_end);
+
+ if (enum_values.back() - enum_values[0] == enum_values.size() - 1 &&
+ enum_values[0] >= std::numeric_limits<int16_t>::min() &&
+ enum_values[0] <= std::numeric_limits<int16_t>::max() &&
+ enum_values.size() <= std::numeric_limits<uint16_t>::max()) {
+ entry.is_enum_range = true;
+ aux_entries.push_back(
+ StrCat(enum_values[0], ", ", enum_values.size()));
+ } else {
+ entry.is_enum_range = false;
+ aux_entries.push_back(
+ StrCat(QualifiedClassName(enum_type, options), "_IsValid"));
+ }
+ } else if ((field->type() == FieldDescriptor::TYPE_STRING ||
+ field->type() == FieldDescriptor::TYPE_BYTES) &&
+ IsStringInlined(field, options)) {
+ GOOGLE_CHECK(!field->is_repeated());
+ // Inlined strings have an extra marker to represent their donation state.
+ int idx = inlined_string_indices[field->index()];
+ // For mini parsing, the donation state index is stored as an `offset`
+ // auxiliary entry.
+ entry.aux_idx = aux_entries.size();
+ aux_entries.push_back(StrCat("_fl::Offset{", idx, "}"));
+ // For fast table parsing, the donation state index is stored instead of
+ // the aux_idx (this will limit the range to 8 bits).
+ entry.inlined_string_idx = idx;
+ }
+ }
+
+ // Choose the smallest fast table that covers the maximum number of fields.
+ table_size_log2 = 0; // fallback value
+ int num_fast_fields = -1;
+ for (int try_size_log2 : {0, 1, 2, 3, 4, 5}) {
+ size_t try_size = 1 << try_size_log2;
+ auto split_fields = SplitFastFieldsForSize(field_entries, try_size_log2,
+ options, scc_analyzer);
+ GOOGLE_CHECK_EQ(split_fields.size(), try_size);
+ int try_num_fast_fields = 0;
+ for (const auto& info : split_fields) {
+ if (info.field != nullptr) ++try_num_fast_fields;
+ }
+ // Use this size if (and only if) it covers more fields.
+ if (try_num_fast_fields > num_fast_fields) {
+ fast_path_fields = std::move(split_fields);
+ table_size_log2 = try_size_log2;
+ num_fast_fields = try_num_fast_fields;
+ }
+ // The largest table we allow has the same number of entries as the message
+ // has fields, rounded up to the next power of 2 (e.g., a message with 5
+ // fields can have a fast table of size 8). A larger table *might* cover
+ // more fields in certain cases, but a larger table in that case would have
+ // mostly empty entries; so, we cap the size to avoid pathologically sparse
+ // tables.
+ if (try_size > ordered_fields.size()) {
+ break;
}
- // This field made it into the fast path, so remove it from the fallback
- // fields and fill in the table entry.
- fallback_fields.pop_back();
- fast_path_fields[idx].func_name = name;
- fast_path_fields[idx].bits = TcFieldData(tag, hasbit_idx, 0);
- fast_path_fields[idx].field = field;
}
+ // Filter out fields that are handled by MiniParse. We don't need to generate
+ // a fallback for these, which saves code size.
+ fallback_fields = FilterMiniParsedFields(ordered_fields, options,
+ scc_analyzer);
+
// If there are no fallback fields, and at most one extension range, the
// parser can use a generic fallback function. Otherwise, a message-specific
// fallback routine is needed.
@@ -252,12 +436,15 @@ ParseFunctionGenerator::ParseFunctionGenerator(
options_(options),
variables_(vars),
inlined_string_indices_(inlined_string_indices),
+ ordered_fields_(GetOrderedFields(descriptor_, options_)),
num_hasbits_(max_has_bit_index) {
if (should_generate_tctable()) {
- tc_table_info_.reset(new TailCallTableInfo(descriptor_, options_,
- has_bit_indices, scc_analyzer));
+ tc_table_info_.reset(new TailCallTableInfo(
+ descriptor_, options_, ordered_fields_, has_bit_indices,
+ inlined_string_indices, scc_analyzer));
}
SetCommonVars(options_, &variables_);
+ SetCommonMessageDataVariables(&variables_);
SetUnknownFieldsVariable(descriptor_, options_, &variables_);
variables_["classname"] = ClassName(descriptor, false);
}
@@ -265,45 +452,18 @@ ParseFunctionGenerator::ParseFunctionGenerator(
void ParseFunctionGenerator::GenerateMethodDecls(io::Printer* printer) {
Formatter format(printer, variables_);
if (should_generate_tctable()) {
- auto declare_function = [&format](const char* name,
- const TProtoStringType& guard) {
- if (!guard.empty()) {
- format.Outdent();
- format("#if $1$\n", guard);
- format.Indent();
- }
- format("static const char* $1$(PROTOBUF_TC_PARAM_DECL);\n", name);
- if (!guard.empty()) {
- format.Outdent();
- format("#endif // $1$\n", guard);
- format.Indent();
- }
- };
+ format.Outdent();
if (should_generate_guarded_tctable()) {
- format.Outdent();
format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n");
- format.Indent();
- }
- format("// The Tct_* functions are internal to the protobuf runtime:\n");
- // These guards are defined in port_def.inc:
- declare_function("Tct_ParseS1", "PROTOBUF_TC_STATIC_PARSE_SINGULAR1");
- declare_function("Tct_ParseS2", "PROTOBUF_TC_STATIC_PARSE_SINGULAR2");
- declare_function("Tct_ParseR1", "PROTOBUF_TC_STATIC_PARSE_REPEATED1");
- declare_function("Tct_ParseR2", "PROTOBUF_TC_STATIC_PARSE_REPEATED2");
- if (tc_table_info_->use_generated_fallback) {
- format.Outdent();
- format(
- " private:\n"
- " ");
- declare_function("Tct_ParseFallback", "");
- format(" public:\n");
- format.Indent();
}
+ format(
+ " private:\n"
+ " static const char* Tct_ParseFallback(PROTOBUF_TC_PARAM_DECL);\n"
+ " public:\n");
if (should_generate_guarded_tctable()) {
- format.Outdent();
format("#endif\n");
- format.Indent();
}
+ format.Indent();
}
format(
"const char* _InternalParse(const char* ptr, "
@@ -318,9 +478,15 @@ void ParseFunctionGenerator::GenerateMethodImpls(io::Printer* printer) {
need_parse_function = false;
format(
"const char* $classname$::_InternalParse(const char* ptr,\n"
- " ::$proto_ns$::internal::ParseContext* ctx) {\n"
- "$annotate_deserialize$"
- " return _extensions_.ParseMessageSet(ptr, \n"
+ " ::_pbi::ParseContext* ctx) {\n"
+ "$annotate_deserialize$");
+ if (!options_.unverified_lazy_message_sets &&
+ ShouldVerify(descriptor_, options_, scc_analyzer_)) {
+ format(
+ " ctx->set_lazy_eager_verify_func(&$classname$::InternalVerify);\n");
+ }
+ format(
+ " return $extensions$.ParseMessageSet(ptr, \n"
" internal_default_instance(), &_internal_metadata_, ctx);\n"
"}\n");
}
@@ -339,7 +505,6 @@ void ParseFunctionGenerator::GenerateMethodImpls(io::Printer* printer) {
if (tc_table_info_->use_generated_fallback) {
GenerateTailcallFallbackFunction(format);
}
- GenerateTailcallFieldParseFunctions(format);
if (should_generate_guarded_tctable()) {
if (need_parse_function) {
format("\n#else // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n\n");
@@ -362,10 +527,10 @@ void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) {
// Generate an `_InternalParse` that starts the tail-calling loop.
format(
"const char* $classname$::_InternalParse(\n"
- " const char* ptr, ::$proto_ns$::internal::ParseContext* ctx) {\n"
+ " const char* ptr, ::_pbi::ParseContext* ctx) {\n"
"$annotate_deserialize$"
- " ptr = ::$proto_ns$::internal::TcParser::ParseLoop(\n"
- " this, ptr, ctx, &_table_.header);\n");
+ " ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, "
+ "&_table_.header);\n");
format(
" return ptr;\n"
"}\n\n");
@@ -384,6 +549,7 @@ void ParseFunctionGenerator::GenerateTailcallFallbackFunction(
// Sync hasbits
format("typed_msg->_has_bits_[0] = hasbits;\n");
}
+ format("arc_ui32 tag = data.tag();\n");
format.Set("msg", "typed_msg->");
format.Set("this", "typed_msg");
@@ -401,62 +567,30 @@ void ParseFunctionGenerator::GenerateTailcallFallbackFunction(
"}\n");
}
-void ParseFunctionGenerator::GenerateTailcallFieldParseFunctions(
- Formatter& format) {
- GOOGLE_CHECK(should_generate_tctable());
- // There are four cases where a tailcall target are needed for messages:
- // {singular, repeated} x {1, 2}-byte tag
- struct {
- const char* type;
- int size;
- } const kTagLayouts[] = {
- {"uint8_t", 1},
- {"uint16_t", 2},
- };
- // Singular:
- for (const auto& layout : kTagLayouts) {
- // Guard macros are defined in port_def.inc.
- format(
- "#if PROTOBUF_TC_STATIC_PARSE_SINGULAR$1$\n"
- "const char* $classname$::Tct_ParseS$1$(PROTOBUF_TC_PARAM_DECL) {\n"
- " if (PROTOBUF_PREDICT_FALSE(data.coded_tag<$2$>() != 0))\n"
- " PROTOBUF_MUSTTAIL "
- "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n"
- " ptr += $1$;\n"
- " hasbits |= (arc_ui64{1} << data.hasbit_idx());\n"
- " ::$proto_ns$::internal::TcParser::SyncHasbits"
- "(msg, hasbits, table);\n"
- " auto& field = ::$proto_ns$::internal::TcParser::"
- "RefAt<$classtype$*>(msg, data.offset());\n"
- " if (field == nullptr)\n"
- " field = CreateMaybeMessage<$classtype$>(ctx->data().arena);\n"
- " return ctx->ParseMessage(field, ptr);\n"
- "}\n"
- "#endif // PROTOBUF_TC_STATIC_PARSE_SINGULAR$1$\n",
- layout.size, layout.type);
- }
- // Repeated:
- for (const auto& layout : kTagLayouts) {
- // Guard macros are defined in port_def.inc.
- format(
- "#if PROTOBUF_TC_STATIC_PARSE_REPEATED$1$\n"
- "const char* $classname$::Tct_ParseR$1$(PROTOBUF_TC_PARAM_DECL) {\n"
- " if (PROTOBUF_PREDICT_FALSE(data.coded_tag<$2$>() != 0)) {\n"
- " PROTOBUF_MUSTTAIL "
- "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n"
- " }\n"
- " ptr += $1$;\n"
- " auto& field = ::$proto_ns$::internal::TcParser::RefAt<"
- "::$proto_ns$::RepeatedPtrField<$classname$>>(msg, data.offset());\n"
- " ::$proto_ns$::internal::TcParser::SyncHasbits"
- "(msg, hasbits, table);\n"
- " ptr = ctx->ParseMessage(field.Add(), ptr);\n"
- " return ptr;\n"
- "}\n"
- "#endif // PROTOBUF_TC_STATIC_PARSE_REPEATED$1$\n",
- layout.size, layout.type);
+struct SkipEntry16 {
+ uint16_t skipmap;
+ uint16_t field_entry_offset;
+};
+struct SkipEntryBlock {
+ arc_ui32 first_fnum;
+ std::vector<SkipEntry16> entries;
+};
+struct NumToEntryTable {
+ arc_ui32 skipmap32; // for fields #1 - #32
+ std::vector<SkipEntryBlock> blocks;
+ // Compute the number of uint16_t required to represent this table.
+ int size16() const {
+ int size = 2; // for the termination field#
+ for (const auto& block : blocks) {
+ // 2 for the field#, 1 for a count of skip entries, 2 for each entry.
+ size += 3 + block.entries.size() * 2;
+ }
+ return size;
}
-}
+};
+
+static NumToEntryTable MakeNumToEntryTable(
+ const std::vector<const FieldDescriptor*>& field_descriptors);
void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) {
if (!should_generate_tctable()) {
@@ -468,10 +602,13 @@ void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) {
format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n");
format.Indent();
}
+ auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format(
- "static const ::$proto_ns$::internal::TcParseTable<$1$>\n"
- " _table_;\n",
- tc_table_info_->table_size_log2);
+ "static const ::$proto_ns$::internal::"
+ "TcParseTable<$1$, $2$, $3$, $4$, $5$> _table_;\n",
+ tc_table_info_->table_size_log2, ordered_fields_.size(),
+ tc_table_info_->aux_entries.size(), CalculateFieldNamesSize(),
+ field_num_to_entry_table.size16());
if (should_generate_guarded_tctable()) {
format.Outdent();
format("#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n");
@@ -496,7 +633,7 @@ void ParseFunctionGenerator::GenerateDataDefinitions(io::Printer* printer) {
void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) {
format(
"const char* $classname$::_InternalParse(const char* ptr, "
- "::$proto_ns$::internal::ParseContext* ctx) {\n"
+ "::_pbi::ParseContext* ctx) {\n"
"$annotate_deserialize$"
"#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure\n");
format.Indent();
@@ -518,8 +655,10 @@ void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) {
format("while (!ctx->Done(&ptr)) {\n");
format.Indent();
- GenerateParseIterationBody(format, descriptor_,
- GetOrderedFields(descriptor_, options_));
+ format(
+ "arc_ui32 tag;\n"
+ "ptr = ::_pbi::ReadTag(ptr, &tag);\n");
+ GenerateParseIterationBody(format, descriptor_, ordered_fields_);
format.Outdent();
format("} // while\n");
@@ -537,6 +676,68 @@ void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) {
"}\n");
}
+static NumToEntryTable MakeNumToEntryTable(
+ const std::vector<const FieldDescriptor*>& field_descriptors) {
+ NumToEntryTable num_to_entry_table;
+ num_to_entry_table.skipmap32 = static_cast<arc_ui32>(-1);
+
+ // skip_entry_block is the current block of SkipEntries that we're
+ // appending to. cur_block_first_fnum is the number of the first
+ // field represented by the block.
+ uint16_t field_entry_index = 0;
+ uint16_t N = field_descriptors.size();
+ // First, handle field numbers 1-32, which affect only the initial
+ // skipmap32 and don't generate additional skip-entry blocks.
+ for (; field_entry_index != N; ++field_entry_index) {
+ auto* field_descriptor = field_descriptors[field_entry_index];
+ if (field_descriptor->number() > 32) break;
+ auto skipmap32_index = field_descriptor->number() - 1;
+ num_to_entry_table.skipmap32 -= 1 << skipmap32_index;
+ }
+ // If all the field numbers were less than or equal to 32, we will have
+ // no further entries to process, and we are already done.
+ if (field_entry_index == N) return num_to_entry_table;
+
+ SkipEntryBlock* block = nullptr;
+ bool start_new_block = true;
+ // To determine sparseness, track the field number corresponding to
+ // the start of the most recent skip entry.
+ arc_ui32 last_skip_entry_start = 0;
+ for (; field_entry_index != N; ++field_entry_index) {
+ auto* field_descriptor = field_descriptors[field_entry_index];
+ arc_ui32 fnum = field_descriptor->number();
+ GOOGLE_CHECK_GT(fnum, last_skip_entry_start);
+ if (start_new_block == false) {
+ // If the next field number is within 15 of the last_skip_entry_start, we
+ // continue writing just to that entry. If it's between 16 and 31 more,
+ // then we just extend the current block by one. If it's more than 31
+ // more, we have to add empty skip entries in order to continue using the
+ // existing block. Obviously it's just 32 more, it doesn't make sense to
+ // start a whole new block, since new blocks mean having to write out
+ // their starting field number, which is 32 bits, as well as the size of
+ // the additional block, which is 16... while an empty SkipEntry16 only
+ // costs 32 bits. So if it was 48 more, it's a slight space win; we save
+ // 16 bits, but probably at the cost of slower run time. We're choosing
+ // 96 for now.
+ if (fnum - last_skip_entry_start > 96) start_new_block = true;
+ }
+ if (start_new_block) {
+ num_to_entry_table.blocks.push_back(SkipEntryBlock{fnum});
+ block = &num_to_entry_table.blocks.back();
+ start_new_block = false;
+ }
+
+ auto skip_entry_num = (fnum - block->first_fnum) / 16;
+ auto skip_entry_index = (fnum - block->first_fnum) % 16;
+ while (skip_entry_num >= block->entries.size())
+ block->entries.push_back({0xFFFF, field_entry_index});
+ block->entries[skip_entry_num].skipmap -= 1 << (skip_entry_index);
+
+ last_skip_entry_start = fnum - skip_entry_index;
+ }
+ return num_to_entry_table;
+}
+
void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
GOOGLE_CHECK(should_generate_tctable());
// All entries without a fast-path parsing function need a fallback.
@@ -544,7 +745,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
if (tc_table_info_->use_generated_fallback) {
fallback = ClassName(descriptor_) + "::Tct_ParseFallback";
} else {
- fallback = TcParserName(options_) + "GenericFallback";
+ fallback = "::_pbi::TcParser::GenericFallback";
if (GetOptimizeFor(descriptor_->file(), options_) ==
FileOptions::LITE_RUNTIME) {
fallback += "Lite";
@@ -558,10 +759,15 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
// maps, weak fields, lazy, more than 1 extension range. In the cases
// the table is sufficient we can use a generic routine, that just handles
// unknown fields and potentially an extension range.
+ auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format(
- "const ::$proto_ns$::internal::TcParseTable<$1$>\n"
- " $classname$::_table_ = {\n",
- tc_table_info_->table_size_log2);
+ "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1\n"
+ "const ::_pbi::TcParseTable<$1$, $2$, $3$, $4$, $5$> "
+ "$classname$::_table_ = "
+ "{\n",
+ tc_table_info_->table_size_log2, ordered_fields_.size(),
+ tc_table_info_->aux_entries.size(), CalculateFieldNamesSize(),
+ field_num_to_entry_table.size16());
{
auto table_scope = format.ScopedIndent();
format("{\n");
@@ -574,86 +780,364 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
}
if (descriptor_->extension_range_count() == 1) {
format(
- "PROTOBUF_FIELD_OFFSET($classname$, _extensions_),\n"
+ "PROTOBUF_FIELD_OFFSET($classname$, $extensions$),\n"
"$1$, $2$, // extension_range_{low,high}\n",
descriptor_->extension_range(0)->start,
descriptor_->extension_range(0)->end);
} else {
format("0, 0, 0, // no _extensions_\n");
}
+ format("$1$, $2$, // max_field_number, fast_idx_mask\n",
+ (ordered_fields_.empty() ? 0 : ordered_fields_.back()->number()),
+ (((1 << tc_table_info_->table_size_log2) - 1) << 3));
+ format(
+ "offsetof(decltype(_table_), field_lookup_table),\n"
+ "$1$, // skipmap\n",
+ field_num_to_entry_table.skipmap32);
+ if (ordered_fields_.empty()) {
+ format(
+ "offsetof(decltype(_table_), field_names), // no field_entries\n");
+ } else {
+ format("offsetof(decltype(_table_), field_entries),\n");
+ }
+
+ format(
+ "$1$, // num_field_entries\n"
+ "$2$, // num_aux_entries\n",
+ ordered_fields_.size(), tc_table_info_->aux_entries.size());
+ if (tc_table_info_->aux_entries.empty()) {
+ format(
+ "offsetof(decltype(_table_), field_names), // no aux_entries\n");
+ } else {
+ format("offsetof(decltype(_table_), aux_entries),\n");
+ }
format(
- "$1$, 0, $2$, // fast_idx_mask, reserved, num_fields\n"
- "&$3$._instance,\n"
- "$4$ // fallback\n",
- (((1 << tc_table_info_->table_size_log2) - 1) << 3),
- descriptor_->field_count(),
+ "&$1$._instance,\n"
+ "$2$, // fallback\n"
+ "",
DefaultInstanceName(descriptor_, options_), fallback);
}
- format("}, {\n");
+ format("}, {{\n");
{
+ // fast_entries[]
auto fast_scope = format.ScopedIndent();
- GenerateFastFieldEntries(format, fallback);
+ GenerateFastFieldEntries(format);
+ }
+ format("}}, {{\n");
+ {
+ // field_lookup_table[]
+ auto field_lookup_scope = format.ScopedIndent();
+ int line_entries = 0;
+ for (int i = 0, N = field_num_to_entry_table.blocks.size(); i < N; ++i) {
+ SkipEntryBlock& entry_block = field_num_to_entry_table.blocks[i];
+ format("$1$, $2$, $3$,\n", entry_block.first_fnum & 65535,
+ entry_block.first_fnum / 65536, entry_block.entries.size());
+ for (auto se16 : entry_block.entries) {
+ if (line_entries == 0) {
+ format("$1$, $2$,", se16.skipmap, se16.field_entry_offset);
+ ++line_entries;
+ } else if (line_entries < 5) {
+ format(" $1$, $2$,", se16.skipmap, se16.field_entry_offset);
+ ++line_entries;
+ } else {
+ format(" $1$, $2$,\n", se16.skipmap, se16.field_entry_offset);
+ line_entries = 0;
+ }
+ }
+ }
+ if (line_entries) format("\n");
+ format("65535, 65535\n");
+ }
+ if (ordered_fields_.empty()) {
+ GOOGLE_LOG_IF(DFATAL, !tc_table_info_->aux_entries.empty())
+ << "Invalid message: " << descriptor_->full_name() << " has "
+ << tc_table_info_->aux_entries.size()
+ << " auxiliary field entries, but no fields";
+ format(
+ "}},\n"
+ "// no field_entries, or aux_entries\n"
+ "{{\n");
+ } else {
+ format("}}, {{\n");
+ {
+ // field_entries[]
+ auto field_scope = format.ScopedIndent();
+ GenerateFieldEntries(format);
+ }
+ if (tc_table_info_->aux_entries.empty()) {
+ format(
+ "}},\n"
+ "// no aux_entries\n"
+ "{{\n");
+ } else {
+ format("}}, {{\n");
+ {
+ // aux_entries[]
+ auto aux_scope = format.ScopedIndent();
+ for (const TProtoStringType& aux_entry : tc_table_info_->aux_entries) {
+ format("{$1$},\n", aux_entry);
+ }
+ }
+ format("}}, {{\n");
+ }
+ } // ordered_fields_.empty()
+ {
+ // field_names[]
+ auto field_name_scope = format.ScopedIndent();
+ GenerateFieldNames(format);
}
- format("},\n"); // entries[]
+ format("}},\n");
}
format("};\n\n"); // _table_
}
-void ParseFunctionGenerator::GenerateFastFieldEntries(
- Formatter& format, const TProtoStringType& fallback) {
+void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) {
for (const auto& info : tc_table_info_->fast_path_fields) {
if (info.field != nullptr) {
PrintFieldComment(format, info.field);
}
- format("{$1$, ", info.func_name.empty() ? fallback : info.func_name);
- if (info.bits.data) {
- GOOGLE_DCHECK_NE(nullptr, info.field);
+ if (info.func_name.empty()) {
+ format("{::_pbi::TcParser::MiniParse, {}},\n");
+ } else {
format(
- "{$1$, $2$, "
- "static_cast<uint16_t>(PROTOBUF_FIELD_OFFSET($classname$, $3$_))}",
- info.bits.coded_tag(), info.bits.hasbit_idx(), FieldName(info.field));
+ "{$1$,\n"
+ " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$, $5$)}},\n",
+ info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx,
+ FieldMemberName(info.field));
+ }
+ }
+}
+
+static void FormatFieldKind(Formatter& format,
+ const TailCallTableInfo::FieldEntryInfo& entry,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ const FieldDescriptor* field = entry.field;
+ // Spell the field kind in proto language declaration order, starting with
+ // cardinality:
+ format("(::_fl::kFc");
+ if (HasHasbit(field)) {
+ format("Optional");
+ } else if (field->is_repeated()) {
+ format("Repeated");
+ } else if (field->real_containing_oneof()) {
+ format("Oneof");
+ } else {
+ format("Singular");
+ }
+
+ // The rest of the type uses convenience aliases:
+ format(" | ::_fl::k");
+ if (field->is_repeated() && field->is_packed()) {
+ format("Packed");
+ }
+ switch (field->type()) {
+ case FieldDescriptor::TYPE_DOUBLE:
+ format("Double");
+ break;
+ case FieldDescriptor::TYPE_FLOAT:
+ format("Float");
+ break;
+ case FieldDescriptor::TYPE_FIXED32:
+ format("Fixed32");
+ break;
+ case FieldDescriptor::TYPE_SFIXED32:
+ format("SFixed32");
+ break;
+ case FieldDescriptor::TYPE_FIXED64:
+ format("Fixed64");
+ break;
+ case FieldDescriptor::TYPE_SFIXED64:
+ format("SFixed64");
+ break;
+ case FieldDescriptor::TYPE_BOOL:
+ format("Bool");
+ break;
+ case FieldDescriptor::TYPE_ENUM:
+ if (HasPreservingUnknownEnumSemantics(field)) {
+ // No validation is required.
+ format("OpenEnum");
+ } else if (entry.is_enum_range) {
+ // Validation is done by range check (start/length in FieldAux).
+ format("EnumRange");
+ } else {
+ // Validation uses the generated _IsValid function.
+ format("Enum");
+ }
+ break;
+ case FieldDescriptor::TYPE_UINT32:
+ format("UInt32");
+ break;
+ case FieldDescriptor::TYPE_SINT32:
+ format("SInt32");
+ break;
+ case FieldDescriptor::TYPE_INT32:
+ format("Int32");
+ break;
+ case FieldDescriptor::TYPE_UINT64:
+ format("UInt64");
+ break;
+ case FieldDescriptor::TYPE_SINT64:
+ format("SInt64");
+ break;
+ case FieldDescriptor::TYPE_INT64:
+ format("Int64");
+ break;
+
+ case FieldDescriptor::TYPE_BYTES:
+ format("Bytes");
+ break;
+ case FieldDescriptor::TYPE_STRING: {
+ auto mode = GetUtf8CheckMode(field, options);
+ switch (mode) {
+ case Utf8CheckMode::kStrict:
+ format("Utf8String");
+ break;
+ case Utf8CheckMode::kVerify:
+ format("RawString");
+ break;
+ case Utf8CheckMode::kNone:
+ // Treat LITE_RUNTIME strings as bytes.
+ format("Bytes");
+ break;
+ default:
+ GOOGLE_LOG(FATAL) << "Invalid Utf8CheckMode (" << static_cast<int>(mode)
+ << ") for " << field->DebugString();
+ }
+ break;
+ }
+
+ case FieldDescriptor::TYPE_GROUP:
+ format("Message | ::_fl::kRepGroup");
+ break;
+ case FieldDescriptor::TYPE_MESSAGE:
+ if (field->is_map()) {
+ format("Map");
+ } else {
+ format("Message");
+ if (IsLazy(field, options, scc_analyzer)) {
+ format(" | ::_fl::kRepLazy");
+ } else if (IsImplicitWeakField(field, options, scc_analyzer)) {
+ format(" | ::_fl::kRepIWeak");
+ }
+ }
+ break;
+ }
+
+ // Fill in extra information about string and bytes field representations.
+ if (field->type() == FieldDescriptor::TYPE_BYTES ||
+ field->type() == FieldDescriptor::TYPE_STRING) {
+ if (field->is_repeated()) {
+ format(" | ::_fl::kRepSString");
+ } else {
+ format(" | ::_fl::kRepAString");
+ }
+ }
+
+ format(")");
+}
+
+void ParseFunctionGenerator::GenerateFieldEntries(Formatter& format) {
+ for (const auto& entry : tc_table_info_->field_entries) {
+ const FieldDescriptor* field = entry.field;
+ PrintFieldComment(format, field);
+ format("{");
+ if (IsWeak(field, options_)) {
+ // Weak fields are handled by the generated fallback function.
+ // (These are handled by legacy Google-internal logic.)
+ format("/* weak */ 0, 0, 0, 0");
} else {
- format("{}");
+ const OneofDescriptor* oneof = field->real_containing_oneof();
+ format("PROTOBUF_FIELD_OFFSET($classname$, $1$), $2$, $3$,\n ",
+ FieldMemberName(field),
+ (oneof ? oneof->index() : entry.hasbit_idx), entry.aux_idx);
+ FormatFieldKind(format, entry, options_, scc_analyzer_);
}
format("},\n");
}
}
+static constexpr int kMaxNameLength = 255;
+
+int ParseFunctionGenerator::CalculateFieldNamesSize() const {
+ // The full name of the message appears first.
+ int size = std::min(static_cast<int>(descriptor_->full_name().size()),
+ kMaxNameLength);
+ int lengths_size = 1;
+ for (const auto& entry : tc_table_info_->field_entries) {
+ const FieldDescriptor* field = entry.field;
+ GOOGLE_CHECK_LE(field->name().size(), kMaxNameLength);
+ size += field->name().size();
+ lengths_size += 1;
+ }
+ // align to an 8-byte boundary
+ lengths_size = (lengths_size + 7) & -8;
+ return size + lengths_size + 1;
+}
+
+static void FormatOctal(Formatter& format, int size) {
+ int octal_size = ((size >> 6) & 3) * 100 + //
+ ((size >> 3) & 7) * 10 + //
+ ((size >> 0) & 7);
+ format("\\$1$", octal_size);
+}
+
+void ParseFunctionGenerator::GenerateFieldNames(Formatter& format) {
+ // First, we output the size of each string, as an unsigned byte. The first
+ // string is the message name.
+ int count = 1;
+ format("\"");
+ FormatOctal(format,
+ std::min(static_cast<int>(descriptor_->full_name().size()), 255));
+ for (const auto& entry : tc_table_info_->field_entries) {
+ FormatOctal(format, entry.field->name().size());
+ ++count;
+ }
+ while (count & 7) { // align to an 8-byte boundary
+ format("\\0");
+ ++count;
+ }
+ format("\"\n");
+ // The message name is stored at the beginning of the string
+ TProtoStringType message_name = descriptor_->full_name();
+ if (message_name.size() > kMaxNameLength) {
+ static constexpr int kNameHalfLength = (kMaxNameLength - 3) / 2;
+ message_name = StrCat(
+ message_name.substr(0, kNameHalfLength), "...",
+ message_name.substr(message_name.size() - kNameHalfLength));
+ }
+ format("\"$1$\"\n", message_name);
+ // Then we output the actual field names
+ for (const auto& entry : tc_table_info_->field_entries) {
+ const FieldDescriptor* field = entry.field;
+ format("\"$1$\"\n", field->name());
+ }
+}
+
void ParseFunctionGenerator::GenerateArenaString(Formatter& format,
const FieldDescriptor* field) {
if (HasHasbit(field)) {
format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field));
}
- TProtoStringType default_string =
- field->default_value_string().empty()
- ? "::" + ProtobufNamespace(options_) +
- "::internal::GetEmptyStringAlreadyInited()"
- : QualifiedClassName(field->containing_type(), options_) +
- "::" + MakeDefaultName(field) + ".get()";
format(
"if (arena != nullptr) {\n"
- " ptr = ctx->ReadArenaString(ptr, &$msg$$name$_, arena");
+ " ptr = ctx->ReadArenaString(ptr, &$msg$$field$, arena");
if (IsStringInlined(field, options_)) {
GOOGLE_DCHECK(!inlined_string_indices_.empty());
int inlined_string_index = inlined_string_indices_[field->index()];
- GOOGLE_DCHECK_GE(inlined_string_index, 0);
- format(
- ", $msg$_internal_$name$_donated()"
- ", &$msg$_inlined_string_donated_[$1$]"
- ", ~0x$2$u",
- inlined_string_index / 32,
- strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8));
+ GOOGLE_DCHECK_GT(inlined_string_index, 0);
+ format(", &$msg$$inlined_string_donated_array$[0], $1$, $this$",
+ inlined_string_index);
} else {
GOOGLE_DCHECK(field->default_value_string().empty());
}
format(
");\n"
"} else {\n"
- " ptr = ::$proto_ns$::internal::InlineGreedyStringParser("
- "$msg$$name$_.MutableNoArenaNoDefault(&$1$), ptr, ctx);\n"
+ " ptr = ::_pbi::InlineGreedyStringParser("
+ "$msg$$field$.MutableNoCopy(nullptr), ptr, ctx);\n"
"}\n"
- "const TProtoStringType* str = &$msg$$name$_.Get(); (void)str;\n",
- default_string);
+ "const TProtoStringType* str = &$msg$$field$.Get(); (void)str;\n");
}
void ParseFunctionGenerator::GenerateStrings(Formatter& format,
@@ -685,11 +1169,14 @@ void ParseFunctionGenerator::GenerateStrings(Formatter& format,
}
format(
"auto str = $msg$$1$$2$_$name$();\n"
- "ptr = ::$proto_ns$::internal::Inline$3$(str, ptr, ctx);\n",
+ "ptr = ::_pbi::Inline$3$(str, ptr, ctx);\n",
HasInternalAccessors(ctype) ? "_internal_" : "",
field->is_repeated() && !field->is_packable() ? "add" : "mutable",
parser_name);
}
+ // It is intentionally placed before VerifyUTF8 because it doesn't make sense
+ // to verify UTF8 when we already know parsing failed.
+ format("CHK_(ptr);\n");
if (!check_utf8) return; // return if this is a bytes field
auto level = GetUtf8CheckMode(field, options_);
switch (level) {
@@ -707,7 +1194,7 @@ void ParseFunctionGenerator::GenerateStrings(Formatter& format,
if (HasDescriptorMethods(field->file(), options_)) {
field_name = StrCat("\"", field->full_name(), "\"");
}
- format("::$proto_ns$::internal::VerifyUTF8(str, $1$)", field_name);
+ format("::_pbi::VerifyUTF8(str, $1$)", field_name);
switch (level) {
case Utf8CheckMode::kNone:
return;
@@ -740,6 +1227,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
"$msg$_internal_mutable_$name$(), ptr, ctx);\n",
DeclaredTypeMethodName(field->type()));
}
+ format("CHK_(ptr);\n");
} else {
auto field_type = field->type();
switch (field_type) {
@@ -751,48 +1239,64 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
break;
case FieldDescriptor::TYPE_MESSAGE: {
if (field->is_map()) {
- const FieldDescriptor* val =
- field->message_type()->FindFieldByName("value");
+ const FieldDescriptor* val = field->message_type()->map_value();
GOOGLE_CHECK(val);
if (val->type() == FieldDescriptor::TYPE_ENUM &&
!HasPreservingUnknownEnumSemantics(field)) {
format(
"auto object = "
"::$proto_ns$::internal::InitEnumParseWrapper<"
- "$unknown_fields_type$>(&$msg$$name$_, $1$_IsValid, "
+ "$unknown_fields_type$>(&$msg$$field$, $1$_IsValid, "
"$2$, &$msg$_internal_metadata_);\n"
"ptr = ctx->ParseMessage(&object, ptr);\n",
QualifiedClassName(val->enum_type(), options_),
field->number());
} else {
- format("ptr = ctx->ParseMessage(&$msg$$name$_, ptr);\n");
+ format("ptr = ctx->ParseMessage(&$msg$$field$, ptr);\n");
}
} else if (IsLazy(field, options_, scc_analyzer_)) {
+ bool eager_verify =
+ IsEagerlyVerifiedLazy(field, options_, scc_analyzer_);
+ if (ShouldVerify(descriptor_, options_, scc_analyzer_)) {
+ format(
+ "ctx->set_lazy_eager_verify_func($1$);\n",
+ eager_verify
+ ? StrCat("&", ClassName(field->message_type(), true),
+ "::InternalVerify")
+ : "nullptr");
+ }
if (field->real_containing_oneof()) {
format(
"if (!$msg$_internal_has_$name$()) {\n"
" $msg$clear_$1$();\n"
- " $msg$$1$_.$name$_ = ::$proto_ns$::Arena::CreateMessage<\n"
+ " $msg$$field$ = ::$proto_ns$::Arena::CreateMessage<\n"
" ::$proto_ns$::internal::LazyField>("
"$msg$GetArenaForAllocation());\n"
" $msg$set_has_$name$();\n"
"}\n"
- "auto* lazy_field = $msg$$1$_.$name$_;\n",
+ "auto* lazy_field = $msg$$field$;\n",
field->containing_oneof()->name());
} else if (HasHasbit(field)) {
format(
"_Internal::set_has_$name$(&$has_bits$);\n"
- "auto* lazy_field = &$msg$$name$_;\n");
+ "auto* lazy_field = &$msg$$field$;\n");
} else {
- format("auto* lazy_field = &$msg$$name$_;\n");
+ format("auto* lazy_field = &$msg$$field$;\n");
}
format(
"::$proto_ns$::internal::LazyFieldParseHelper<\n"
" ::$proto_ns$::internal::LazyField> parse_helper(\n"
" $1$::default_instance(),\n"
- " $msg$GetArenaForAllocation(), lazy_field);\n"
+ " $msg$GetArenaForAllocation(),\n"
+ " ::google::protobuf::internal::LazyVerifyOption::$2$,\n"
+ " lazy_field);\n"
"ptr = ctx->ParseMessage(&parse_helper, ptr);\n",
- FieldMessageTypeName(field, options_));
+ FieldMessageTypeName(field, options_),
+ eager_verify ? "kEager" : "kLazy");
+ if (ShouldVerify(descriptor_, options_, scc_analyzer_) &&
+ eager_verify) {
+ format("ctx->set_lazy_eager_verify_func(nullptr);\n");
+ }
} else if (IsImplicitWeakField(field, options_, scc_analyzer_)) {
if (!field->is_repeated()) {
format(
@@ -800,7 +1304,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
"ptr);\n");
} else {
format(
- "ptr = ctx->ParseMessage($msg$$name$_.AddWeak("
+ "ptr = ctx->ParseMessage($msg$$field$.AddWeak("
"reinterpret_cast<const ::$proto_ns$::MessageLite*>($1$ptr_)"
"), ptr);\n",
QualifiedDefaultInstanceName(field->message_type(), options_));
@@ -809,7 +1313,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
format(
"{\n"
" auto* default_ = &reinterpret_cast<const Message&>($1$);\n"
- " ptr = ctx->ParseMessage($msg$_weak_field_map_.MutableMessage("
+ " ptr = ctx->ParseMessage($msg$$weak_field_map$.MutableMessage("
"$2$, default_), ptr);\n"
"}\n",
QualifiedDefaultInstanceName(field->message_type(), options_),
@@ -819,6 +1323,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
"ptr = ctx->ParseMessage($msg$_internal_$mutable_field$(), "
"ptr);\n");
}
+ format("CHK_(ptr);\n");
break;
}
default:
@@ -898,7 +1403,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
format("_Internal::set_has_$name$(&$has_bits$);\n");
}
format(
- "$msg$$name$_ = ::$proto_ns$::internal::ReadVarint$1$$2$(&ptr);\n"
+ "$msg$$field$ = ::$proto_ns$::internal::ReadVarint$1$$2$(&ptr);\n"
"CHK_(ptr);\n",
zigzag, size);
}
@@ -917,7 +1422,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
format("_Internal::set_has_$name$(&$has_bits$);\n");
}
format(
- "$msg$$name$_ = "
+ "$msg$$field$ = "
"::$proto_ns$::internal::UnalignedLoad<$primitive_type$>(ptr);\n"
"ptr += sizeof($primitive_type$);\n");
}
@@ -925,7 +1430,6 @@ void ParseFunctionGenerator::GenerateFieldBody(
}
case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {
GenerateLengthDelim(format, field);
- format("CHK_(ptr);\n");
break;
}
case WireFormatLite::WIRETYPE_START_GROUP: {
@@ -983,13 +1487,9 @@ static arc_ui32 ExpectedTag(const FieldDescriptor* field,
// parse the next tag in the stream.
void ParseFunctionGenerator::GenerateParseIterationBody(
Formatter& format, const Descriptor* descriptor,
- const std::vector<const FieldDescriptor*>& ordered_fields) {
- format(
- "$uint32$ tag;\n"
- "ptr = ::$proto_ns$::internal::ReadTag(ptr, &tag);\n");
-
- if (!ordered_fields.empty()) {
- GenerateFieldSwitch(format, ordered_fields);
+ const std::vector<const FieldDescriptor*>& fields) {
+ if (!fields.empty()) {
+ GenerateFieldSwitch(format, fields);
// Each field `case` only considers field number. Field numbers that are
// not defined in the message, or tags with an incompatible wire type, are
// considered "unusual" cases. They will be handled by the logic below.
@@ -1028,7 +1528,7 @@ void ParseFunctionGenerator::GenerateParseIterationBody(
}
format(
") {\n"
- " ptr = $msg$_extensions_.ParseField(tag, ptr, "
+ " ptr = $msg$$extensions$.ParseField(tag, ptr, "
"internal_default_instance(), &$msg$_internal_metadata_, ctx);\n"
" CHK_(ptr != nullptr);\n"
" $next_tag$;\n"
@@ -1045,12 +1545,12 @@ void ParseFunctionGenerator::GenerateParseIterationBody(
}
void ParseFunctionGenerator::GenerateFieldSwitch(
- Formatter& format,
- const std::vector<const FieldDescriptor*>& ordered_fields) {
+ Formatter& format, const std::vector<const FieldDescriptor*>& fields) {
format("switch (tag >> 3) {\n");
format.Indent();
- for (const auto* field : ordered_fields) {
+ for (const auto* field : fields) {
+ format.Set("field", FieldMemberName(field));
PrintFieldComment(format, field);
format("case $1$:\n", field->number());
format.Indent();
@@ -1104,199 +1604,111 @@ void ParseFunctionGenerator::GenerateFieldSwitch(
namespace {
-TProtoStringType FieldParseFunctionName(const FieldDescriptor* field,
- const Options& options) {
- ParseCardinality card = //
- field->is_packed() ? ParseCardinality::kPacked
- : field->is_repeated() ? ParseCardinality::kRepeated
- : field->real_containing_oneof() ? ParseCardinality::kOneof
- : ParseCardinality::kSingular;
+TProtoStringType FieldParseFunctionName(
+ const TailCallTableInfo::FieldEntryInfo& entry, const Options& options) {
+ const FieldDescriptor* field = entry.field;
+ TProtoStringType name = "::_pbi::TcParser::Fast";
- TypeFormat type_format;
switch (field->type()) {
- case FieldDescriptor::TYPE_FIXED64:
- case FieldDescriptor::TYPE_SFIXED64:
- case FieldDescriptor::TYPE_DOUBLE:
- type_format = TypeFormat::kFixed64;
- break;
-
case FieldDescriptor::TYPE_FIXED32:
case FieldDescriptor::TYPE_SFIXED32:
case FieldDescriptor::TYPE_FLOAT:
- type_format = TypeFormat::kFixed32;
+ name.append("F32");
break;
- case FieldDescriptor::TYPE_INT64:
- case FieldDescriptor::TYPE_UINT64:
- type_format = TypeFormat::kVar64;
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_DOUBLE:
+ name.append("F64");
break;
+ case FieldDescriptor::TYPE_BOOL:
+ name.append("V8");
+ break;
case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_UINT32:
- type_format = TypeFormat::kVar32;
+ name.append("V32");
+ break;
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_UINT64:
+ name.append("V64");
break;
- case FieldDescriptor::TYPE_SINT64:
- type_format = TypeFormat::kSInt64;
+ case FieldDescriptor::TYPE_ENUM:
+ if (HasPreservingUnknownEnumSemantics(field)) {
+ name.append("V32");
+ break;
+ }
+ if (field->is_repeated() && field->is_packed()) {
+ GOOGLE_LOG(DFATAL) << "Enum validation not handled: " << field->DebugString();
+ return "";
+ }
+ name.append(entry.is_enum_range ? "Er" : "Ev");
break;
case FieldDescriptor::TYPE_SINT32:
- type_format = TypeFormat::kSInt32;
+ name.append("Z32");
break;
-
- case FieldDescriptor::TYPE_BOOL:
- type_format = TypeFormat::kBool;
+ case FieldDescriptor::TYPE_SINT64:
+ name.append("Z64");
break;
case FieldDescriptor::TYPE_BYTES:
- type_format = TypeFormat::kBytes;
+ name.append("B");
+ if (IsStringInlined(field, options)) {
+ name.append("i");
+ }
break;
-
case FieldDescriptor::TYPE_STRING:
switch (GetUtf8CheckMode(field, options)) {
case Utf8CheckMode::kNone:
- type_format = TypeFormat::kBytes;
- break;
- case Utf8CheckMode::kStrict:
- type_format = TypeFormat::kString;
+ name.append("B");
break;
case Utf8CheckMode::kVerify:
- type_format = TypeFormat::kStringValidateOnly;
+ name.append("S");
+ break;
+ case Utf8CheckMode::kStrict:
+ name.append("U");
break;
default:
GOOGLE_LOG(DFATAL) << "Mode not handled: "
<< static_cast<int>(GetUtf8CheckMode(field, options));
return "";
}
+ if (IsStringInlined(field, options)) {
+ name.append("i");
+ }
break;
- default:
- GOOGLE_LOG(DFATAL) << "Type not handled: " << field->DebugString();
- return "";
- }
-
- return "::" + ProtobufNamespace(options) + "::internal::TcParser::" +
- GetTailCallFieldHandlerName(card, type_format,
- TagSize(field->number()), options);
-}
-
-} // namespace
-
-TProtoStringType GetTailCallFieldHandlerName(ParseCardinality card,
- TypeFormat type_format,
- int tag_length_bytes,
- const Options& options) {
- TProtoStringType name;
-
- // The field implementation functions are prefixed by cardinality:
- // `Singular` for optional or implicit fields.
- // `Repeated` for non-packed repeated.
- // `Packed` for packed repeated.
- switch (card) {
- case ParseCardinality::kSingular:
- name.append("Singular");
- break;
- case ParseCardinality::kOneof:
- name.append("Oneof");
- break;
- case ParseCardinality::kRepeated:
- name.append("Repeated");
- break;
- case ParseCardinality::kPacked:
- name.append("Packed");
- break;
- }
-
- // Next in the function name is the TypeFormat-specific name.
- switch (type_format) {
- case TypeFormat::kFixed64:
- case TypeFormat::kFixed32:
- name.append("Fixed");
- break;
-
- case TypeFormat::kVar64:
- case TypeFormat::kVar32:
- case TypeFormat::kSInt64:
- case TypeFormat::kSInt32:
- case TypeFormat::kBool:
- name.append("Varint");
- break;
-
- case TypeFormat::kBytes:
- case TypeFormat::kString:
- case TypeFormat::kStringValidateOnly:
- name.append("String");
- break;
-
- default:
- break;
- }
-
- name.append("<");
-
- // Determine the numeric layout type for the parser to use, independent of
- // the specific parsing logic used.
- switch (type_format) {
- case TypeFormat::kVar64:
- case TypeFormat::kFixed64:
- name.append("arc_ui64, ");
- break;
-
- case TypeFormat::kSInt64:
- name.append("arc_i64, ");
- break;
-
- case TypeFormat::kVar32:
- case TypeFormat::kFixed32:
- name.append("arc_ui32, ");
- break;
-
- case TypeFormat::kSInt32:
- name.append("arc_i32, ");
+ case FieldDescriptor::TYPE_MESSAGE:
+ name.append("M");
break;
-
- case TypeFormat::kBool:
- name.append("bool, ");
+ case FieldDescriptor::TYPE_GROUP:
+ name.append("G");
break;
default:
- break;
+ GOOGLE_LOG(DFATAL) << "Type not handled: " << field->DebugString();
+ return "";
}
- name.append(CodedTagType(tag_length_bytes));
-
- switch (type_format) {
- case TypeFormat::kVar64:
- case TypeFormat::kVar32:
- case TypeFormat::kBool:
- StrAppend(&name, ", ", TcParserName(options), "kNoConversion");
- break;
-
- case TypeFormat::kSInt64:
- case TypeFormat::kSInt32:
- StrAppend(&name, ", ", TcParserName(options), "kZigZag");
- break;
-
- case TypeFormat::kBytes:
- StrAppend(&name, ", ", TcParserName(options), "kNoUtf8");
- break;
-
- case TypeFormat::kString:
- StrAppend(&name, ", ", TcParserName(options), "kUtf8");
- break;
-
- case TypeFormat::kStringValidateOnly:
- StrAppend(&name, ", ", TcParserName(options), "kUtf8ValidateOnly");
- break;
+ // The field implementation functions are prefixed by cardinality:
+ // `S` for optional or implicit fields.
+ // `R` for non-packed repeated.
+ // `P` for packed repeated.
+ name.append(field->is_packed() ? "P"
+ : field->is_repeated() ? "R"
+ : field->real_containing_oneof() ? "O"
+ : "S");
- default:
- break;
- }
+ // Append the tag length. Fast parsing only handles 1- or 2-byte tags.
+ name.append(TagSize(field->number()) == 1 ? "1" : "2");
- name.append(">");
return name;
}
+} // namespace
+
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h
index 0246079146..3c8209534a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h
@@ -35,12 +35,11 @@
#include <string>
#include <vector>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_tctable_decl.h>
#include <google/protobuf/wire_format_lite.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
namespace protobuf {
@@ -50,18 +49,36 @@ namespace cpp {
// Helper class for generating tailcall parsing functions.
struct TailCallTableInfo {
TailCallTableInfo(const Descriptor* descriptor, const Options& options,
+ const std::vector<const FieldDescriptor*>& ordered_fields,
const std::vector<int>& has_bit_indices,
+ const std::vector<int>& inlined_string_indices,
MessageSCCAnalyzer* scc_analyzer);
- // Information to generate field entries.
- struct FieldInfo {
- const FieldDescriptor* field;
- google::protobuf::internal::TcFieldData bits;
+
+ // Fields parsed by the table fast-path.
+ struct FastFieldInfo {
TProtoStringType func_name;
+ const FieldDescriptor* field;
+ uint16_t coded_tag;
+ uint8_t hasbit_idx;
+ uint8_t aux_idx;
};
- // Fields parsed by the table fast-path.
- std::vector<FieldInfo> fast_path_fields;
- // Fields parsed by slow-path fallback.
+ std::vector<FastFieldInfo> fast_path_fields;
+
+ // Fields parsed by mini parsing routines.
+ struct FieldEntryInfo {
+ const FieldDescriptor* field;
+ int hasbit_idx;
+ int inlined_string_idx;
+ uint16_t aux_idx;
+ // True for enums entirely covered by the start/length fields of FieldAux:
+ bool is_enum_range;
+ };
+ std::vector<FieldEntryInfo> field_entries;
+ std::vector<TProtoStringType> aux_entries;
+
+ // Fields parsed by generated fallback function.
std::vector<const FieldDescriptor*> fallback_fields;
+
// Table size.
int table_size_log2;
// Mask for has-bits of required fields.
@@ -110,15 +127,15 @@ class ParseFunctionGenerator {
// Generates a fallback function for tailcall table-based parsing.
void GenerateTailcallFallbackFunction(Formatter& format);
- // Generates functions for parsing this message as a field.
- void GenerateTailcallFieldParseFunctions(Formatter& format);
-
// Generates a looping `_InternalParse` function.
void GenerateLoopingParseFunction(Formatter& format);
// Generates the tail-call table definition.
void GenerateTailCallTable(Formatter& format);
- void GenerateFastFieldEntries(Formatter& format, const TProtoStringType& fallback);
+ void GenerateFastFieldEntries(Formatter& format);
+ void GenerateFieldEntries(Formatter& format);
+ int CalculateFieldNamesSize() const;
+ void GenerateFieldNames(Formatter& format);
// Generates parsing code for an `ArenaString` field.
void GenerateArenaString(Formatter& format, const FieldDescriptor* field);
@@ -139,12 +156,11 @@ class ParseFunctionGenerator {
// Generates code to parse the next field from the input stream.
void GenerateParseIterationBody(
Formatter& format, const Descriptor* descriptor,
- const std::vector<const FieldDescriptor*>& ordered_fields);
+ const std::vector<const FieldDescriptor*>& fields);
- // Generates a `switch` statement to parse each of `ordered_fields`.
- void GenerateFieldSwitch(
- Formatter& format,
- const std::vector<const FieldDescriptor*>& ordered_fields);
+ // Generates a `switch` statement to parse each of `fields`.
+ void GenerateFieldSwitch(Formatter& format,
+ const std::vector<const FieldDescriptor*>& fields);
const Descriptor* descriptor_;
MessageSCCAnalyzer* scc_analyzer_;
@@ -152,45 +168,10 @@ class ParseFunctionGenerator {
std::map<TProtoStringType, TProtoStringType> variables_;
std::unique_ptr<TailCallTableInfo> tc_table_info_;
std::vector<int> inlined_string_indices_;
+ const std::vector<const FieldDescriptor*> ordered_fields_;
int num_hasbits_;
};
-enum class ParseCardinality {
- kSingular,
- kOneof,
- kRepeated,
- kPacked,
-};
-
-// TypeFormat defines parsing types, which encapsulates the expected wire
-// format, conversion or validation, and the in-memory layout.
-enum class TypeFormat {
- // Fixed types:
- kFixed64, // fixed64, sfixed64, double
- kFixed32, // fixed32, sfixed32, float
-
- // Varint types:
- kVar64, // int64, uint64
- kVar32, // int32, uint32
- kSInt64, // sint64
- kSInt32, // sint32
- kBool, // bool
-
- // Length-delimited types:
- kBytes, // bytes
- kString, // string (proto3/UTF-8 strict)
- kStringValidateOnly, // string (proto2/UTF-8 validate only)
-};
-
-// Returns the name of a field parser function.
-//
-// These are out-of-line functions generated by
-// parse_function_inc_generator_main.
-TProtoStringType GetTailCallFieldHandlerName(ParseCardinality card,
- TypeFormat type_format,
- int tag_length_bytes,
- const Options& options);
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index 8b37b866ae..910b59a21a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -34,10 +34,10 @@
#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
namespace google {
namespace protobuf {
@@ -104,6 +104,9 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = PrimitiveTypeName(options, descriptor->cpp_type());
(*variables)["default"] = DefaultValue(options, descriptor);
+ (*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor);
+ (*variables)["cached_byte_size_field"] =
+ MakeVarintCachedSizeFieldName(descriptor);
(*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
int fixed_size = FixedSize(descriptor->type());
if (fixed_size != -1) {
@@ -150,7 +153,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_);
format(
"inline $type$ $classname$::_internal_$name$() const {\n"
- " return $name$_;\n"
+ " return $field$;\n"
"}\n"
"inline $type$ $classname$::$name$() const {\n"
"$annotate_get$"
@@ -159,7 +162,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline void $classname$::_internal_set_$name$($type$ value) {\n"
" $set_hasbit$\n"
- " $name$_ = value;\n"
+ " $field$ = value;\n"
"}\n"
"inline void $classname$::set_$name$($type$ value) {\n"
" _internal_set_$name$(value);\n"
@@ -170,7 +173,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_ = $default$;\n");
+ format("$field$ = $default$;\n");
}
void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
@@ -180,19 +183,19 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("swap($name$_, other->$name$_);\n");
+ format("swap($field$, other->$field$);\n");
}
void PrimitiveFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_ = $default$;\n");
+ format("$field$ = $default$;\n");
}
void PrimitiveFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_ = from.$name$_;\n");
+ format("$field$ = from.$field$;\n");
}
void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -201,7 +204,7 @@ void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format(
"target = stream->EnsureSpace(target);\n"
"target = "
- "::$proto_ns$::internal::WireFormatLite::Write$declared_type$ToArray("
+ "::_pbi::WireFormatLite::Write$declared_type$ToArray("
"$number$, this->_internal_$name$(), target);\n");
}
@@ -214,12 +217,12 @@ void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const {
// Adding one is very common and it turns out it can be done for
// free inside of WireFormatLite, so we can save an instruction here.
format(
- "total_size += ::$proto_ns$::internal::WireFormatLite::"
+ "total_size += ::_pbi::WireFormatLite::"
"$declared_type$SizePlusOne(this->_internal_$name$());\n");
} else {
format(
"total_size += $tag_size$ +\n"
- " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
+ " ::_pbi::WireFormatLite::$declared_type$Size(\n"
" this->_internal_$name$());\n");
}
} else {
@@ -249,7 +252,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline $type$ $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n"
- " return $field_member$;\n"
+ " return $field$;\n"
" }\n"
" return $default$;\n"
"}\n"
@@ -258,7 +261,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" }\n"
- " $field_member$ = value;\n"
+ " $field$ = value;\n"
"}\n"
"inline $type$ $classname$::$name$() const {\n"
"$annotate_get$"
@@ -275,7 +278,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void PrimitiveOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field_member$ = $default$;\n");
+ format("$field$ = $default$;\n");
}
void PrimitiveOneofFieldGenerator::GenerateSwappingCode(
@@ -286,7 +289,7 @@ void PrimitiveOneofFieldGenerator::GenerateSwappingCode(
void PrimitiveOneofFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$ns$::_$classname$_default_instance_.$name$_ = $default$;\n");
+ format("$ns$::_$classname$_default_instance_.$field$ = $default$;\n");
}
// ===================================================================
@@ -313,7 +316,7 @@ void RepeatedPrimitiveFieldGenerator::GeneratePrivateMembers(
format("::$proto_ns$::RepeatedField< $type$ > $name$_;\n");
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
HasGeneratedMethods(descriptor_->file(), options_)) {
- format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
+ format("mutable std::atomic<int> $cached_byte_size_name$;\n");
}
}
@@ -344,7 +347,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_);
format(
"inline $type$ $classname$::_internal_$name$(int index) const {\n"
- " return $name$_.Get(index);\n"
+ " return $field$.Get(index);\n"
"}\n"
"inline $type$ $classname$::$name$(int index) const {\n"
"$annotate_get$"
@@ -353,11 +356,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline void $classname$::set_$name$(int index, $type$ value) {\n"
"$annotate_set$"
- " $name$_.Set(index, value);\n"
+ " $field$.Set(index, value);\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"inline void $classname$::_internal_add_$name$($type$ value) {\n"
- " $name$_.Add(value);\n"
+ " $field$.Add(value);\n"
"}\n"
"inline void $classname$::add_$name$($type$ value) {\n"
" _internal_add_$name$(value);\n"
@@ -366,7 +369,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
"$classname$::_internal_$name$() const {\n"
- " return $name$_;\n"
+ " return $field$;\n"
"}\n"
"inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
"$classname$::$name$() const {\n"
@@ -376,7 +379,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline ::$proto_ns$::RepeatedField< $type$ >*\n"
"$classname$::_internal_mutable_$name$() {\n"
- " return &$name$_;\n"
+ " return &$field$;\n"
"}\n"
"inline ::$proto_ns$::RepeatedField< $type$ >*\n"
"$classname$::mutable_$name$() {\n"
@@ -389,30 +392,19 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
void RepeatedPrimitiveFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.Clear();\n");
+ format("$field$.Clear();\n");
}
void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.MergeFrom(from.$name$_);\n");
+ format("$field$.MergeFrom(from.$field$);\n");
}
void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateCopyConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$name$_.CopyFrom(from.$name$_);\n");
+ format("$field$.InternalSwap(&other->$field$);\n");
}
void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -423,7 +415,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format(
"{\n"
" int byte_size = "
- "_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n"
+ "$cached_byte_size_field$.load(std::memory_order_relaxed);\n"
" if (byte_size > 0) {\n"
" target = stream->Write$declared_type$Packed(\n"
" $number$, _internal_$name$(), byte_size, target);\n"
@@ -440,7 +432,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format(
"for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n"
" target = stream->EnsureSpace(target);\n"
- " target = ::$proto_ns$::internal::WireFormatLite::"
+ " target = ::_pbi::WireFormatLite::"
"Write$declared_type$ToArray($number$, this->_internal_$name$(i), "
"target);\n"
"}\n");
@@ -455,8 +447,8 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
int fixed_size = FixedSize(descriptor_->type());
if (fixed_size == -1) {
format(
- "size_t data_size = ::$proto_ns$::internal::WireFormatLite::\n"
- " $declared_type$Size(this->$name$_);\n");
+ "size_t data_size = ::_pbi::WireFormatLite::\n"
+ " $declared_type$Size(this->$field$);\n");
} else {
format(
"unsigned int count = static_cast<unsigned "
@@ -468,13 +460,12 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
format(
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
- " ::$proto_ns$::internal::WireFormatLite::Int32Size(\n"
- " static_cast<$int32$>(data_size));\n"
+ " ::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
"}\n");
if (FixedSize(descriptor_->type()) == -1) {
format(
- "int cached_size = ::$proto_ns$::internal::ToCachedSize(data_size);\n"
- "_$name$_cached_byte_size_.store(cached_size,\n"
+ "int cached_size = ::_pbi::ToCachedSize(data_size);\n"
+ "$cached_byte_size_field$.store(cached_size,\n"
" std::memory_order_relaxed);\n");
}
format("total_size += data_size;\n");
@@ -482,7 +473,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
format(
"total_size += $tag_size$ *\n"
" "
- "::$proto_ns$::internal::FromIntSize(this->_internal_$name$_size());\n"
+ "::_pbi::FromIntSize(this->_internal_$name$_size());\n"
"total_size += data_size;\n");
}
format.Outdent();
@@ -495,7 +486,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer(
format("$name$_()");
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
HasGeneratedMethods(descriptor_->file(), options_)) {
- format("\n, _$name$_cached_byte_size_(0)");
+ format("\n, $cached_byte_size_name$(0)");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
index ff7c208ff2..77ac598e90 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/cpp/cpp_field.h>
namespace google {
@@ -48,7 +49,7 @@ class PrimitiveFieldGenerator : public FieldGenerator {
public:
PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~PrimitiveFieldGenerator();
+ ~PrimitiveFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
@@ -72,7 +73,7 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {
public:
PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~PrimitiveOneofFieldGenerator();
+ ~PrimitiveOneofFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
@@ -88,7 +89,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
public:
RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~RepeatedPrimitiveFieldGenerator();
+ ~RepeatedPrimitiveFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
@@ -97,8 +98,8 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
- void GenerateCopyConstructorCode(io::Printer* printer) const override;
+ void GenerateConstructorCode(io::Printer* printer) const override {}
+ void GenerateCopyConstructorCode(io::Printer* printer) const override {}
void GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
index 944b41ba90..7bf589fa38 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
@@ -33,9 +33,10 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/cpp/cpp_service.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
index f510716fed..d237f9d732 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
@@ -37,8 +37,9 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index c736ce9527..4d8744976b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -33,10 +33,11 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/cpp/cpp_string_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/descriptor.pb.h>
+
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/descriptor.pb.h>
namespace google {
@@ -50,36 +51,30 @@ void SetStringVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
+
+ const TProtoStringType kNS = "::" + (*variables)["proto_ns"] + "::internal::";
+ const TProtoStringType kArenaStringPtr = kNS + "ArenaStringPtr";
+
(*variables)["default"] = DefaultValue(options, descriptor);
(*variables)["default_length"] =
StrCat(descriptor->default_value_string().length());
- TProtoStringType default_variable_string = MakeDefaultName(descriptor);
- (*variables)["default_variable_name"] = default_variable_string;
+ (*variables)["default_variable_name"] = MakeDefaultName(descriptor);
+ (*variables)["default_variable_field"] = MakeDefaultFieldName(descriptor);
- if (!descriptor->default_value_string().empty()) {
+ if (descriptor->default_value_string().empty()) {
+ (*variables)["default_string"] = kNS + "GetEmptyStringAlreadyInited()";
+ (*variables)["default_value"] = "&" + (*variables)["default_string"];
+ (*variables)["lazy_variable_args"] = "";
+ } else {
(*variables)["lazy_variable"] =
- QualifiedClassName(descriptor->containing_type(), options) +
- "::" + default_variable_string;
- }
-
- (*variables)["default_string"] =
- descriptor->default_value_string().empty()
- ? "::" + (*variables)["proto_ns"] +
- "::internal::GetEmptyStringAlreadyInited()"
- : (*variables)["lazy_variable"] + ".get()";
- (*variables)["init_value"] =
- descriptor->default_value_string().empty()
- ? "&::" + (*variables)["proto_ns"] +
- "::internal::GetEmptyStringAlreadyInited()"
- : "nullptr";
- (*variables)["default_value_tag"] =
- "::" + (*variables)["proto_ns"] + "::internal::ArenaStringPtr::" +
- (descriptor->default_value_string().empty() ? "Empty" : "NonEmpty") +
- "Default{}";
- (*variables)["default_variable_or_tag"] =
- (*variables)[descriptor->default_value_string().empty()
- ? "default_value_tag"
- : "lazy_variable"];
+ StrCat(QualifiedClassName(descriptor->containing_type(), options),
+ "::", MakeDefaultFieldName(descriptor));
+
+ (*variables)["default_string"] = (*variables)["lazy_variable"] + ".get()";
+ (*variables)["default_value"] = "nullptr";
+ (*variables)["lazy_variable_args"] = (*variables)["lazy_variable"] + ", ";
+ }
+
(*variables)["pointer_type"] =
descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
(*variables)["setter"] =
@@ -116,9 +111,14 @@ void StringFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
if (!inlined_) {
format("::$proto_ns$::internal::ArenaStringPtr $name$_;\n");
} else {
+ // Skips the automatic destruction; rather calls it explicitly if
+ // allocating arena is null. This is required to support message-owned
+ // arena (go/path-to-arenas) where a root proto is destroyed but
+ // InlinedStringField may have arena-allocated memory.
+ //
// `_init_inline_xxx` is used for initializing default instances.
format(
- "::$proto_ns$::internal::InlinedStringField $name$_;\n"
+ "union { ::$proto_ns$::internal::InlinedStringField $name$_; };\n"
"static std::true_type _init_inline_$name$_;\n");
}
}
@@ -204,8 +204,8 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_get:$full_name$)\n");
if (!descriptor_->default_value_string().empty()) {
format(
- " if ($name$_.IsDefault(nullptr)) return "
- "$default_variable_name$.get();\n");
+ " if ($field$.IsDefault()) return "
+ "$default_variable_field$.get();\n");
}
format(
" return _internal_$name$();\n"
@@ -216,7 +216,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline PROTOBUF_ALWAYS_INLINE\n"
"void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
" $set_hasbit$\n"
- " $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0),"
+ " $field$.$setter$(static_cast<ArgT0 &&>(arg0),"
" args..., GetArenaForAllocation());\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
@@ -227,9 +227,9 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline PROTOBUF_ALWAYS_INLINE\n"
"void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
" $set_hasbit$\n"
- " $name$_.$setter$(nullptr, static_cast<ArgT0 &&>(arg0),"
+ " $field$.$setter$(static_cast<ArgT0 &&>(arg0),"
" args..., GetArenaForAllocation(), _internal_$name$_donated(), "
- "&$donating_states_word$, $mask_for_undonate$);\n"
+ "&$donating_states_word$, $mask_for_undonate$, this);\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
@@ -246,20 +246,20 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" return _s;\n"
"}\n"
"inline const TProtoStringType& $classname$::_internal_$name$() const {\n"
- " return $name$_.Get();\n"
+ " return $field$.Get();\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const TProtoStringType& "
"value) {\n"
" $set_hasbit$\n");
if (!inlined_) {
format(
- " $name$_.Set($default_value_tag$, value, GetArenaForAllocation());\n"
+ " $field$.Set(value, GetArenaForAllocation());\n"
"}\n");
} else {
format(
- " $name$_.Set(nullptr, value, GetArenaForAllocation(),\n"
+ " $field$.Set(value, GetArenaForAllocation(),\n"
" _internal_$name$_donated(), &$donating_states_word$, "
- "$mask_for_undonate$);\n"
+ "$mask_for_undonate$, this);\n"
"}\n");
}
format(
@@ -267,14 +267,14 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" $set_hasbit$\n");
if (!inlined_) {
format(
- " return $name$_.Mutable($default_variable_or_tag$, "
+ " return $field$.Mutable($lazy_variable_args$"
"GetArenaForAllocation());\n"
"}\n");
} else {
format(
- " return $name$_.Mutable($default_variable_or_tag$, "
+ " return $field$.Mutable($lazy_variable_args$"
"GetArenaForAllocation(), _internal_$name$_donated(), "
- "&$donating_states_word$, $mask_for_undonate$);\n"
+ "&$donating_states_word$, $mask_for_undonate$, this);\n"
"}\n");
}
format(
@@ -289,26 +289,23 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" }\n"
" $clear_hasbit$\n");
if (!inlined_) {
- format(
- " auto* p = $name$_.ReleaseNonDefault($init_value$, "
- "GetArenaForAllocation());\n");
+ format(" auto* p = $field$.Release();\n");
if (descriptor_->default_value_string().empty()) {
format(
"#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
- " if ($name$_.IsDefault($init_value$)) {\n"
- " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n"
+ " if ($field$.IsDefault()) {\n"
+ " $field$.Set(\"\", GetArenaForAllocation());\n"
" }\n"
"#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
}
format(" return p;\n");
} else {
format(
- " return $name$_.Release(nullptr, GetArenaForAllocation(), "
+ " return $field$.Release(GetArenaForAllocation(), "
"_internal_$name$_donated());\n");
}
} else {
- format(
- " return $name$_.Release($init_value$, GetArenaForAllocation());\n");
+ format(" return $field$.Release();\n");
}
format(
@@ -320,23 +317,21 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n"
" }\n");
if (!inlined_) {
- format(
- " $name$_.SetAllocated($init_value$, $name$,\n"
- " GetArenaForAllocation());\n");
+ format(" $field$.SetAllocated($name$, GetArenaForAllocation());\n");
if (descriptor_->default_value_string().empty()) {
format(
"#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
- " if ($name$_.IsDefault($init_value$)) {\n"
- " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n"
+ " if ($field$.IsDefault()) {\n"
+ " $field$.Set(\"\", GetArenaForAllocation());\n"
" }\n"
"#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
}
} else {
// Currently, string fields with default value can't be inlined.
format(
- " $name$_.SetAllocated(nullptr, $name$, GetArenaForAllocation(), "
+ " $field$.SetAllocated(nullptr, $name$, GetArenaForAllocation(), "
"_internal_$name$_donated(), &$donating_states_word$, "
- "$mask_for_undonate$);\n");
+ "$mask_for_undonate$, this);\n");
}
format(
"$annotate_set$"
@@ -350,7 +345,7 @@ void StringFieldGenerator::GenerateNonInlineAccessorDefinitions(
if (!descriptor_->default_value_string().empty()) {
format(
"const ::$proto_ns$::internal::LazyString "
- "$classname$::$default_variable_name$"
+ "$classname$::$default_variable_field$"
"{{{$default$, $default_length$}}, {nullptr}};\n");
}
}
@@ -358,11 +353,11 @@ void StringFieldGenerator::GenerateNonInlineAccessorDefinitions(
void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
if (descriptor_->default_value_string().empty()) {
- format("$name$_.ClearToEmpty();\n");
+ format("$field$.ClearToEmpty();\n");
} else {
GOOGLE_DCHECK(!inlined_);
format(
- "$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n");
+ "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n");
}
}
@@ -388,20 +383,20 @@ void StringFieldGenerator::GenerateMessageClearingCode(
//
// For non-inlined strings, we distinguish from non-default by comparing
// instances, rather than contents.
- format("$DCHK$(!$name$_.IsDefault(nullptr));\n");
+ format("$DCHK$(!$field$.IsDefault());\n");
}
if (descriptor_->default_value_string().empty()) {
if (must_be_present) {
- format("$name$_.ClearNonDefaultToEmpty();\n");
+ format("$field$.ClearNonDefaultToEmpty();\n");
} else {
- format("$name$_.ClearToEmpty();\n");
+ format("$field$.ClearToEmpty();\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($lazy_variable$, GetArenaForAllocation());\n ");
+ "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n ");
}
}
@@ -416,34 +411,31 @@ void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
if (!inlined_) {
format(
"::$proto_ns$::internal::ArenaStringPtr::InternalSwap(\n"
- " $init_value$,\n"
- " &$name$_, lhs_arena,\n"
- " &other->$name$_, rhs_arena\n"
+ " &$field$, lhs_arena,\n"
+ " &other->$field$, rhs_arena\n"
");\n");
} else {
- // At this point, it's guaranteed that the two fields being swapped are on
- // the same arena.
format(
- "$name$_.Swap(&other->$name$_, nullptr, GetArenaForAllocation(), "
- "_internal_$name$_donated(), other->_internal_$name$_donated(), "
- "&$donating_states_word$, &(other->$donating_states_word$), "
- "$mask_for_undonate$);\n");
+ "::$proto_ns$::internal::InlinedStringField::InternalSwap(\n"
+ " &$field$, lhs_arena, "
+ "($inlined_string_donated_array$[0] & 0x1u) == 0, this,\n"
+ " &other->$field$, rhs_arena, "
+ "(other->$inlined_string_donated_array$[0] & 0x1u) == 0, other);\n");
}
}
void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
Formatter format(printer, variables_);
if (inlined_ && descriptor_->default_value_string().empty()) {
- // Automatic initialization will construct the string.
return;
}
GOOGLE_DCHECK(!inlined_);
- format("$name$_.UnsafeSetDefault($init_value$);\n");
+ format("$field$.InitDefault();\n");
if (IsString(descriptor_, options_) &&
descriptor_->default_value_string().empty()) {
format(
"#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
- " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n"
+ " $field$.Set(\"\", GetArenaForAllocation());\n"
"#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
}
}
@@ -452,6 +444,9 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
GenerateConstructorCode(printer);
+ if (inlined_) {
+ format("new (&$field$) ::_pbi::InlinedStringField();\n");
+ }
if (HasHasbit(descriptor_)) {
format("if (from._internal_has_$name$()) {\n");
@@ -463,13 +458,13 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
if (!inlined_) {
format(
- "$name$_.Set($default_value_tag$, from._internal_$name$(), \n"
+ "$field$.Set(from._internal_$name$(), \n"
" GetArenaForAllocation());\n");
} else {
format(
- "$name$_.Set(nullptr, from._internal_$name$(),\n"
+ "$field$.Set(from._internal_$name$(),\n"
" GetArenaForAllocation(), _internal_$name$_donated(), "
- "&$donating_states_word$, $mask_for_undonate$);\n");
+ "&$donating_states_word$, $mask_for_undonate$, this);\n");
}
format.Outdent();
@@ -478,12 +473,30 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- if (inlined_) {
- // The destructor is automatically invoked.
+ if (!inlined_) {
+ format("$field$.Destroy();\n");
return;
}
+ // Explicitly calls ~InlinedStringField as its automatic call is disabled.
+ // Destructor has been implicitly skipped as a union, and even the
+ // message-owned arena is enabled, arena could still be missing for
+ // Arena::CreateMessage(nullptr).
+ format("$field$.~InlinedStringField();\n");
+}
- format("$name$_.DestroyNoArena($init_value$);\n");
+ArenaDtorNeeds StringFieldGenerator::NeedsArenaDestructor() const {
+ return inlined_ ? ArenaDtorNeeds::kOnDemand : ArenaDtorNeeds::kNone;
+}
+
+void StringFieldGenerator::GenerateArenaDestructorCode(
+ io::Printer* printer) const {
+ if (!inlined_) return;
+ Formatter format(printer, variables_);
+ // _this is the object being destructed (we are inside a static method here).
+ format(
+ "if (!_this->_internal_$name$_donated()) {\n"
+ " _this->$field$.~InlinedStringField();\n"
+ "}\n");
}
void StringFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -517,9 +530,11 @@ void StringFieldGenerator::GenerateConstinitInitializer(
return;
}
if (descriptor_->default_value_string().empty()) {
- format("$name$_(&::$proto_ns$::internal::fixed_address_empty_string)");
+ format(
+ "$name$_(&::_pbi::fixed_address_empty_string, "
+ "::_pbi::ConstantInitialized{})");
} else {
- format("$name$_(nullptr)");
+ format("$name$_(nullptr, ::_pbi::ConstantInitialized{})");
}
}
@@ -550,9 +565,9 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $field_member$.UnsafeSetDefault($init_value$);\n"
+ " $field$.InitDefault();\n"
" }\n"
- " $field_member$.$setter$($default_value_tag$,"
+ " $field$.$setter$("
" static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
@@ -565,7 +580,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline const TProtoStringType& $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n"
- " return $field_member$.Get();\n"
+ " return $field$.Get();\n"
" }\n"
" return $default_string$;\n"
"}\n"
@@ -574,28 +589,26 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $field_member$.UnsafeSetDefault($init_value$);\n"
+ " $field$.InitDefault();\n"
" }\n"
- " $field_member$.Set($default_value_tag$, value, "
- "GetArenaForAllocation());\n"
+ " $field$.Set(value, GetArenaForAllocation());\n"
"}\n");
format(
"inline TProtoStringType* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $field_member$.UnsafeSetDefault($init_value$);\n"
+ " $field$.InitDefault();\n"
" }\n"
- " return $field_member$.Mutable(\n"
- " $default_variable_or_tag$, GetArenaForAllocation());\n"
+ " return $field$.Mutable($lazy_variable_args$"
+ " GetArenaForAllocation());\n"
"}\n"
"inline TProtoStringType* $classname$::$release_name$() {\n"
"$annotate_release$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
- " return $field_member$.ReleaseNonDefault($init_value$, "
- "GetArenaForAllocation());\n"
+ " return $field$.Release();\n"
" } else {\n"
" return nullptr;\n"
" }\n"
@@ -606,11 +619,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" }\n"
" if ($name$ != nullptr) {\n"
" set_has_$name$();\n"
- " $field_member$.UnsafeSetDefault($name$);\n"
- " ::$proto_ns$::Arena* arena = GetArenaForAllocation();\n"
- " if (arena != nullptr) {\n"
- " arena->Own($name$);\n"
- " }\n"
+ " $field$.InitAllocated($name$, GetArenaForAllocation());\n"
" }\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
@@ -620,9 +629,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void StringOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format(
- "$field_member$.Destroy($default_value_tag$, "
- "GetArenaForAllocation());\n");
+ format("$field$.Destroy();\n");
}
void StringOneofFieldGenerator::GenerateMessageClearingCode(
@@ -737,14 +744,14 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline const TProtoStringType& $classname$::_internal_$name$(int index) "
"const {\n"
- " return $name$_.InternalCheckedGet(\n"
+ " return $field$.InternalCheckedGet(\n"
" index, ::$proto_ns$::internal::GetEmptyStringAlreadyInited());\n"
"}\n");
} else {
format(
"inline const TProtoStringType& $classname$::_internal_$name$(int index) "
"const {\n"
- " return $name$_.Get(index);\n"
+ " return $field$.Get(index);\n"
"}\n");
}
format(
@@ -756,23 +763,23 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline TProtoStringType* $classname$::mutable_$name$(int index) {\n"
"$annotate_mutable$"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $name$_.Mutable(index);\n"
+ " return $field$.Mutable(index);\n"
"}\n"
"inline void $classname$::set_$name$(int index, const TProtoStringType& "
"value) "
"{\n"
- " $name$_.Mutable(index)->assign(value);\n"
+ " $field$.Mutable(index)->assign(value);\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(int index, TProtoStringType&& value) {\n"
- " $name$_.Mutable(index)->assign(std::move(value));\n"
+ " $field$.Mutable(index)->assign(std::move(value));\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(int index, const char* value) {\n"
" $null_check$"
- " $name$_.Mutable(index)->assign(value);\n"
+ " $field$.Mutable(index)->assign(value);\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n");
@@ -780,7 +787,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline void "
"$classname$::set_$name$(int index, StringPiece value) {\n"
- " $name$_.Mutable(index)->assign(value.data(), value.size());\n"
+ " $field$.Mutable(index)->assign(value.data(), value.size());\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
"}\n");
@@ -789,34 +796,34 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void "
"$classname$::set_$name$"
"(int index, const $pointer_type$* value, size_t size) {\n"
- " $name$_.Mutable(index)->assign(\n"
+ " $field$.Mutable(index)->assign(\n"
" reinterpret_cast<const char*>(value), size);\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"}\n"
"inline TProtoStringType* $classname$::_internal_add_$name$() {\n"
- " return $name$_.Add();\n"
+ " return $field$.Add();\n"
"}\n"
"inline void $classname$::add_$name$(const TProtoStringType& value) {\n"
- " $name$_.Add()->assign(value);\n"
+ " $field$.Add()->assign(value);\n"
"$annotate_add$"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n"
"inline void $classname$::add_$name$(TProtoStringType&& value) {\n"
- " $name$_.Add(std::move(value));\n"
+ " $field$.Add(std::move(value));\n"
"$annotate_add$"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n"
"inline void $classname$::add_$name$(const char* value) {\n"
" $null_check$"
- " $name$_.Add()->assign(value);\n"
+ " $field$.Add()->assign(value);\n"
"$annotate_add$"
" // @@protoc_insertion_point(field_add_char:$full_name$)\n"
"}\n");
if (!options_.opensource_runtime) {
format(
"inline void $classname$::add_$name$(StringPiece value) {\n"
- " $name$_.Add()->assign(value.data(), value.size());\n"
+ " $field$.Add()->assign(value.data(), value.size());\n"
"$annotate_add$"
" // @@protoc_insertion_point(field_add_string_piece:$full_name$)\n"
"}\n");
@@ -824,7 +831,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline void "
"$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n"
- " $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
+ " $field$.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
"$annotate_add$"
" // @@protoc_insertion_point(field_add_pointer:$full_name$)\n"
"}\n"
@@ -832,43 +839,32 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
"$classname$::$name$() const {\n"
"$annotate_list$"
" // @@protoc_insertion_point(field_list:$full_name$)\n"
- " return $name$_;\n"
+ " return $field$;\n"
"}\n"
"inline ::$proto_ns$::RepeatedPtrField<TProtoStringType>*\n"
"$classname$::mutable_$name$() {\n"
"$annotate_mutable_list$"
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
- " return &$name$_;\n"
+ " return &$field$;\n"
"}\n");
}
void RepeatedStringFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.Clear();\n");
+ format("$field$.Clear();\n");
}
void RepeatedStringFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.MergeFrom(from.$name$_);\n");
+ format("$field$.MergeFrom(from.$field$);\n");
}
void RepeatedStringFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
-void RepeatedStringFieldGenerator::GenerateCopyConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$name$_.CopyFrom(from.$name$_);");
+ format("$field$.InternalSwap(&other->$field$);\n");
}
void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -895,11 +891,11 @@ void RepeatedStringFieldGenerator::GenerateByteSize(
Formatter format(printer, variables_);
format(
"total_size += $tag_size$ *\n"
- " ::$proto_ns$::internal::FromIntSize($name$_.size());\n"
- "for (int i = 0, n = $name$_.size(); i < n; i++) {\n"
+ " ::$proto_ns$::internal::FromIntSize($field$.size());\n"
+ "for (int i = 0, n = $field$.size(); i < n; i++) {\n"
" total_size += "
"::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
- " $name$_.Get(i));\n"
+ " $field$.Get(i));\n"
"}\n");
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
index 3f05443f58..845bf073a9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/cpp/cpp_field.h>
namespace google {
@@ -48,7 +49,7 @@ class StringFieldGenerator : public FieldGenerator {
public:
StringFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~StringFieldGenerator();
+ ~StringFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
@@ -64,11 +65,13 @@ class StringFieldGenerator : public FieldGenerator {
void GenerateConstructorCode(io::Printer* printer) const override;
void GenerateCopyConstructorCode(io::Printer* printer) const override;
void GenerateDestructorCode(io::Printer* printer) const override;
+ void GenerateArenaDestructorCode(io::Printer* printer) const override;
void GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override;
void GenerateConstinitInitializer(io::Printer* printer) const override;
bool IsInlined() const override { return inlined_; }
+ ArenaDtorNeeds NeedsArenaDestructor() const override;
private:
bool inlined_;
@@ -79,7 +82,7 @@ class StringOneofFieldGenerator : public StringFieldGenerator {
public:
StringOneofFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~StringOneofFieldGenerator();
+ ~StringOneofFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
@@ -99,7 +102,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator {
public:
RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,
const Options& options);
- ~RepeatedStringFieldGenerator();
+ ~RepeatedStringFieldGenerator() override;
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
@@ -108,8 +111,8 @@ class RepeatedStringFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
- void GenerateCopyConstructorCode(io::Printer* printer) const override;
+ void GenerateConstructorCode(io::Printer* printer) const override {}
+ void GenerateCopyConstructorCode(io::Printer* printer) const override {}
void GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc
index 5e97b46441..ec39b10888 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc
@@ -61,7 +61,7 @@ void FieldGeneratorBase::SetCommonFieldVariables(
part_tag_size /= 2;
}
uint tag = internal::WireFormat::MakeTag(descriptor_);
- uint8 tag_array[5];
+ uint8_t tag_array[5];
io::CodedOutputStream::WriteTagToArray(tag, tag_array);
TProtoStringType tag_bytes = StrCat(tag_array[0]);
for (int i = 1; i < part_tag_size; i++) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h
index 29ff9e8eb6..db93b6211e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h
@@ -130,7 +130,8 @@ uint GetGroupEndTag(const Descriptor* descriptor);
// descriptors etc, for use in the runtime. This is the only type which is
// allowed to use proto2 syntax, and it generates internal classes.
inline bool IsDescriptorProto(const FileDescriptor* descriptor) {
- return descriptor->name() == "google/protobuf/descriptor.proto";
+ return descriptor->name() == "google/protobuf/descriptor.proto" ||
+ descriptor->name() == "net/proto2/proto/descriptor.proto";
}
// Determines whether the given message is an options message within descriptor.proto.
@@ -138,15 +139,15 @@ inline bool IsDescriptorOptionMessage(const Descriptor* descriptor) {
if (!IsDescriptorProto(descriptor->file())) {
return false;
}
- const TProtoStringType name = descriptor->full_name();
- return name == "google.protobuf.FileOptions" ||
- name == "google.protobuf.MessageOptions" ||
- name == "google.protobuf.FieldOptions" ||
- name == "google.protobuf.OneofOptions" ||
- name == "google.protobuf.EnumOptions" ||
- name == "google.protobuf.EnumValueOptions" ||
- name == "google.protobuf.ServiceOptions" ||
- name == "google.protobuf.MethodOptions";
+ const TProtoStringType name = descriptor->name();
+ return name == "FileOptions" ||
+ name == "MessageOptions" ||
+ name == "FieldOptions" ||
+ name == "OneofOptions" ||
+ name == "EnumOptions" ||
+ name == "EnumValueOptions" ||
+ name == "ServiceOptions" ||
+ name == "MethodOptions";
}
inline bool IsWrapperType(const FieldDescriptor* descriptor) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.cc
index 44c13e2f63..a13b995da8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.cc
@@ -57,9 +57,9 @@ MapFieldGenerator::~MapFieldGenerator() {
void MapFieldGenerator::GenerateMembers(io::Printer* printer) {
const FieldDescriptor* key_descriptor =
- descriptor_->message_type()->FindFieldByName("key");
+ descriptor_->message_type()->map_key();
const FieldDescriptor* value_descriptor =
- descriptor_->message_type()->FindFieldByName("value");
+ descriptor_->message_type()->map_value();
variables_["key_type_name"] = type_name(key_descriptor);
variables_["value_type_name"] = type_name(value_descriptor);
std::unique_ptr<FieldGeneratorBase> key_generator(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc
index f3e2eff8a1..cc966488f7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc
@@ -717,7 +717,7 @@ void MessageGenerator::GenerateMainParseLoop(io::Printer* printer, bool use_pars
const FieldDescriptor* field = fields_by_number()[i];
internal::WireFormatLite::WireType wt =
internal::WireFormat::WireTypeForFieldType(field->type());
- uint32 tag = internal::WireFormatLite::MakeTag(field->number(), wt);
+ arc_ui32 tag = internal::WireFormatLite::MakeTag(field->number(), wt);
// Handle both packed and unpacked repeated fields with the same Read*Array call;
// the two generated cases are the packed and unpacked tags.
// TODO(jonskeet): Check that is_packable is equivalent to
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
index 7032f2a747..80bb1270ef 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
@@ -93,13 +93,13 @@ class SourceTreeDescriptorDatabase::SingleFileErrorCollector
: filename_(filename),
multi_file_error_collector_(multi_file_error_collector),
had_errors_(false) {}
- ~SingleFileErrorCollector() {}
+ ~SingleFileErrorCollector() override {}
bool had_errors() { return had_errors_; }
// implements ErrorCollector ---------------------------------------
void AddError(int line, int column, const TProtoStringType& message) override {
- if (multi_file_error_collector_ != NULL) {
+ if (multi_file_error_collector_ != nullptr) {
multi_file_error_collector_->AddError(filename_, line, column, message);
}
had_errors_ = true;
@@ -134,12 +134,12 @@ SourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {}
bool SourceTreeDescriptorDatabase::FindFileByName(const TProtoStringType& filename,
FileDescriptorProto* output) {
std::unique_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename));
- if (input == NULL) {
+ if (input == nullptr) {
if (fallback_database_ != nullptr &&
fallback_database_->FindFileByName(filename, output)) {
return true;
}
- if (error_collector_ != NULL) {
+ if (error_collector_ != nullptr) {
error_collector_->AddError(filename, -1, 0,
source_tree_->GetLastErrorMessage());
}
@@ -151,7 +151,7 @@ bool SourceTreeDescriptorDatabase::FindFileByName(const TProtoStringType& filena
io::Tokenizer tokenizer(input.get(), &file_error_collector);
Parser parser;
- if (error_collector_ != NULL) {
+ if (error_collector_ != nullptr) {
parser.RecordErrorsTo(&file_error_collector);
}
if (using_validation_error_collector_) {
@@ -187,7 +187,7 @@ void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError(
const TProtoStringType& filename, const TProtoStringType& element_name,
const Message* descriptor, ErrorLocation location,
const TProtoStringType& message) {
- if (owner_->error_collector_ == NULL) return;
+ if (owner_->error_collector_ == nullptr) return;
int line, column;
if (location == DescriptorPool::ErrorCollector::IMPORT) {
@@ -203,7 +203,7 @@ void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning(
const TProtoStringType& filename, const TProtoStringType& element_name,
const Message* descriptor, ErrorLocation location,
const TProtoStringType& message) {
- if (owner_->error_collector_ == NULL) return;
+ if (owner_->error_collector_ == nullptr) return;
int line, column;
if (location == DescriptorPool::ErrorCollector::IMPORT) {
@@ -429,7 +429,7 @@ DiskSourceTree::DiskFileToVirtualFile(const TProtoStringType& disk_file,
// of verifying that we are not canonicalizing away any non-existent
// directories.
std::unique_ptr<io::ZeroCopyInputStream> stream(OpenDiskFile(disk_file));
- if (stream == NULL) {
+ if (stream == nullptr) {
return CANNOT_OPEN;
}
@@ -440,11 +440,11 @@ bool DiskSourceTree::VirtualFileToDiskFile(const TProtoStringType& virtual_file,
TProtoStringType* disk_file) {
std::unique_ptr<io::ZeroCopyInputStream> stream(
OpenVirtualFile(virtual_file, disk_file));
- return stream != NULL;
+ return stream != nullptr;
}
io::ZeroCopyInputStream* DiskSourceTree::Open(const TProtoStringType& filename) {
- return OpenVirtualFile(filename, NULL);
+ return OpenVirtualFile(filename, nullptr);
}
TProtoStringType DiskSourceTree::GetLastErrorMessage() {
@@ -461,7 +461,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
last_error_message_ =
"Backslashes, consecutive slashes, \".\", or \"..\" "
"are not allowed in the virtual path";
- return NULL;
+ return nullptr;
}
for (const auto& mapping : mappings_) {
@@ -469,8 +469,8 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
if (ApplyMapping(virtual_file, mapping.virtual_path, mapping.disk_path,
&temp_disk_file)) {
io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file);
- if (stream != NULL) {
- if (disk_file != NULL) {
+ if (stream != nullptr) {
+ if (disk_file != nullptr) {
*disk_file = temp_disk_file;
}
return stream;
@@ -480,12 +480,12 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
// The file exists but is not readable.
last_error_message_ =
"Read access is denied for file: " + temp_disk_file;
- return NULL;
+ return nullptr;
}
}
}
last_error_message_ = "File not found.";
- return NULL;
+ return nullptr;
}
io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
@@ -498,12 +498,12 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
#if defined(_WIN32)
if (ret == 0 && sb.st_mode & S_IFDIR) {
last_error_message_ = "Input file is a directory.";
- return NULL;
+ return nullptr;
}
#else
if (ret == 0 && S_ISDIR(sb.st_mode)) {
last_error_message_ = "Input file is a directory.";
- return NULL;
+ return nullptr;
}
#endif
int file_descriptor;
@@ -515,7 +515,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
result->SetCloseOnDelete(true);
return result;
} else {
- return NULL;
+ return nullptr;
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
index f38fcf2d67..c13821a243 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
@@ -41,10 +41,12 @@
#include <string>
#include <utility>
#include <vector>
+
#include <google/protobuf/compiler/parser.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor_database.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -85,7 +87,7 @@ class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
// the specified source_tree.
SourceTreeDescriptorDatabase(SourceTree* source_tree,
DescriptorDatabase* fallback_database);
- ~SourceTreeDescriptorDatabase();
+ ~SourceTreeDescriptorDatabase() override;
// Instructs the SourceTreeDescriptorDatabase to report any parse errors
// to the given MultiFileErrorCollector. This should be called before
@@ -124,7 +126,7 @@ class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
: public DescriptorPool::ErrorCollector {
public:
ValidationErrorCollector(SourceTreeDescriptorDatabase* owner);
- ~ValidationErrorCollector();
+ ~ValidationErrorCollector() override;
// implements ErrorCollector ---------------------------------------
void AddError(const TProtoStringType& filename, const TProtoStringType& element_name,
@@ -241,7 +243,7 @@ class PROTOBUF_EXPORT SourceTree {
class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
public:
DiskSourceTree();
- ~DiskSourceTree();
+ ~DiskSourceTree() override;
// Map a path on disk to a location in the SourceTree. The path may be
// either a file or a directory. If it is a directory, the entire tree
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
index 3403cfca2c..9ee161f7f3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
@@ -30,11 +30,11 @@
#include <google/protobuf/compiler/java/java_context.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_field.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
index 2d30eabce9..2252d122fa 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
@@ -36,9 +36,9 @@
#include <vector>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/descriptor.pb.h>
namespace google {
namespace protobuf {
@@ -199,7 +199,16 @@ void WriteDeprecatedJavadoc(io::Printer* printer, const FieldDescriptor* field,
return;
}
- printer->Print(" * @deprecated\n");
+ TProtoStringType startLine = "0";
+ SourceLocation location;
+ if (field->GetSourceLocation(&location)) {
+ startLine = std::to_string(location.start_line);
+ }
+
+ printer->Print(" * @deprecated $name$ is deprecated.\n", "name",
+ field->full_name());
+ printer->Print(" * See $file$;l=$line$\n", "file", field->file()->name(),
+ "line", startLine);
}
void WriteFieldAccessorDocComment(io::Printer* printer,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
index e7faa4a6a0..52d6f77474 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
@@ -37,6 +37,7 @@
#include <google/protobuf/descriptor.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
index d9070eeaab..8574527f0b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
@@ -32,17 +32,18 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <google/protobuf/compiler/java/java_enum.h>
+
#include <map>
#include <string>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_enum.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc
index 8c658eef9b..59df1132e7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -40,13 +40,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
index 5d3564530e..3fb65ae546 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
@@ -99,7 +100,7 @@ class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
- ~ImmutableEnumOneofFieldGenerator();
+ ~ImmutableEnumOneofFieldGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index f7e7b2dab7..33cff57cf3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc
@@ -40,13 +40,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
index bf84607aac..7ec742d19f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
@@ -32,17 +32,18 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <google/protobuf/compiler/java/java_enum_lite.h>
+
#include <map>
#include <string>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_enum_lite.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
index 9602780c49..d90994503d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
@@ -34,12 +34,12 @@
#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
index d796c56c76..f9bd326f9b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
@@ -92,7 +92,7 @@ class ImmutableExtensionGenerator : public ExtensionGenerator {
public:
explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor,
Context* context);
- virtual ~ImmutableExtensionGenerator();
+ ~ImmutableExtensionGenerator() override;
void Generate(io::Printer* printer) override;
int GenerateNonNestedInitializationCode(io::Printer* printer) override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
index 3f12f20a57..0135d9ee03 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
@@ -30,12 +30,12 @@
#include <google/protobuf/compiler/java/java_extension_lite.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
index 117b87f7a8..3e13db7028 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
@@ -49,7 +49,7 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
public:
explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor,
Context* context);
- virtual ~ImmutableExtensionLiteGenerator();
+ ~ImmutableExtensionLiteGenerator() override;
void Generate(io::Printer* printer) override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
index 15283e1083..9373e568cf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
@@ -38,6 +38,9 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_enum_field.h>
#include <google/protobuf/compiler/java/java_enum_field_lite.h>
@@ -50,9 +53,6 @@
#include <google/protobuf/compiler/java/java_primitive_field_lite.h>
#include <google/protobuf/compiler/java/java_string_field.h>
#include <google/protobuf/compiler/java/java_string_field_lite.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
index 09384c483a..481fbdb456 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
@@ -156,7 +156,7 @@ template <>
FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap();
-// Field information used in FieldGeneartors.
+// Field information used in FieldGenerators.
struct FieldGeneratorInfo {
TProtoStringType name;
TProtoStringType capitalized_name;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
index 0809febb8b..c2261ddfeb 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
@@ -37,6 +37,11 @@
#include <memory>
#include <set>
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_enum.h>
#include <google/protobuf/compiler/java/java_enum_lite.h>
@@ -47,12 +52,7 @@
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/compiler/java/java_service.h>
#include <google/protobuf/compiler/java/java_shared_code_generator.h>
-#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h
index b567b62fd9..7a5a8ec01d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h
@@ -38,6 +38,7 @@
#include <memory>
#include <string>
#include <vector>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_options.h>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
index 2b5728579e..ce198c7692 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
@@ -37,6 +37,9 @@
#include <memory>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/compiler/java/java_file.h>
#include <google/protobuf/compiler/java/java_generator_factory.h>
#include <google/protobuf/compiler/java/java_helpers.h>
@@ -44,8 +47,6 @@
#include <google/protobuf/compiler/java/java_options.h>
#include <google/protobuf/compiler/java/java_shared_code_generator.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/strutil.h>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h
index 90d2610550..e08c980788 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h
@@ -40,6 +40,7 @@
#include <string>
#include <google/protobuf/compiler/code_generator.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -54,7 +55,7 @@ namespace java {
class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
public:
JavaGenerator();
- ~JavaGenerator();
+ ~JavaGenerator() override;
// implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
index 831d9dd857..807bca383a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
@@ -78,7 +78,7 @@ class GeneratorFactory {
class ImmutableGeneratorFactory : public GeneratorFactory {
public:
ImmutableGeneratorFactory(Context* context);
- virtual ~ImmutableGeneratorFactory();
+ ~ImmutableGeneratorFactory() override;
MessageGenerator* NewMessageGenerator(
const Descriptor* descriptor) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
index 4c613af8ea..3f1f058c9e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
@@ -40,13 +40,13 @@
#include <unordered_set>
#include <vector>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/compiler/java/java_names.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/hash.h> // for hash<T *>
namespace google {
@@ -66,15 +66,27 @@ namespace {
const char* kDefaultPackage = "";
-// Names that should be avoided as field names.
-// Using them will cause the compiler to generate accessors whose names are
-// colliding with methods defined in base classes.
+// Names that should be avoided (in UpperCamelCase format).
+// Using them will cause the compiler to generate accessors whose names
+// collide with methods defined in base classes.
+// Keep this list in sync with specialFieldNames in
+// java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java
const char* kForbiddenWordList[] = {
- // message base class:
- "cached_size",
- "serialized_size",
// java.lang.Object:
- "class",
+ "Class",
+ // com.google.protobuf.MessageLiteOrBuilder:
+ "DefaultInstanceForType",
+ // com.google.protobuf.MessageLite:
+ "ParserForType",
+ "SerializedSize",
+ // com.google.protobuf.MessageOrBuilder:
+ "AllFields",
+ "DescriptorForType",
+ "InitializationErrorString",
+ // TODO(b/219045204): re-enable
+ // "UnknownFields",
+ // obsolete. kept for backwards compatibility of generated code
+ "CachedSize",
};
const std::unordered_set<TProtoStringType>* kReservedNames =
@@ -93,7 +105,7 @@ const std::unordered_set<TProtoStringType>* kReservedNames =
bool IsForbidden(const TProtoStringType& field_name) {
for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
- if (field_name == kForbiddenWordList[i]) {
+ if (UnderscoresToCamelCase(field_name, true) == kForbiddenWordList[i]) {
return true;
}
}
@@ -1049,8 +1061,7 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) {
if (field->is_map()) {
if (!SupportUnknownEnumValue(field)) {
- const FieldDescriptor* value =
- field->message_type()->FindFieldByName("value");
+ const FieldDescriptor* value = field->message_type()->map_value();
if (GetJavaType(value) == JAVATYPE_ENUM) {
extra_bits |= kMapWithProto2EnumValue;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
index b0cce4949b..59bb718bc9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
@@ -38,10 +38,10 @@
#include <cstdint>
#include <string>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/compiler/java/java_context.h>
+#include <google/protobuf/descriptor.pb.h>
namespace google {
namespace protobuf {
@@ -151,6 +151,21 @@ inline bool IsDescriptorProto(const Descriptor* descriptor) {
// fields.
TProtoStringType GetOneofStoredType(const FieldDescriptor* field);
+// We use either the proto1 enums if the enum is generated, otherwise fall back
+// to use integers.
+enum class Proto1EnumRepresentation {
+ kEnum,
+ kInteger,
+};
+
+// Returns which representation we should use.
+inline Proto1EnumRepresentation GetProto1EnumRepresentation(
+ const EnumDescriptor* descriptor) {
+ if (descriptor->containing_type() != nullptr) {
+ return Proto1EnumRepresentation::kEnum;
+ }
+ return Proto1EnumRepresentation::kInteger;
+}
// Whether we should generate multiple java files for messages.
inline bool MultipleJavaFiles(const FileDescriptor* descriptor,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc
index 9a18926275..fc0d823671 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc
@@ -30,11 +30,11 @@
#include <google/protobuf/compiler/java/java_kotlin_generator.h>
+#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/java/java_file.h>
+#include <google/protobuf/compiler/java/java_generator.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_options.h>
-#include <google/protobuf/compiler/java/java_generator.h>
-#include <google/protobuf/compiler/code_generator.h>
namespace google {
namespace protobuf {
@@ -63,11 +63,13 @@ bool KotlinGenerator::Generate(const FileDescriptor* file,
if (option.first == "output_list_file") {
file_options.output_list_file = option.second;
} else if (option.first == "immutable") {
+ // Note: the option is considered always set regardless of the input.
file_options.generate_immutable_code = true;
} else if (option.first == "mutable") {
*error = "Mutable not supported by Kotlin generator";
return false;
} else if (option.first == "shared") {
+ // Note: the option is considered always set regardless of the input.
file_options.generate_shared_code = true;
} else if (option.first == "lite") {
file_options.enforce_lite = true;
@@ -81,23 +83,17 @@ bool KotlinGenerator::Generate(const FileDescriptor* file,
}
}
- // By default we generate immutable code and shared code for immutable API.
- if (!file_options.generate_immutable_code &&
- !file_options.generate_shared_code) {
- file_options.generate_immutable_code = true;
- file_options.generate_shared_code = true;
- }
+ // We only support generation of immutable code so we do it.
+ file_options.generate_immutable_code = true;
+ file_options.generate_shared_code = true;
std::vector<TProtoStringType> all_files;
std::vector<TProtoStringType> all_annotations;
- std::unique_ptr<FileGenerator> file_generator;
- if (file_options.generate_immutable_code) {
- file_generator.reset(
+ std::unique_ptr<FileGenerator> file_generator(
new FileGenerator(file, file_options, /* immutable_api = */ true));
- }
- if (!file_generator->Validate(error)) {
+ if (!file_generator || !file_generator->Validate(error)) {
return false;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
index 6e0fa8c276..195acb6537 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
@@ -36,6 +36,8 @@
#include <string>
#include <google/protobuf/compiler/code_generator.h>
+
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
index a35bd42ebe..7a93f4696d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
@@ -30,11 +30,11 @@
#include <google/protobuf/compiler/java/java_map_field.h>
+#include <google/protobuf/io/printer.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
namespace google {
namespace protobuf {
@@ -47,14 +47,14 @@ const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("key");
+ return message->map_key();
}
const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("value");
+ return message->map_value();
}
TProtoStringType TypeName(const FieldDescriptor* field,
@@ -99,6 +99,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
const JavaType keyJavaType = GetJavaType(key);
const JavaType valueJavaType = GetJavaType(value);
+ TProtoStringType pass_through_nullness = "/* nullable */\n";
+
(*variables)["key_type"] = TypeName(key, name_resolver, false);
TProtoStringType boxed_key_type = TypeName(key, name_resolver, true);
(*variables)["boxed_key_type"] = boxed_key_type;
@@ -129,6 +131,9 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
+ (*variables)["value_enum_type_pass_through_nullness"] =
+ pass_through_nullness + (*variables)["value_enum_type"];
+
if (SupportUnknownEnumValue(descriptor->file())) {
// Map unknown values to a special UNRECOGNIZED value if supported.
(*variables)["unrecognized_value"] =
@@ -140,6 +145,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
}
} else {
(*variables)["value_type"] = TypeName(value, name_resolver, false);
+
+ (*variables)["value_type_pass_through_nullness"] =
+ (IsReferenceType(valueJavaType) ? pass_through_nullness : "") +
+ (*variables)["value_type"];
+
(*variables)["boxed_value_type"] = TypeName(value, name_resolver, true);
(*variables)["value_wire_type"] = WireType(value);
(*variables)["value_default_value"] =
@@ -218,11 +228,12 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
"${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue);\n");
+ printer->Print(variables_,
+ "$deprecation$$value_enum_type_pass_through_nullness$ "
+ "${$get$capitalized_name$OrDefault$}$(\n"
+ " $key_type$ key,\n"
+ " $value_enum_type_pass_through_nullness$ "
+ " defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
@@ -276,9 +287,10 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "$value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_type$ defaultValue);\n");
+ " $value_type_pass_through_nullness$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
@@ -538,9 +550,10 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
variables_,
"@java.lang.Override\n"
"$deprecation$\n"
- "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "public $value_enum_type_pass_through_nullness$ "
+ "${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_enum_type$ defaultValue) {\n"
+ " $value_enum_type_pass_through_nullness$ defaultValue) {\n"
" $key_null_check$\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
" internalGet$capitalized_name$().getMap();\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
index 2c52ccaea7..8817f27339 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -32,11 +32,11 @@
#include <cstdint>
+#include <google/protobuf/io/printer.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
namespace google {
namespace protobuf {
@@ -49,14 +49,14 @@ const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("key");
+ return message->map_key();
}
const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("value");
+ return message->map_value();
}
TProtoStringType TypeName(const FieldDescriptor* field,
@@ -101,6 +101,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
const JavaType keyJavaType = GetJavaType(key);
const JavaType valueJavaType = GetJavaType(value);
+ TProtoStringType pass_through_nullness = "/* nullable */\n";
+
(*variables)["key_type"] = TypeName(key, name_resolver, false);
(*variables)["boxed_key_type"] = TypeName(key, name_resolver, true);
(*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver);
@@ -128,6 +130,9 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
+ (*variables)["value_enum_type_pass_through_nullness"] =
+ pass_through_nullness + (*variables)["value_enum_type"];
+
if (SupportUnknownEnumValue(descriptor->file())) {
// Map unknown values to a special UNRECOGNIZED value if supported.
(*variables)["unrecognized_value"] =
@@ -139,6 +144,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
}
} else {
(*variables)["value_type"] = TypeName(value, name_resolver, false);
+
+ (*variables)["value_type_pass_through_nullness"] =
+ (IsReferenceType(valueJavaType) ? pass_through_nullness : "") +
+ (*variables)["value_type"];
+
(*variables)["boxed_value_type"] = TypeName(value, name_resolver, true);
(*variables)["value_wire_type"] = WireType(value);
(*variables)["value_default_value"] =
@@ -203,11 +213,12 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
"${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue);\n");
+ printer->Print(variables_,
+ "$deprecation$$value_enum_type_pass_through_nullness$ "
+ "${$get$capitalized_name$OrDefault$}$(\n"
+ " $key_type$ key,\n"
+ " $value_enum_type_pass_through_nullness$ "
+ " defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
@@ -261,9 +272,10 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "$value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_type$ defaultValue);\n");
+ " $value_type_pass_through_nullness$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
@@ -606,9 +618,10 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$\n"
- "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "public $value_enum_type_pass_through_nullness$ "
+ "${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_enum_type$ defaultValue) {\n"
+ " $value_enum_type_pass_through_nullness$ defaultValue) {\n"
" $key_null_check$\n"
" java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n"
" instance.get$capitalized_name$Map();\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
index e5343d6762..9a5c25a538 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
@@ -40,6 +40,11 @@
#include <memory>
#include <vector>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -50,11 +55,6 @@
#include <google/protobuf/compiler/java/java_message_builder_lite.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -67,7 +67,7 @@ using internal::WireFormatLite;
namespace {
TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
ClassNameResolver* name_resolver) {
- const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
+ const FieldDescriptor* value_field = descriptor->map_value();
GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
return name_resolver->GetImmutableClassName(value_field->message_type());
}
@@ -1273,6 +1273,9 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
printer->Print(
"} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
" throw e.setUnfinishedMessage(this);\n"
+ "} catch (com.google.protobuf.UninitializedMessageException e) {\n"
+ " throw "
+ "e.asInvalidProtocolBufferException().setUnfinishedMessage(this);\n"
"} catch (java.io.IOException e) {\n"
" throw new com.google.protobuf.InvalidProtocolBufferException(\n"
" e).setUnfinishedMessage(this);\n"
@@ -1455,7 +1458,7 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
void ImmutableMessageGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n"
"public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ "
@@ -1486,7 +1489,7 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
"kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
- "}._build()\n",
+ "}._build()\n\n",
"message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
name_resolver_->GetKotlinExtensionsClassName(descriptor_));
@@ -1495,6 +1498,24 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
.GenerateTopLevelKotlinMembers(printer);
}
+
+ GenerateKotlinOrNull(printer);
+}
+
+void ImmutableMessageGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) {
+ printer->Print(
+ "val $full_classname$OrBuilder.$camelcase_name$OrNull: $full_name$?\n"
+ " get() = if (has$name$()) get$name$() else null\n\n",
+ "full_classname", name_resolver_->GetClassName(descriptor_, true),
+ "camelcase_name", context_->GetFieldGeneratorInfo(field)->name,
+ "full_name",
+ name_resolver_->GetImmutableClassName(field->message_type()), "name",
+ context_->GetFieldGeneratorInfo(field)->capitalized_name);
+ }
+ }
}
void ImmutableMessageGenerator::GenerateKotlinExtensions(
@@ -1504,7 +1525,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <T> get(extension: "
+ "public operator fun <T : kotlin.Any> get(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
@@ -1520,7 +1541,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "public operator fun <E> get(\n"
+ "public operator fun <E : kotlin.Any> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@@ -1549,7 +1570,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.PublishedApi\n"
- "internal fun <T> setExtension(extension: "
+ "internal fun <T : kotlin.Any> setExtension(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>, "
"value: T) {\n"
" _builder.setExtension(extension, value)\n"
@@ -1592,7 +1613,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@@ -1601,7 +1622,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@@ -1611,7 +1632,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@@ -1622,7 +1643,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@@ -1632,7 +1653,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public operator fun <E : kotlin.Any> "
+ "com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
" _builder.setExtension(this.extension, index, value)\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
index cafc91e68b..cc24d73d35 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
@@ -100,7 +101,7 @@ class MessageGenerator {
class ImmutableMessageGenerator : public MessageGenerator {
public:
ImmutableMessageGenerator(const Descriptor* descriptor, Context* context);
- virtual ~ImmutableMessageGenerator();
+ ~ImmutableMessageGenerator() override;
void Generate(io::Printer* printer) override;
void GenerateInterface(io::Printer* printer) override;
@@ -136,6 +137,7 @@ class ImmutableMessageGenerator : public MessageGenerator {
void GenerateParsingConstructor(io::Printer* printer);
void GenerateMutableCopy(io::Printer* printer);
void GenerateKotlinExtensions(io::Printer* printer) const;
+ void GenerateKotlinOrNull(io::Printer* printer) const;
void GenerateAnyMethods(io::Printer* printer);
Context* context_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
index 510b9d785c..e8ff5fa33b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -39,6 +39,11 @@
#include <memory>
#include <vector>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -47,11 +52,6 @@
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -61,7 +61,7 @@ namespace java {
namespace {
TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
ClassNameResolver* name_resolver) {
- const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
+ const FieldDescriptor* value_field = descriptor->map_value();
GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
return name_resolver->GetImmutableClassName(value_field->message_type());
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
index fcd73b3436..619bf9eca1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
index bff99b7b1a..5f90e8d691 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
@@ -39,6 +39,11 @@
#include <memory>
#include <vector>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -47,11 +52,6 @@
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
index 3402adf332..03ecbf870b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
index bdd80a811f..5db89dbe21 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
@@ -32,17 +32,18 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <google/protobuf/compiler/java/java_message_field.h>
+
#include <map>
#include <string>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message_field.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -438,6 +439,16 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
+
+ GenerateKotlinOrNull(printer);
+}
+
+void ImmutableMessageFieldGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
+ if (descriptor_->has_optional_keyword()) {
+ printer->Print(variables_,
+ "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
+ " get() = $kt_dsl_builder$.$name$OrNull\n");
+ }
}
void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode(
@@ -698,8 +709,9 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
"if ($has_oneof_case_message$) {\n"
" $name$Builder_.mergeFrom(value);\n"
- "}\n"
- "$name$Builder_.setMessage(value);\n",
+ "} else {\n"
+ " $name$Builder_.setMessage(value);\n"
+ "}\n",
"$set_oneof_case_message$;\n"
"return this;\n");
@@ -1426,7 +1438,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ false);
@@ -1438,7 +1450,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ false);
@@ -1449,7 +1461,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ false);
@@ -1462,7 +1474,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ false);
@@ -1474,7 +1486,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
@@ -1485,7 +1497,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
+ "}\n\n");
}
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
index a0c24ae7b7..94a144d4ae 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
@@ -61,7 +62,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
int messageBitIndex,
int builderBitIndex,
Context* context);
- ~ImmutableMessageFieldGenerator();
+ ~ImmutableMessageFieldGenerator() override;
// implements ImmutableFieldGenerator
// ---------------------------------------
@@ -102,6 +103,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator);
+ void GenerateKotlinOrNull(io::Printer* printer) const;
};
class ImmutableMessageOneofFieldGenerator
@@ -110,7 +112,7 @@ class ImmutableMessageOneofFieldGenerator
ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
- ~ImmutableMessageOneofFieldGenerator();
+ ~ImmutableMessageOneofFieldGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc
index 100726856c..523190d85a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc
@@ -38,13 +38,13 @@
#include <map>
#include <string>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -308,6 +308,15 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
+ GenerateKotlinOrNull(printer);
+}
+
+void ImmutableMessageFieldLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
+ if (descriptor_->has_optional_keyword()) {
+ printer->Print(variables_,
+ "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
+ " get() = $kt_dsl_builder$.$name$OrNull\n");
+ }
}
void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
@@ -816,7 +825,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ false);
@@ -828,7 +837,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ false);
@@ -839,7 +848,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ false);
@@ -852,7 +861,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ false);
@@ -864,7 +873,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
+ "}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
@@ -875,7 +884,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
+ "}\n");
}
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h
index 9f778da45b..189d760afe 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h
@@ -62,7 +62,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
- ~ImmutableMessageFieldLiteGenerator();
+ ~ImmutableMessageFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator
// ------------------------------------
@@ -85,6 +85,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldLiteGenerator);
+ void GenerateKotlinOrNull(io::Printer* printer) const;
};
class ImmutableMessageOneofFieldLiteGenerator
@@ -93,7 +94,7 @@ class ImmutableMessageOneofFieldLiteGenerator
ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
- ~ImmutableMessageOneofFieldLiteGenerator();
+ ~ImmutableMessageOneofFieldLiteGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
index f5d7c9362a..615dece6cb 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -40,6 +40,11 @@
#include <memory>
#include <vector>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum_lite.h>
@@ -50,11 +55,6 @@
#include <google/protobuf/compiler/java/java_message_builder_lite.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -779,7 +779,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n"
"public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ =\n"
@@ -808,7 +808,7 @@ void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
"kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
- "}._build()\n",
+ "}._build()\n\n",
"message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
name_resolver_->GetKotlinExtensionsClassName(descriptor_));
@@ -817,6 +817,26 @@ void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
.GenerateTopLevelKotlinMembers(printer);
}
+
+ GenerateKotlinOrNull(printer);
+}
+
+void ImmutableMessageLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
+ // Generate getFieldOrNull getters for all optional message fields.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) {
+ printer->Print(
+ "val $full_classname$OrBuilder.$camelcase_name$OrNull: "
+ "$full_name$?\n"
+ " get() = if (has$name$()) get$name$() else null\n\n",
+ "full_classname", name_resolver_->GetClassName(descriptor_, true),
+ "camelcase_name", context_->GetFieldGeneratorInfo(field)->name,
+ "full_name",
+ name_resolver_->GetImmutableClassName(field->message_type()), "name",
+ context_->GetFieldGeneratorInfo(field)->capitalized_name);
+ }
+ }
}
void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
@@ -826,7 +846,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <T> get(extension: "
+ "public operator fun <T : kotlin.Any> get(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
@@ -842,7 +862,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "public operator fun <E> get(\n"
+ "public operator fun <E : kotlin.Any> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@@ -871,7 +891,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.PublishedApi\n"
- "internal fun <T> setExtension(extension: "
+ "internal fun <T : kotlin.Any> setExtension(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>, "
"value: T) {\n"
" _builder.setExtension(extension, value)\n"
@@ -914,7 +934,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@@ -923,7 +943,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@@ -933,7 +953,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@@ -944,7 +964,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@@ -954,7 +974,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public operator fun <E : kotlin.Any> "
+ "com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
" _builder.setExtension(this.extension, index, value)\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
index adb0df7cc7..c0afbc99ec 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
#include <google/protobuf/compiler/java/java_message.h>
@@ -48,7 +49,7 @@ namespace java {
class ImmutableMessageLiteGenerator : public MessageGenerator {
public:
ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context);
- virtual ~ImmutableMessageLiteGenerator();
+ ~ImmutableMessageLiteGenerator() override;
void Generate(io::Printer* printer) override;
void GenerateInterface(io::Printer* printer) override;
@@ -70,6 +71,7 @@ class ImmutableMessageLiteGenerator : public MessageGenerator {
void GenerateConstructor(io::Printer* printer);
void GenerateDynamicMethodNewBuildMessageInfo(io::Printer* printer);
void GenerateKotlinExtensions(io::Printer* printer) const;
+ void GenerateKotlinOrNull(io::Printer* printer) const;
Context* context_;
ClassNameResolver* name_resolver_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
index 595ead4955..a257409ab7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
@@ -33,10 +33,10 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_names.h>
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_names.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
index 180f3de630..46f699c6aa 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
@@ -123,7 +123,6 @@ class ClassNameResolver {
TProtoStringType GetDowngradedFileClassName(const FileDescriptor* file);
TProtoStringType GetDowngradedClassName(const Descriptor* descriptor);
- private:
// Get the full name of a Java class by prepending the Java package name
// or outer class name.
TProtoStringType GetClassFullName(const TProtoStringType& name_without_package,
@@ -132,6 +131,8 @@ class ClassNameResolver {
TProtoStringType GetClassFullName(const TProtoStringType& name_without_package,
const FileDescriptor* file, bool immutable,
bool is_own_file, bool kotlin);
+
+ private:
// Get the Java Class style full name of a message.
TProtoStringType GetJavaClassFullName(const TProtoStringType& name_without_package,
const FileDescriptor* file, bool immutable);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc
index 8b3d234469..abe88b67e0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc
@@ -40,13 +40,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
index f04fd0f7b5..8883b83d66 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
@@ -37,6 +37,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
@@ -101,7 +102,7 @@ class ImmutablePrimitiveOneofFieldGenerator
ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex, Context* context);
- ~ImmutablePrimitiveOneofFieldGenerator();
+ ~ImmutablePrimitiveOneofFieldGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index 6ab207e7af..20ba2a4051 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -40,13 +40,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -161,7 +161,6 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
(*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_message"] = "";
(*variables)["clear_has_field_bit_message"] = "";
switch (descriptor->type()) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h
index 445012e0e3..a7f03e2acc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h
@@ -93,7 +93,7 @@ class ImmutablePrimitiveOneofFieldLiteGenerator
ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
- ~ImmutablePrimitiveOneofFieldLiteGenerator();
+ ~ImmutablePrimitiveOneofFieldLiteGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
index 05748f5847..59e11deb77 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
@@ -34,12 +34,12 @@
#include <google/protobuf/compiler/java/java_service.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
index 58d2c8d750..a03a3de561 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
@@ -78,7 +78,7 @@ class ImmutableServiceGenerator : public ServiceGenerator {
public:
ImmutableServiceGenerator(const ServiceDescriptor* descriptor,
Context* context);
- virtual ~ImmutableServiceGenerator();
+ ~ImmutableServiceGenerator() override;
void Generate(io::Printer* printer) override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
index a0d5e2b45f..7d7e95dfba 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
@@ -34,15 +34,15 @@
#include <memory>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_names.h>
#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/compiler/java/java_names.h>
+#include <google/protobuf/descriptor.pb.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
index 0c9ba04e56..5628441a74 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
@@ -41,13 +41,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -992,7 +992,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String> += String
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ false);
- printer->Print(variables_,
+ printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
index 02f0734aea..f282163b55 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
@@ -38,6 +38,7 @@
#include <map>
#include <string>
+
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
@@ -61,7 +62,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
explicit ImmutableStringFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex, Context* context);
- ~ImmutableStringFieldGenerator();
+ ~ImmutableStringFieldGenerator() override;
// implements ImmutableFieldGenerator
// ---------------------------------------
@@ -101,7 +102,7 @@ class ImmutableStringOneofFieldGenerator
ImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
- ~ImmutableStringOneofFieldGenerator();
+ ~ImmutableStringOneofFieldGenerator() override;
private:
void GenerateMembers(io::Printer* printer) const override;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
index 3150c766ce..d2cfad0dcd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -41,13 +41,13 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc
index 019ef3a5b5..8c9fadf067 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc
@@ -3625,16 +3625,19 @@ void Generator::GenerateFile(const GeneratorOptions& options,
if (options.import_style == GeneratorOptions::kImportCommonJsStrict) {
printer->Print("var proto = {};\n\n");
} else {
- // To get the global object we call a function with .call(null), this will set "this" inside the
- // function to the global object.
- // This does not work if we are running in strict mode ("use strict"),
- // so we fallback to the following things (in order from first to last):
+ // To get the global object we call a function with .call(null), this will
+ // set "this" inside the function to the global object. This does not work
+ // if we are running in strict mode ("use strict"), so we fallback to the
+ // following things (in order from first to last):
// - window: defined in browsers
// - global: defined in most server side environments like NodeJS
// - self: defined inside Web Workers (WorkerGlobalScope)
- // - Function('return this')(): this will work on most platforms, but it may be blocked by things like CSP.
+ // - Function('return this')(): this will work on most platforms, but it
+ // may be blocked by things like CSP.
// Function('') is almost the same as eval('')
- printer->Print("var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);\n\n");
+ printer->Print(
+ "var global = (function() { return this || window || global || self "
+ "|| Function('return this')(); }).call(null);\n\n");
}
for (int i = 0; i < file->dependency_count(); i++) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
index 10de997f0c..ce6b49d84e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
@@ -35,11 +35,13 @@
#include <google/protobuf/compiler/command_line_interface.h>
#include <google/protobuf/compiler/perlxs/perlxs_generator.h>
#include <google/protobuf/compiler/python/python_generator.h>
+#include <google/protobuf/compiler/python/python_pyi_generator.h>
#include <google/protobuf/compiler/csharp/csharp_generator.h>
#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
#include <google/protobuf/compiler/php/php_generator.h>
#include <google/protobuf/compiler/ruby/ruby_generator.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -76,6 +78,10 @@ int ProtobufMain(int argc, char* argv[]) {
python::Generator py_generator;
cli.RegisterGenerator("--python_out", "--python_opt", &py_generator,
"Generate Python source file.");
+ // Python pyi
+ python::PyiGenerator pyi_generator;
+ cli.RegisterGenerator("--pyi_out", &pyi_generator,
+ "Generate python pyi stub.");
// PHP
php::Generator php_generator;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
index 474b70a8ad..9f87d2c71e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
@@ -65,9 +65,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
}
} // namespace
-EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : SingleFieldGenerator(descriptor, options) {
+EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor)
+ : SingleFieldGenerator(descriptor) {
SetEnumVariables(descriptor, &variables_);
}
@@ -116,12 +115,16 @@ void EnumFieldGenerator::GenerateCFunctionImplementations(
}
void EnumFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const {
- SingleFieldGenerator::DetermineForwardDeclarations(fwd_decls);
- // If it is an enum defined in a different file, then we'll need a forward
- // declaration for it. When it is in our file, all the enums are output
- // before the message, so it will be declared before it is needed.
- if (descriptor_->file() != descriptor_->enum_type()->file()) {
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const {
+ SingleFieldGenerator::DetermineForwardDeclarations(
+ fwd_decls, include_external_types);
+ // If it is an enum defined in a different file (and not a WKT), then we'll
+ // need a forward declaration for it. When it is in our file, all the enums
+ // are output before the message, so it will be declared before it is needed.
+ if (include_external_types &&
+ descriptor_->file() != descriptor_->enum_type()->file() &&
+ !IsProtobufLibraryBundledProtoFile(descriptor_->enum_type()->file())) {
// Enum name is already in "storage_type".
const TProtoStringType& name = variable("storage_type");
fwd_decls->insert("GPB_ENUM_FWD_DECLARE(" + name + ")");
@@ -129,8 +132,8 @@ void EnumFieldGenerator::DetermineForwardDeclarations(
}
RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : RepeatedFieldGenerator(descriptor, options) {
+ const FieldDescriptor* descriptor)
+ : RepeatedFieldGenerator(descriptor) {
SetEnumVariables(descriptor, &variables_);
variables_["array_storage_type"] = "GPBEnumArray";
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
index 89d3e6907c..8c27a3702f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
@@ -41,8 +41,7 @@ namespace compiler {
namespace objectivec {
class EnumFieldGenerator : public SingleFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
EnumFieldGenerator(const EnumFieldGenerator&) = delete;
EnumFieldGenerator& operator=(const EnumFieldGenerator&) = delete;
@@ -53,23 +52,22 @@ class EnumFieldGenerator : public SingleFieldGenerator {
virtual void GenerateCFunctionImplementations(
io::Printer* printer) const override;
virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const override;
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
protected:
- EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
+ EnumFieldGenerator(const FieldDescriptor* descriptor);
virtual ~EnumFieldGenerator();
};
class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
public:
virtual void FinishInitialization() override;
protected:
- RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor);
virtual ~RepeatedEnumFieldGenerator();
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
index 0e1bb33070..cd0ad8a016 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
@@ -118,40 +118,39 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
} // namespace
-FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options) {
+FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field) {
FieldGenerator* result = NULL;
if (field->is_repeated()) {
switch (GetObjectiveCType(field)) {
case OBJECTIVECTYPE_MESSAGE: {
if (field->is_map()) {
- result = new MapFieldGenerator(field, options);
+ result = new MapFieldGenerator(field);
} else {
- result = new RepeatedMessageFieldGenerator(field, options);
+ result = new RepeatedMessageFieldGenerator(field);
}
break;
}
case OBJECTIVECTYPE_ENUM:
- result = new RepeatedEnumFieldGenerator(field, options);
+ result = new RepeatedEnumFieldGenerator(field);
break;
default:
- result = new RepeatedPrimitiveFieldGenerator(field, options);
+ result = new RepeatedPrimitiveFieldGenerator(field);
break;
}
} else {
switch (GetObjectiveCType(field)) {
case OBJECTIVECTYPE_MESSAGE: {
- result = new MessageFieldGenerator(field, options);
+ result = new MessageFieldGenerator(field);
break;
}
case OBJECTIVECTYPE_ENUM:
- result = new EnumFieldGenerator(field, options);
+ result = new EnumFieldGenerator(field);
break;
default:
if (IsReferenceType(field)) {
- result = new PrimitiveObjFieldGenerator(field, options);
+ result = new PrimitiveObjFieldGenerator(field);
} else {
- result = new PrimitiveFieldGenerator(field, options);
+ result = new PrimitiveFieldGenerator(field);
}
break;
}
@@ -160,8 +159,7 @@ FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
return result;
}
-FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
+FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor)
: descriptor_(descriptor) {
SetCommonFieldVariables(descriptor, &variables_);
}
@@ -185,7 +183,8 @@ void FieldGenerator::GenerateCFunctionImplementations(
}
void FieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const {
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const {
// Nothing
}
@@ -266,9 +265,8 @@ void FieldGenerator::FinishInitialization(void) {
}
}
-SingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : FieldGenerator(descriptor, options) {
+SingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor)
+ : FieldGenerator(descriptor) {
// Nothing
}
@@ -310,9 +308,8 @@ bool SingleFieldGenerator::RuntimeUsesHasBit(void) const {
return true;
}
-ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : SingleFieldGenerator(descriptor, options) {
+ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor)
+ : SingleFieldGenerator(descriptor) {
variables_["property_storage_attribute"] = "strong";
if (IsRetainedName(variables_["name"])) {
variables_["storage_attribute"] = " NS_RETURNS_NOT_RETAINED";
@@ -353,8 +350,8 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
}
RepeatedFieldGenerator::RepeatedFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : ObjCObjFieldGenerator(descriptor, options) {
+ const FieldDescriptor* descriptor)
+ : ObjCObjFieldGenerator(descriptor) {
// Default to no comment and let the cases needing it fill it in.
variables_["array_comment"] = "";
}
@@ -407,19 +404,18 @@ bool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const {
return false; // The array (or map/dict) having anything is what is used.
}
-FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,
- const Options& options)
+FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
: descriptor_(descriptor),
field_generators_(descriptor->field_count()),
extension_generators_(descriptor->extension_count()) {
// Construct all the FieldGenerators.
for (int i = 0; i < descriptor->field_count(); i++) {
field_generators_[i].reset(
- FieldGenerator::Make(descriptor->field(i), options));
+ FieldGenerator::Make(descriptor->field(i)));
}
for (int i = 0; i < descriptor->extension_count(); i++) {
extension_generators_[i].reset(
- FieldGenerator::Make(descriptor->extension(i), options));
+ FieldGenerator::Make(descriptor->extension(i)));
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
index b2d2e676b1..bc1fb11b8a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
@@ -33,7 +33,6 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/printer.h>
@@ -44,8 +43,7 @@ namespace objectivec {
class FieldGenerator {
public:
- static FieldGenerator* Make(const FieldDescriptor* field,
- const Options& options);
+ static FieldGenerator* Make(const FieldDescriptor* field);
virtual ~FieldGenerator();
@@ -66,7 +64,8 @@ class FieldGenerator {
// Exposed for subclasses, should always call it on the parent class also.
virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const;
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const;
virtual void DetermineObjectiveCClassDefinitions(
std::set<TProtoStringType>* fwd_decls) const;
@@ -96,7 +95,7 @@ class FieldGenerator {
TProtoStringType raw_field_name() const { return variable("raw_field_name"); }
protected:
- FieldGenerator(const FieldDescriptor* descriptor, const Options& options);
+ FieldGenerator(const FieldDescriptor* descriptor);
virtual void FinishInitialization(void);
bool WantsHasProperty(void) const;
@@ -120,8 +119,7 @@ class SingleFieldGenerator : public FieldGenerator {
virtual bool RuntimeUsesHasBit(void) const override;
protected:
- SingleFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ SingleFieldGenerator(const FieldDescriptor* descriptor);
};
// Subclass with common support for when the field ends up as an ObjC Object.
@@ -136,8 +134,7 @@ class ObjCObjFieldGenerator : public SingleFieldGenerator {
virtual void GeneratePropertyDeclaration(io::Printer* printer) const override;
protected:
- ObjCObjFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ ObjCObjFieldGenerator(const FieldDescriptor* descriptor);
};
class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
@@ -155,15 +152,14 @@ class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
virtual bool RuntimeUsesHasBit(void) const override;
protected:
- RepeatedFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ RepeatedFieldGenerator(const FieldDescriptor* descriptor);
virtual void FinishInitialization(void) override;
};
// Convenience class which constructs FieldGenerators for a Descriptor.
class FieldGeneratorMap {
public:
- FieldGeneratorMap(const Descriptor* descriptor, const Options& options);
+ FieldGeneratorMap(const Descriptor* descriptor);
~FieldGeneratorMap();
FieldGeneratorMap(const FieldGeneratorMap&) = delete;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
index abb8bb7811..0f4828c3ac 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
@@ -31,6 +31,7 @@
#include <google/protobuf/compiler/objectivec/objectivec_file.h>
#include <google/protobuf/compiler/objectivec/objectivec_enum.h>
#include <google/protobuf/compiler/objectivec/objectivec_extension.h>
+#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
#include <google/protobuf/compiler/objectivec/objectivec_message.h>
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/io/printer.h>
@@ -56,6 +57,10 @@ const arc_i32 GOOGLE_PROTOBUF_OBJC_VERSION = 30004;
const char* kHeaderExtension = ".pbobjc.h";
+TProtoStringType BundledFileName(const FileDescriptor* file) {
+ return "GPB" + FilePathBasename(file) + kHeaderExtension;
+}
+
// Checks if a message contains any enums definitions (on the message or
// a nested message under it).
bool MessageContainsEnums(const Descriptor* message) {
@@ -185,18 +190,19 @@ bool IsDirectDependency(const FileDescriptor* dep, const FileDescriptor* file) {
} // namespace
-FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
+FileGenerator::FileGenerator(const FileDescriptor* file,
+ const GenerationOptions& generation_options)
: file_(file),
+ generation_options_(generation_options),
root_class_name_(FileClassName(file)),
- is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)),
- options_(options) {
+ is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)) {
for (int i = 0; i < file_->enum_type_count(); i++) {
EnumGenerator* generator = new EnumGenerator(file_->enum_type(i));
enum_generators_.emplace_back(generator);
}
for (int i = 0; i < file_->message_type_count(); i++) {
MessageGenerator* generator =
- new MessageGenerator(root_class_name_, file_->message_type(i), options_);
+ new MessageGenerator(root_class_name_, file_->message_type(i));
message_generators_.emplace_back(generator);
}
for (int i = 0; i < file_->extension_count(); i++) {
@@ -216,6 +222,10 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
headers.push_back("GPBDescriptor.h");
headers.push_back("GPBMessage.h");
headers.push_back("GPBRootObject.h");
+ for (int i = 0; i < file_->dependency_count(); i++) {
+ const TProtoStringType header_name = BundledFileName(file_->dependency(i));
+ headers.push_back(header_name);
+ }
} else {
headers.push_back("GPBProtocolBuffers.h");
}
@@ -237,16 +247,26 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
"\n",
"google_protobuf_objc_version", StrCat(GOOGLE_PROTOBUF_OBJC_VERSION));
- // #import any headers for "public imports" in the proto file.
+ // The bundled protos (WKTs) don't use of forward declarations.
+ bool headers_use_forward_declarations =
+ generation_options_.headers_use_forward_declarations && !is_bundled_proto_;
+
{
ImportWriter import_writer(
- options_.generate_for_named_framework,
- options_.named_framework_to_proto_path_mappings_path,
- options_.runtime_import_prefix,
- is_bundled_proto_);
+ generation_options_.generate_for_named_framework,
+ generation_options_.named_framework_to_proto_path_mappings_path,
+ generation_options_.runtime_import_prefix,
+ /* include_wkt_imports = */ false);
const TProtoStringType header_extension(kHeaderExtension);
- for (int i = 0; i < file_->public_dependency_count(); i++) {
- import_writer.AddFile(file_->public_dependency(i), header_extension);
+ if (headers_use_forward_declarations) {
+ // #import any headers for "public imports" in the proto file.
+ for (int i = 0; i < file_->public_dependency_count(); i++) {
+ import_writer.AddFile(file_->public_dependency(i), header_extension);
+ }
+ } else {
+ for (int i = 0; i < file_->dependency_count(); i++) {
+ import_writer.AddFile(file_->dependency(i), header_extension);
+ }
}
import_writer.Print(printer);
}
@@ -266,7 +286,9 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
std::set<TProtoStringType> fwd_decls;
for (const auto& generator : message_generators_) {
- generator->DetermineForwardDeclarations(&fwd_decls);
+ generator->DetermineForwardDeclarations(
+ &fwd_decls,
+ /* include_external_types = */ headers_use_forward_declarations);
}
for (std::set<TProtoStringType>::const_iterator i(fwd_decls.begin());
i != fwd_decls.end(); ++i) {
@@ -340,6 +362,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
// #import the runtime support.
std::vector<TProtoStringType> headers;
headers.push_back("GPBProtocolBuffers_RuntimeSupport.h");
+ if (is_bundled_proto_) {
+ headers.push_back(BundledFileName(file_));
+ }
PrintFileRuntimePreamble(printer, headers);
// Enums use atomic in the generated code, so add the system import as needed.
@@ -352,28 +377,34 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
std::vector<const FileDescriptor*> deps_with_extensions;
CollectMinimalFileDepsContainingExtensions(file_, &deps_with_extensions);
+ // The bundled protos (WKTs) don't use of forward declarations.
+ bool headers_use_forward_declarations =
+ generation_options_.headers_use_forward_declarations && !is_bundled_proto_;
+
{
ImportWriter import_writer(
- options_.generate_for_named_framework,
- options_.named_framework_to_proto_path_mappings_path,
- options_.runtime_import_prefix,
- is_bundled_proto_);
+ generation_options_.generate_for_named_framework,
+ generation_options_.named_framework_to_proto_path_mappings_path,
+ generation_options_.runtime_import_prefix,
+ /* include_wkt_imports = */ false);
const TProtoStringType header_extension(kHeaderExtension);
// #import the header for this proto file.
import_writer.AddFile(file_, header_extension);
- // #import the headers for anything that a plain dependency of this proto
- // file (that means they were just an include, not a "public" include).
- std::set<TProtoStringType> public_import_names;
- for (int i = 0; i < file_->public_dependency_count(); i++) {
- public_import_names.insert(file_->public_dependency(i)->name());
- }
- for (int i = 0; i < file_->dependency_count(); i++) {
- const FileDescriptor *dep = file_->dependency(i);
- bool public_import = (public_import_names.count(dep->name()) != 0);
- if (!public_import) {
- import_writer.AddFile(dep, header_extension);
+ if (headers_use_forward_declarations) {
+ // #import the headers for anything that a plain dependency of this proto
+ // file (that means they were just an include, not a "public" include).
+ std::set<TProtoStringType> public_import_names;
+ for (int i = 0; i < file_->public_dependency_count(); i++) {
+ public_import_names.insert(file_->public_dependency(i)->name());
+ }
+ for (int i = 0; i < file_->dependency_count(); i++) {
+ const FileDescriptor *dep = file_->dependency(i);
+ bool public_import = (public_import_names.count(dep->name()) != 0);
+ if (!public_import) {
+ import_writer.AddFile(dep, header_extension);
+ }
}
}
@@ -599,8 +630,26 @@ void FileGenerator::PrintFileRuntimePreamble(
"// source: $filename$\n"
"\n",
"filename", file_->name());
- ImportWriter::PrintRuntimeImports(
- printer, headers_to_import, options_.runtime_import_prefix, true);
+
+ if (is_bundled_proto_) {
+ // This is basically a clone of ImportWriter::PrintRuntimeImports() but
+ // without the CPP symbol gate, since within the bundled files, that isn't
+ // needed.
+ TProtoStringType import_prefix = generation_options_.runtime_import_prefix;
+ if (!import_prefix.empty()) {
+ import_prefix += "/";
+ }
+ for (const auto& header : headers_to_import) {
+ printer->Print(
+ "#import \"$import_prefix$$header$\"\n",
+ "import_prefix", import_prefix,
+ "header", header);
+ }
+ } else {
+ ImportWriter::PrintRuntimeImports(
+ printer, headers_to_import, generation_options_.runtime_import_prefix, true);
+ }
+
printer->Print("\n");
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
index 6bd747ac5e..6d2c970f81 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
@@ -34,7 +34,6 @@
#include <string>
#include <set>
#include <vector>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/printer.h>
@@ -49,7 +48,19 @@ class MessageGenerator;
class FileGenerator {
public:
- FileGenerator(const FileDescriptor* file, const Options& options);
+ struct GenerationOptions {
+ GenerationOptions()
+ // TODO(thomasvl): Eventually flip this default to false for better
+ // interop with Swift if proto usages span modules made from ObjC sources.
+ : headers_use_forward_declarations(true) {}
+ TProtoStringType generate_for_named_framework;
+ TProtoStringType named_framework_to_proto_path_mappings_path;
+ TProtoStringType runtime_import_prefix;
+ bool headers_use_forward_declarations;
+ };
+
+ FileGenerator(const FileDescriptor* file,
+ const GenerationOptions& generation_options);
~FileGenerator();
FileGenerator(const FileGenerator&) = delete;
@@ -60,6 +71,7 @@ class FileGenerator {
private:
const FileDescriptor* file_;
+ const GenerationOptions& generation_options_;
TProtoStringType root_class_name_;
bool is_bundled_proto_;
@@ -67,8 +79,6 @@ class FileGenerator {
std::vector<std::unique_ptr<MessageGenerator>> message_generators_;
std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
- const Options options_;
-
void PrintFileRuntimePreamble(
io::Printer* printer,
const std::vector<TProtoStringType>& headers_to_import) const;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
index 160af71080..552d7e7273 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
@@ -94,7 +94,8 @@ bool ObjectiveCGenerator::GenerateAll(
//
// e.g. protoc ... --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework
- Options generation_options;
+ Options validation_options;
+ FileGenerator::GenerationOptions generation_options;
std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
ParseGeneratorParameter(parameter, &options);
@@ -110,17 +111,20 @@ bool ObjectiveCGenerator::GenerateAll(
// - Comments start with "#".
// - A comment can go on a line after a expected package/prefix pair.
// (i.e. - "package=prefix # comment")
+ // - For files that do NOT have a proto package (not recommended), an
+ // entry can be made as "no_package:PATH=prefix", where PATH is the
+ // path for the .proto file.
//
// There is no validation that the prefixes are good prefixes, it is
// assumed that they are when you create the file.
- generation_options.expected_prefixes_path = options[i].second;
+ validation_options.expected_prefixes_path = options[i].second;
} else if (options[i].first == "expected_prefixes_suppressions") {
// A semicolon delimited string that lists the paths of .proto files to
// exclude from the package prefix validations (expected_prefixes_path).
// This is provided as an "out", to skip some files being checked.
for (StringPiece split_piece : Split(
options[i].second, ";", true)) {
- generation_options.expected_prefixes_suppressions.push_back(
+ validation_options.expected_prefixes_suppressions.push_back(
TProtoStringType(split_piece));
}
} else if (options[i].first == "prefixes_must_be_registered") {
@@ -132,7 +136,7 @@ bool ObjectiveCGenerator::GenerateAll(
// tried to use a prefix that isn't registered.
// Default is "no".
if (!StringToBool(options[i].second,
- &generation_options.prefixes_must_be_registered)) {
+ &validation_options.prefixes_must_be_registered)) {
*error = "error: Unknown value for prefixes_must_be_registered: " + options[i].second;
return false;
}
@@ -144,7 +148,7 @@ bool ObjectiveCGenerator::GenerateAll(
// raised if a files doesn't have one.
// Default is "no".
if (!StringToBool(options[i].second,
- &generation_options.require_prefixes)) {
+ &validation_options.require_prefixes)) {
*error = "error: Unknown value for require_prefixes: " + options[i].second;
return false;
}
@@ -185,8 +189,22 @@ bool ObjectiveCGenerator::GenerateAll(
// generated files. When integrating ObjC protos into a build system,
// this can be used to avoid having to add the runtime directory to the
// header search path since the generate #import will be more complete.
- generation_options.runtime_import_prefix =
- StripSuffixString(options[i].second, "/");
+ generation_options.runtime_import_prefix = StripSuffixString(options[i].second, "/");
+ } else if (options[i].first == "package_to_prefix_mappings_path") {
+ // Path to use for when loading the objc class prefix mappings to use.
+ // The `objc_class_prefix` file option is always honored first if one is present.
+ // This option also has precedent over the use_package_as_prefix option.
+ //
+ // The format of the file is:
+ // - An entry is a line of "package=prefix".
+ // - Comments start with "#".
+ // - A comment can go on a line after a expected package/prefix pair.
+ // (i.e. - "package=prefix # comment")
+ // - For files that do NOT have a proto package (not recommended), an
+ // entry can be made as "no_package:PATH=prefix", where PATH is the
+ // path for the .proto file.
+ //
+ SetPackageToPrefixMappingsPath(options[i].second);
} else if (options[i].first == "use_package_as_prefix") {
// Controls how the symbols should be prefixed to avoid symbols
// collisions. The objc_class_prefix file option is always honored, this
@@ -212,6 +230,12 @@ bool ObjectiveCGenerator::GenerateAll(
// - A comment can go on a line after a expected package/prefix pair.
// (i.e. - "some.proto.package # comment")
SetProtoPackagePrefixExceptionList(options[i].second);
+ } else if (options[i].first == "headers_use_forward_declarations") {
+ if (!StringToBool(options[i].second,
+ &generation_options.headers_use_forward_declarations)) {
+ *error = "error: Unknown value for headers_use_forward_declarations: " + options[i].second;
+ return false;
+ }
} else {
*error = "error: Unknown generator option: " + options[i].first;
return false;
@@ -240,7 +264,7 @@ bool ObjectiveCGenerator::GenerateAll(
// -----------------------------------------------------------------
// Validate the objc prefix/package pairings.
- if (!ValidateObjCClassPrefixes(files, generation_options, error)) {
+ if (!ValidateObjCClassPrefixes(files, validation_options, error)) {
// *error will have been filled in.
return false;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
index cbe70bac36..5122fa46c0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@@ -74,6 +74,14 @@ using ::open;
namespace {
+bool BoolFromEnvVar(const char* env_var, bool default_value) {
+ const char* value = getenv(env_var);
+ if (value) {
+ return TProtoStringType("YES") == ToUpper(value);
+ }
+ return default_value;
+}
+
class SimpleLineCollector : public LineConsumer {
public:
SimpleLineCollector(std::unordered_set<TProtoStringType>* inout_set)
@@ -88,10 +96,31 @@ class SimpleLineCollector : public LineConsumer {
std::unordered_set<TProtoStringType>* set_;
};
+class PackageToPrefixesCollector : public LineConsumer {
+ public:
+ PackageToPrefixesCollector(const TProtoStringType &usage,
+ std::map<TProtoStringType, TProtoStringType>* inout_package_to_prefix_map)
+ : usage_(usage), prefix_map_(inout_package_to_prefix_map) {}
+
+ virtual bool ConsumeLine(const StringPiece& line, TProtoStringType* out_error) override;
+
+ private:
+ const TProtoStringType usage_;
+ std::map<TProtoStringType, TProtoStringType>* prefix_map_;
+};
+
class PrefixModeStorage {
public:
PrefixModeStorage();
+ const TProtoStringType package_to_prefix_mappings_path() const { return package_to_prefix_mappings_path_; }
+ void set_package_to_prefix_mappings_path(const TProtoStringType& path) {
+ package_to_prefix_mappings_path_ = path;
+ package_to_prefix_map_.clear();
+ }
+
+ TProtoStringType prefix_from_proto_package_mappings(const FileDescriptor* file);
+
bool use_package_name() const { return use_package_name_; }
void set_use_package_name(bool on_or_off) { use_package_name_ = on_or_off; }
@@ -103,9 +132,16 @@ class PrefixModeStorage {
bool is_package_exempted(const TProtoStringType& package);
+ // When using a proto package as the prefix, this should be added as the
+ // prefix in front of it.
+ const TProtoStringType& forced_package_prefix() const { return forced_prefix_; }
+
private:
bool use_package_name_;
+ std::map<TProtoStringType, TProtoStringType> package_to_prefix_map_;
+ TProtoStringType package_to_prefix_mappings_path_;
TProtoStringType exception_path_;
+ TProtoStringType forced_prefix_;
std::unordered_set<TProtoStringType> exceptions_;
};
@@ -113,14 +149,57 @@ PrefixModeStorage::PrefixModeStorage() {
// Even thought there are generation options, have an env back door since some
// of these helpers could be used in other plugins.
- const char* use_package_cstr = getenv("GPB_OBJC_USE_PACKAGE_AS_PREFIX");
- use_package_name_ =
- (use_package_cstr && (TProtoStringType("YES") == ToUpper(use_package_cstr)));
+ use_package_name_ = BoolFromEnvVar("GPB_OBJC_USE_PACKAGE_AS_PREFIX", false);
const char* exception_path = getenv("GPB_OBJC_PACKAGE_PREFIX_EXCEPTIONS_PATH");
if (exception_path) {
exception_path_ = exception_path;
}
+
+ // This one is a not expected to be common, so it doesn't get a generation
+ // option, just the env var.
+ const char* prefix = getenv("GPB_OBJC_USE_PACKAGE_AS_PREFIX_PREFIX");
+ if (prefix) {
+ forced_prefix_ = prefix;
+ }
+}
+
+TProtoStringType PrefixModeStorage::prefix_from_proto_package_mappings(const FileDescriptor* file) {
+ if (!file) {
+ return "";
+ }
+
+ if (package_to_prefix_map_.empty() && !package_to_prefix_mappings_path_.empty()) {
+ TProtoStringType error_str;
+ // Re use the same collector as we use for expected_prefixes_path since the file
+ // format is the same.
+ PackageToPrefixesCollector collector("Package to prefixes", &package_to_prefix_map_);
+ if (!ParseSimpleFile(package_to_prefix_mappings_path_, &collector, &error_str)) {
+ if (error_str.empty()) {
+ error_str = TProtoStringType("protoc:0: warning: Failed to parse")
+ + TProtoStringType(" prefix to proto package mappings file: ")
+ + package_to_prefix_mappings_path_;
+ }
+ std::cerr << error_str << std::endl;
+ std::cerr.flush();
+ package_to_prefix_map_.clear();
+ }
+ }
+
+ const TProtoStringType package = file->package();
+ // For files without packages, the can be registered as "no_package:PATH",
+ // allowing the expected prefixes file.
+ static const TProtoStringType no_package_prefix("no_package:");
+ const TProtoStringType lookup_key = package.empty() ? no_package_prefix + file->name() : package;
+
+ std::map<TProtoStringType, TProtoStringType>::const_iterator prefix_lookup =
+ package_to_prefix_map_.find(lookup_key);
+
+ if (prefix_lookup != package_to_prefix_map_.end()) {
+ return prefix_lookup->second;
+ }
+
+ return "";
}
bool PrefixModeStorage::is_package_exempted(const TProtoStringType& package) {
@@ -152,6 +231,14 @@ PrefixModeStorage g_prefix_mode;
} // namespace
+TProtoStringType GetPackageToPrefixMappingsPath() {
+ return g_prefix_mode.package_to_prefix_mappings_path();
+}
+
+void SetPackageToPrefixMappingsPath(const TProtoStringType& file_path) {
+ g_prefix_mode.set_package_to_prefix_mappings_path(file_path);
+}
+
bool UseProtoPackageAsDefaultPrefix() {
return g_prefix_mode.use_package_name();
}
@@ -169,7 +256,9 @@ void SetProtoPackagePrefixExceptionList(const TProtoStringType& file_path) {
}
Options::Options() {
- // Default is the value of the env for the package prefixes.
+ // While there are generator options, also support env variables to help with
+ // build systems where it isn't as easy to hook in for add the generation
+ // options when invoking protoc.
const char* file_path = getenv("GPB_OBJC_EXPECTED_PACKAGE_PREFIXES");
if (file_path) {
expected_prefixes_path = file_path;
@@ -179,8 +268,9 @@ Options::Options() {
expected_prefixes_suppressions =
Split(suppressions, ";", true);
}
- prefixes_must_be_registered = false;
- require_prefixes = false;
+ prefixes_must_be_registered =
+ BoolFromEnvVar("GPB_OBJC_PREFIXES_MUST_BE_REGISTERED", false);
+ require_prefixes = BoolFromEnvVar("GPB_OBJC_REQUIRE_PREFIXES", false);
}
namespace {
@@ -353,9 +443,9 @@ bool IsReservedCIdentifier(const TProtoStringType& input) {
}
TProtoStringType SanitizeNameForObjC(const TProtoStringType& prefix,
- const TProtoStringType& input,
- const TProtoStringType& extension,
- TProtoStringType* out_suffix_added) {
+ const TProtoStringType& input,
+ const TProtoStringType& extension,
+ TProtoStringType* out_suffix_added) {
static const std::unordered_set<TProtoStringType> kReservedWords =
MakeWordsMap(kReservedWordList, GOOGLE_ARRAYSIZE(kReservedWordList));
static const std::unordered_set<TProtoStringType> kNSObjectMethods =
@@ -511,8 +601,14 @@ TProtoStringType FileClassPrefix(const FileDescriptor* file) {
return file->options().objc_class_prefix();
}
- // If package prefix isn't enabled or no package, done.
- if (!g_prefix_mode.use_package_name() || file->package().empty()) {
+ // If package prefix is specified in an prefix to proto mappings file then use that.
+ TProtoStringType objc_class_prefix = g_prefix_mode.prefix_from_proto_package_mappings(file);
+ if (!objc_class_prefix.empty()) {
+ return objc_class_prefix;
+ }
+
+ // If package prefix isn't enabled, done.
+ if (!g_prefix_mode.use_package_name()) {
return "";
}
@@ -539,7 +635,7 @@ TProtoStringType FileClassPrefix(const FileDescriptor* file) {
if (!result.empty()) {
result.append("_");
}
- return result;
+ return g_prefix_mode.forced_package_prefix() + result;
}
TProtoStringType FilePath(const FileDescriptor* file) {
@@ -1185,23 +1281,11 @@ void RemoveComment(StringPiece* input) {
namespace {
-class ExpectedPrefixesCollector : public LineConsumer {
- public:
- ExpectedPrefixesCollector(std::map<TProtoStringType, TProtoStringType>* inout_package_to_prefix_map)
- : prefix_map_(inout_package_to_prefix_map) {}
-
- virtual bool ConsumeLine(const StringPiece& line, TProtoStringType* out_error) override;
-
- private:
- std::map<TProtoStringType, TProtoStringType>* prefix_map_;
-};
-
-bool ExpectedPrefixesCollector::ConsumeLine(
+bool PackageToPrefixesCollector::ConsumeLine(
const StringPiece& line, TProtoStringType* out_error) {
int offset = line.find('=');
if (offset == StringPiece::npos) {
- *out_error = TProtoStringType("Expected prefixes file line without equal sign: '") +
- TProtoStringType(line) + "'.";
+ *out_error = usage_ + " file line without equal sign: '" + StrCat(line) + "'.";
return false;
}
StringPiece package = line.substr(0, offset);
@@ -1215,16 +1299,16 @@ bool ExpectedPrefixesCollector::ConsumeLine(
return true;
}
-bool LoadExpectedPackagePrefixes(const Options& generation_options,
+bool LoadExpectedPackagePrefixes(const TProtoStringType& expected_prefixes_path,
std::map<TProtoStringType, TProtoStringType>* prefix_map,
TProtoStringType* out_error) {
- if (generation_options.expected_prefixes_path.empty()) {
+ if (expected_prefixes_path.empty()) {
return true;
}
- ExpectedPrefixesCollector collector(prefix_map);
+ PackageToPrefixesCollector collector("Expected prefixes", prefix_map);
return ParseSimpleFile(
- generation_options.expected_prefixes_path, &collector, out_error);
+ expected_prefixes_path, &collector, out_error);
}
bool ValidateObjCClassPrefix(
@@ -1241,6 +1325,11 @@ bool ValidateObjCClassPrefix(
const TProtoStringType prefix = file->options().objc_class_prefix();
const TProtoStringType package = file->package();
+ // For files without packages, the can be registered as "no_package:PATH",
+ // allowing the expected prefixes file.
+ static const TProtoStringType no_package_prefix("no_package:");
+ const TProtoStringType lookup_key =
+ package.empty() ? no_package_prefix + file->name() : package;
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// error cases, so it seems to be ok to use as a back door for warnings.
@@ -1248,7 +1337,7 @@ bool ValidateObjCClassPrefix(
// Check: Error - See if there was an expected prefix for the package and
// report if it doesn't match (wrong or missing).
std::map<TProtoStringType, TProtoStringType>::const_iterator package_match =
- expected_package_prefixes.find(package);
+ expected_package_prefixes.find(lookup_key);
if (package_match != expected_package_prefixes.end()) {
// There was an entry, and...
if (has_prefix && package_match->second == prefix) {
@@ -1257,8 +1346,11 @@ bool ValidateObjCClassPrefix(
} else {
// ...it didn't match!
*out_error = "error: Expected 'option objc_class_prefix = \"" +
- package_match->second + "\";' for package '" + package +
- "' in '" + file->name() + "'";
+ package_match->second + "\";'";
+ if (!package.empty()) {
+ *out_error += " for package '" + package + "'";
+ }
+ *out_error += " in '" + file->name() + "'";
if (has_prefix) {
*out_error += "; but found '" + prefix + "' instead";
}
@@ -1287,35 +1379,12 @@ bool ValidateObjCClassPrefix(
i != expected_package_prefixes.end(); ++i) {
if (i->second == prefix) {
other_package_for_prefix = i->first;
- break;
- }
- }
-
- // Check: Warning - If the file does not have a package, check whether the
- // prefix was declared is being used by another package or not. This is
- // a special case for empty packages.
- if (package.empty()) {
- // The file does not have a package and ...
- if (other_package_for_prefix.empty()) {
- // ... no other package has declared that prefix.
- std::cerr
- << "protoc:0: warning: File '" << file->name() << "' has no "
- << "package. Consider adding a new package to the proto and adding '"
- << "new.package = " << prefix << "' to the expected prefixes file ("
- << expected_prefixes_path << ")." << std::endl;
- std::cerr.flush();
- } else {
- // ... another package has declared the same prefix.
- std::cerr
- << "protoc:0: warning: File '" << file->name() << "' has no package "
- << "and package '" << other_package_for_prefix << "' already uses '"
- << prefix << "' as its prefix. Consider either adding a new package "
- << "to the proto, or reusing one of the packages already using this "
- << "prefix in the expected prefixes file ("
- << expected_prefixes_path << ")." << std::endl;
- std::cerr.flush();
+ // Stop on the first real package listing, if it was a no_package file
+ // specific entry, keep looking to try and find a package one.
+ if (!HasPrefixString(other_package_for_prefix, no_package_prefix)) {
+ break;
+ }
}
- return true;
}
// Check: Error - Make sure the prefix wasn't expected for a different
@@ -1324,14 +1393,20 @@ bool ValidateObjCClassPrefix(
if (!other_package_for_prefix.empty()) {
*out_error =
"error: Found 'option objc_class_prefix = \"" + prefix +
- "\";' in '" + file->name() +
- "'; that prefix is already used for 'package " +
- other_package_for_prefix + ";'. It can only be reused by listing " +
- "it in the expected file (" +
- expected_prefixes_path + ").";
+ "\";' in '" + file->name() + "'; that prefix is already used for ";
+ if (HasPrefixString(other_package_for_prefix, no_package_prefix)) {
+ *out_error += "file '" +
+ StripPrefixString(other_package_for_prefix, no_package_prefix) +
+ "'.";
+ } else {
+ *out_error += "'package " + other_package_for_prefix + ";'.";
+ }
+ *out_error +=
+ " It can only be reused by adding '" + lookup_key + " = " + prefix +
+ "' to the expected prefixes file (" + expected_prefixes_path + ").";
return false; // Only report first usage of the prefix.
}
- } // !prefix.empty()
+ } // !prefix.empty() && have_expected_prefix_file
// Check: Warning - Make sure the prefix is is a reasonable value according
// to Apple's rules (the checks above implicitly whitelist anything that
@@ -1360,17 +1435,18 @@ bool ValidateObjCClassPrefix(
if (prefixes_must_be_registered) {
*out_error =
"error: '" + file->name() + "' has 'option objc_class_prefix = \"" +
- prefix + "\";', but it is not registered; add it to the expected " +
- "prefixes file (" + expected_prefixes_path + ") for the package '" +
- package + "'.";
+ prefix + "\";', but it is not registered. Add '" + lookup_key + " = " +
+ (prefix.empty() ? "\"\"" : prefix) +
+ "' to the expected prefixes file (" + expected_prefixes_path + ").";
return false;
}
std::cerr
<< "protoc:0: warning: Found unexpected 'option objc_class_prefix = \""
- << prefix << "\";' in '" << file->name() << "';"
- << " consider adding it to the expected prefixes file ("
- << expected_prefixes_path << ")." << std::endl;
+ << prefix << "\";' in '" << file->name() << "'; consider adding '"
+ << lookup_key << " = " << (prefix.empty() ? "\"\"" : prefix)
+ << "' to the expected prefixes file (" << expected_prefixes_path
+ << ")." << std::endl;
std::cerr.flush();
}
@@ -1380,6 +1456,13 @@ bool ValidateObjCClassPrefix(
} // namespace
bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files,
+ TProtoStringType* out_error) {
+ // Options's ctor load from the environment.
+ Options options;
+ return ValidateObjCClassPrefixes(files, options, out_error);
+}
+
+bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files,
const Options& generation_options,
TProtoStringType* out_error) {
// Allow a '-' as the path for the expected prefixes to completely disable
@@ -1390,7 +1473,7 @@ bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files,
// Load the expected package prefixes, if available, to validate against.
std::map<TProtoStringType, TProtoStringType> expected_package_prefixes;
- if (!LoadExpectedPackagePrefixes(generation_options,
+ if (!LoadExpectedPackagePrefixes(generation_options.expected_prefixes_path,
&expected_package_prefixes,
out_error)) {
return false;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
index 28acf4affd..afbf34b7ad 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
@@ -47,6 +47,10 @@ namespace protobuf {
namespace compiler {
namespace objectivec {
+// Get/Set the path to a file to load for objc class prefix lookups.
+TProtoStringType PROTOC_EXPORT GetPackageToPrefixMappingsPath();
+void PROTOC_EXPORT SetPackageToPrefixMappingsPath(
+ const TProtoStringType& file_path);
// Get/Set if the proto package should be used to make the default prefix for
// symbols. This will then impact most of the type naming apis below. It is done
// as a global to not break any other generator reusing the methods since they
@@ -54,20 +58,18 @@ namespace objectivec {
bool PROTOC_EXPORT UseProtoPackageAsDefaultPrefix();
void PROTOC_EXPORT SetUseProtoPackageAsDefaultPrefix(bool on_or_off);
// Get/Set the path to a file to load as exceptions when
-// `UseProtoPackageAsDefaultPrefixUseProtoPackageAsDefaultPrefix()` is `true`.
-// And empty string means there should be no exceptions loaded.
+// `UseProtoPackageAsDefaultPrefix()` is `true`. An empty string means there
+// should be no exceptions.
TProtoStringType PROTOC_EXPORT GetProtoPackagePrefixExceptionList();
void PROTOC_EXPORT SetProtoPackagePrefixExceptionList(
const TProtoStringType& file_path);
-// Generator options (see objectivec_generator.cc for a description of each):
+// Generator Prefix Validation Options (see objectivec_generator.cc for a
+// description of each):
struct Options {
Options();
TProtoStringType expected_prefixes_path;
std::vector<TProtoStringType> expected_prefixes_suppressions;
- TProtoStringType generate_for_named_framework;
- TProtoStringType named_framework_to_proto_path_mappings_path;
- TProtoStringType runtime_import_prefix;
bool prefixes_must_be_registered;
bool require_prefixes;
};
@@ -251,7 +253,11 @@ IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);
// and the result is false.
bool PROTOC_EXPORT ValidateObjCClassPrefixes(
const std::vector<const FileDescriptor*>& files,
- const Options& generation_options, TProtoStringType* out_error);
+ const Options& validation_options, TProtoStringType* out_error);
+// Same was the other ValidateObjCClassPrefixes() calls, but the options all
+// come from the environment variables.
+bool PROTOC_EXPORT ValidateObjCClassPrefixes(
+ const std::vector<const FileDescriptor*>& files, TProtoStringType* out_error);
// Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform
// the input into the expected output.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
index ed21b6526c..933f0ce73d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
@@ -81,14 +81,13 @@ const char* MapEntryTypeName(const FieldDescriptor* descriptor, bool isKey) {
} // namespace
-MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : RepeatedFieldGenerator(descriptor, options) {
+MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor)
+ : RepeatedFieldGenerator(descriptor) {
const FieldDescriptor* key_descriptor =
descriptor->message_type()->map_key();
const FieldDescriptor* value_descriptor =
descriptor->message_type()->map_value();
- value_field_generator_.reset(FieldGenerator::Make(value_descriptor, options));
+ value_field_generator_.reset(FieldGenerator::Make(value_descriptor));
// Pull over some variables_ from the value.
variables_["field_type"] = value_field_generator_->variable("field_type");
@@ -153,7 +152,7 @@ void MapFieldGenerator::FinishInitialization(void) {
// Use the array_comment support in RepeatedFieldGenerator to output what the
// values in the map are.
const FieldDescriptor* value_descriptor =
- descriptor_->message_type()->FindFieldByName("value");
+ descriptor_->message_type()->map_value();
if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_ENUM) {
variables_["array_comment"] =
"// |" + variables_["name"] + "| values are |" + value_field_generator_->variable("storage_type") + "|\n";
@@ -161,11 +160,19 @@ void MapFieldGenerator::FinishInitialization(void) {
}
void MapFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const {
- RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls);
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const {
+ RepeatedFieldGenerator::DetermineForwardDeclarations(
+ fwd_decls, include_external_types);
const FieldDescriptor* value_descriptor =
- descriptor_->message_type()->FindFieldByName("value");
- if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE) {
+ descriptor_->message_type()->map_value();
+ // Within a file there is no requirement on the order of the messages, so
+ // local references need a forward declaration. External files (not WKTs),
+ // need one when requested.
+ if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE &&
+ ((include_external_types &&
+ !IsProtobufLibraryBundledProtoFile(value_descriptor->file())) ||
+ descriptor_->file() == value_descriptor->file())) {
const TProtoStringType& value_storage_type =
value_field_generator_->variable("storage_type");
fwd_decls->insert("@class " + value_storage_type);
@@ -176,7 +183,7 @@ void MapFieldGenerator::DetermineObjectiveCClassDefinitions(
std::set<TProtoStringType>* fwd_decls) const {
// Class name is already in "storage_type".
const FieldDescriptor* value_descriptor =
- descriptor_->message_type()->FindFieldByName("value");
+ descriptor_->message_type()->map_value();
if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE) {
fwd_decls->insert(ObjCClassDeclaration(
value_field_generator_->variable("storage_type")));
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
index fd2b466dcc..2ec2e43435 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
@@ -41,8 +41,7 @@ namespace compiler {
namespace objectivec {
class MapFieldGenerator : public RepeatedFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
public:
virtual void FinishInitialization(void) override;
@@ -51,13 +50,14 @@ class MapFieldGenerator : public RepeatedFieldGenerator {
MapFieldGenerator& operator=(const MapFieldGenerator&) = delete;
protected:
- MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
+ MapFieldGenerator(const FieldDescriptor* descriptor);
virtual ~MapFieldGenerator();
virtual void DetermineObjectiveCClassDefinitions(
std::set<TProtoStringType>* fwd_decls) const override;
virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const override;
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
private:
std::unique_ptr<FieldGenerator> value_field_generator_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
index 39f8fd50fb..ab5b29628f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
@@ -171,11 +171,10 @@ const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {
} // namespace
MessageGenerator::MessageGenerator(const TProtoStringType& root_classname,
- const Descriptor* descriptor,
- const Options& options)
+ const Descriptor* descriptor)
: root_classname_(root_classname),
descriptor_(descriptor),
- field_generators_(descriptor, options),
+ field_generators_(descriptor),
class_name_(ClassName(descriptor_)),
deprecated_attribute_(GetOptionalDeprecatedAttribute(
descriptor, descriptor->file(), false, true)) {
@@ -197,8 +196,7 @@ MessageGenerator::MessageGenerator(const TProtoStringType& root_classname,
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
MessageGenerator* generator =
new MessageGenerator(root_classname_,
- descriptor_->nested_type(i),
- options);
+ descriptor_->nested_type(i));
nested_message_generators_.emplace_back(generator);
}
}
@@ -217,17 +215,18 @@ void MessageGenerator::GenerateStaticVariablesInitialization(
}
void MessageGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) {
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) {
if (!IsMapEntryMessage(descriptor_)) {
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* fieldDescriptor = descriptor_->field(i);
field_generators_.get(fieldDescriptor)
- .DetermineForwardDeclarations(fwd_decls);
+ .DetermineForwardDeclarations(fwd_decls, include_external_types);
}
}
for (const auto& generator : nested_message_generators_) {
- generator->DetermineForwardDeclarations(fwd_decls);
+ generator->DetermineForwardDeclarations(fwd_decls, include_external_types);
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h
index a55351b1a2..71eec0d0c7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h
@@ -35,7 +35,6 @@
#include <set>
#include <vector>
#include <google/protobuf/compiler/objectivec/objectivec_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
#include <google/protobuf/compiler/objectivec/objectivec_oneof.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/printer.h>
@@ -51,7 +50,7 @@ class EnumGenerator;
class MessageGenerator {
public:
MessageGenerator(const TProtoStringType& root_classname,
- const Descriptor* descriptor, const Options& options);
+ const Descriptor* descriptor);
~MessageGenerator();
MessageGenerator(const MessageGenerator&) = delete;
@@ -63,7 +62,8 @@ class MessageGenerator {
void GenerateSource(io::Printer* printer);
void GenerateExtensionRegistrationSource(io::Printer* printer);
void DetermineObjectiveCClassDefinitions(std::set<TProtoStringType>* fwd_decls);
- void DetermineForwardDeclarations(std::set<TProtoStringType>* fwd_decls);
+ void DetermineForwardDeclarations(std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types);
// Checks if the message or a nested message includes a oneof definition.
bool IncludesOneOfDefinition() const;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
index f26bbc8de5..828b75c868 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
@@ -58,19 +58,27 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
} // namespace
-MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : ObjCObjFieldGenerator(descriptor, options) {
+MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor)
+ : ObjCObjFieldGenerator(descriptor) {
SetMessageVariables(descriptor, &variables_);
}
MessageFieldGenerator::~MessageFieldGenerator() {}
void MessageFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const {
- ObjCObjFieldGenerator::DetermineForwardDeclarations(fwd_decls);
- // Class name is already in "storage_type".
- fwd_decls->insert("@class " + variable("storage_type"));
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const {
+ ObjCObjFieldGenerator::DetermineForwardDeclarations(
+ fwd_decls, include_external_types);
+ // Within a file there is no requirement on the order of the messages, so
+ // local references need a forward declaration. External files (not WKTs),
+ // need one when requested.
+ if ((include_external_types &&
+ !IsProtobufLibraryBundledProtoFile(descriptor_->message_type()->file())) ||
+ descriptor_->file() == descriptor_->message_type()->file()) {
+ // Class name is already in "storage_type".
+ fwd_decls->insert("@class " + variable("storage_type"));
+ }
}
void MessageFieldGenerator::DetermineObjectiveCClassDefinitions(
@@ -79,8 +87,8 @@ void MessageFieldGenerator::DetermineObjectiveCClassDefinitions(
}
RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : RepeatedFieldGenerator(descriptor, options) {
+ const FieldDescriptor* descriptor)
+ : RepeatedFieldGenerator(descriptor) {
SetMessageVariables(descriptor, &variables_);
variables_["array_storage_type"] = "NSMutableArray";
variables_["array_property_type"] =
@@ -90,10 +98,19 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
void RepeatedMessageFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const {
- RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls);
- // Class name is already in "storage_type".
- fwd_decls->insert("@class " + variable("storage_type"));
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const {
+ RepeatedFieldGenerator::DetermineForwardDeclarations(
+ fwd_decls, include_external_types);
+ // Within a file there is no requirement on the order of the messages, so
+ // local references need a forward declaration. External files (not WKTs),
+ // need one when requested.
+ if ((include_external_types &&
+ !IsProtobufLibraryBundledProtoFile(descriptor_->message_type()->file())) ||
+ descriptor_->file() == descriptor_->message_type()->file()) {
+ // Class name is already in "storage_type".
+ fwd_decls->insert("@class " + variable("storage_type"));
+ }
}
void RepeatedMessageFieldGenerator::DetermineObjectiveCClassDefinitions(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
index 8897c9b7b6..44b5aabcfd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
@@ -41,12 +41,10 @@ namespace compiler {
namespace objectivec {
class MessageFieldGenerator : public ObjCObjFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- MessageFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ MessageFieldGenerator(const FieldDescriptor* descriptor);
MessageFieldGenerator(const MessageFieldGenerator&) = delete;
MessageFieldGenerator& operator=(const MessageFieldGenerator&) = delete;
@@ -55,18 +53,17 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator {
public:
virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const override;
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
virtual void DetermineObjectiveCClassDefinitions(
std::set<TProtoStringType>* fwd_decls) const override;
};
class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor);
virtual ~RepeatedMessageFieldGenerator();
RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete;
@@ -74,7 +71,8 @@ class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
public:
virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls) const override;
+ std::set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
virtual void DetermineObjectiveCClassDefinitions(
std::set<TProtoStringType>* fwd_decls) const override;
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
index 767068107a..c8233b1441 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
@@ -125,8 +125,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
} // namespace
PrimitiveFieldGenerator::PrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : SingleFieldGenerator(descriptor, options) {
+ const FieldDescriptor* descriptor)
+ : SingleFieldGenerator(descriptor) {
SetPrimitiveVariables(descriptor, &variables_);
}
@@ -159,8 +159,8 @@ void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) {
}
PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : ObjCObjFieldGenerator(descriptor, options) {
+ const FieldDescriptor* descriptor)
+ : ObjCObjFieldGenerator(descriptor) {
SetPrimitiveVariables(descriptor, &variables_);
variables_["property_storage_attribute"] = "copy";
}
@@ -168,8 +168,8 @@ PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator(
PrimitiveObjFieldGenerator::~PrimitiveObjFieldGenerator() {}
RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : RepeatedFieldGenerator(descriptor, options) {
+ const FieldDescriptor* descriptor)
+ : RepeatedFieldGenerator(descriptor) {
SetPrimitiveVariables(descriptor, &variables_);
TProtoStringType base_name = PrimitiveArrayTypeName(descriptor);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
index a9f30f6419..291d11a2e3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
@@ -41,12 +41,10 @@ namespace compiler {
namespace objectivec {
class PrimitiveFieldGenerator : public SingleFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ PrimitiveFieldGenerator(const FieldDescriptor* descriptor);
virtual ~PrimitiveFieldGenerator();
PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete;
@@ -59,12 +57,10 @@ class PrimitiveFieldGenerator : public SingleFieldGenerator {
};
class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor);
virtual ~PrimitiveObjFieldGenerator();
PrimitiveObjFieldGenerator(const PrimitiveObjFieldGenerator&) = delete;
@@ -73,12 +69,10 @@ class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
};
class RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator {
- friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,
- const Options& options);
+ friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
+ RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor);
virtual ~RepeatedPrimitiveFieldGenerator();
RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) =
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
index 335edcf30c..332556e9c4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
@@ -46,11 +46,11 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/tokenizer.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/hash.h>
@@ -180,9 +180,9 @@ bool IsNumberFollowUnderscore(const TProtoStringType& name) {
// ===================================================================
Parser::Parser()
- : input_(NULL),
- error_collector_(NULL),
- source_location_table_(NULL),
+ : input_(nullptr),
+ error_collector_(nullptr),
+ source_location_table_(nullptr),
had_errors_(false),
require_syntax_identifier_(false),
stop_after_syntax_identifier_(false) {
@@ -221,12 +221,8 @@ bool Parser::Consume(const char* text, const char* error) {
}
bool Parser::Consume(const char* text) {
- if (TryConsume(text)) {
- return true;
- } else {
- AddError("Expected \"" + TProtoStringType(text) + "\".");
- return false;
- }
+ TProtoStringType error = "Expected \"" + TProtoStringType(text) + "\".";
+ return Consume(text, error.c_str());
}
bool Parser::ConsumeIdentifier(TProtoStringType* output, const char* error) {
@@ -347,7 +343,7 @@ bool Parser::TryConsumeEndOfDeclaration(const char* text,
// from last time.
leading.swap(upcoming_doc_comments_);
- if (location != NULL) {
+ if (location != nullptr) {
upcoming_detached_comments_.swap(detached);
location->AttachComments(&leading, &trailing, &detached);
} else if (strcmp(text, "}") == 0) {
@@ -380,7 +376,7 @@ bool Parser::ConsumeEndOfDeclaration(const char* text,
// -------------------------------------------------------------------
void Parser::AddError(int line, int column, const TProtoStringType& error) {
- if (error_collector_ != NULL) {
+ if (error_collector_ != nullptr) {
error_collector_->AddError(line, column, error);
}
had_errors_ = true;
@@ -473,7 +469,7 @@ void Parser::LocationRecorder::EndAt(const io::Tokenizer::Token& token) {
void Parser::LocationRecorder::RecordLegacyLocation(
const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location) {
- if (parser_->source_location_table_ != NULL) {
+ if (parser_->source_location_table_ != nullptr) {
parser_->source_location_table_->Add(
descriptor, location, location_->span(0), location_->span(1));
}
@@ -516,7 +512,7 @@ void Parser::SkipStatement() {
if (AtEnd()) {
return;
} else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
+ if (TryConsumeEndOfDeclaration(";", nullptr)) {
return;
} else if (TryConsume("{")) {
SkipRestOfBlock();
@@ -534,7 +530,7 @@ void Parser::SkipRestOfBlock() {
if (AtEnd()) {
return;
} else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {
- if (TryConsumeEndOfDeclaration("}", NULL)) {
+ if (TryConsumeEndOfDeclaration("}", nullptr)) {
return;
} else if (TryConsume("{")) {
SkipRestOfBlock();
@@ -628,7 +624,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
if (LookingAtType(io::Tokenizer::TYPE_START)) {
// Advance to first token.
- input_->NextWithComments(NULL, &upcoming_detached_comments_,
+ input_->NextWithComments(nullptr, &upcoming_detached_comments_,
&upcoming_doc_comments_);
}
@@ -644,7 +640,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
return false;
}
// Store the syntax into the file.
- if (file != NULL) file->set_syntax(syntax_identifier_);
+ if (file != nullptr) file->set_syntax(syntax_identifier_);
} else if (!stop_after_syntax_identifier_) {
syntax_identifier_ = "proto2";
}
@@ -660,16 +656,16 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
if (LookingAt("}")) {
AddError("Unmatched \"}\".");
- input_->NextWithComments(NULL, &upcoming_detached_comments_,
+ input_->NextWithComments(nullptr, &upcoming_detached_comments_,
&upcoming_doc_comments_);
}
}
}
}
- input_ = NULL;
- source_code_info_ = NULL;
- assert(file != NULL);
+ input_ = nullptr;
+ source_code_info_ = nullptr;
+ assert(file != nullptr);
source_code_info.Swap(file->mutable_source_code_info());
return !had_errors_;
}
@@ -702,7 +698,7 @@ bool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) {
bool Parser::ParseTopLevelStatement(FileDescriptorProto* file,
const LocationRecorder& root_location) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
+ if (TryConsumeEndOfDeclaration(";", nullptr)) {
// empty statement; ignore
return true;
} else if (LookingAt("message")) {
@@ -858,7 +854,7 @@ bool Parser::ParseMessageBlock(DescriptorProto* message,
const FileDescriptorProto* containing_file) {
DO(ConsumeEndOfDeclaration("{", &message_location));
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
AddError("Reached end of input in message definition (missing '}').");
return false;
@@ -883,7 +879,7 @@ bool Parser::ParseMessageBlock(DescriptorProto* message,
bool Parser::ParseMessageStatement(DescriptorProto* message,
const LocationRecorder& message_location,
const FileDescriptorProto* containing_file) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
+ if (TryConsumeEndOfDeclaration(";", nullptr)) {
// empty statement; ignore
return true;
} else if (LookingAt("message")) {
@@ -941,7 +937,7 @@ bool Parser::ParseMessageField(FieldDescriptorProto* field,
const FileDescriptorProto* containing_file) {
{
FieldDescriptorProto::Label label;
- if (ParseLabel(&label, field_location, containing_file)) {
+ if (ParseLabel(&label, field_location)) {
field->set_label(label);
if (label == FieldDescriptorProto::LABEL_OPTIONAL &&
syntax_identifier_ == "proto3") {
@@ -1454,7 +1450,7 @@ bool Parser::ParseOption(Message* options,
// Create an entry in the uninterpreted_option field.
const FieldDescriptor* uninterpreted_option_field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option");
- GOOGLE_CHECK(uninterpreted_option_field != NULL)
+ GOOGLE_CHECK(uninterpreted_option_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto.";
const Reflection* reflection = options->GetReflection();
@@ -1902,7 +1898,7 @@ bool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
// other statements.
SkipStatement();
}
- } while (!TryConsumeEndOfDeclaration("}", NULL));
+ } while (!TryConsumeEndOfDeclaration("}", nullptr));
return true;
}
@@ -1966,7 +1962,7 @@ bool Parser::ParseOneof(OneofDescriptorProto* oneof_decl,
// other statements.
SkipStatement();
}
- } while (!TryConsumeEndOfDeclaration("}", NULL));
+ } while (!TryConsumeEndOfDeclaration("}", nullptr));
return true;
}
@@ -1999,7 +1995,7 @@ bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type,
const FileDescriptorProto* containing_file) {
DO(ConsumeEndOfDeclaration("{", &enum_location));
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
AddError("Reached end of input in enum definition (missing '}').");
return false;
@@ -2018,7 +2014,7 @@ bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type,
bool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type,
const LocationRecorder& enum_location,
const FileDescriptorProto* containing_file) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
+ if (TryConsumeEndOfDeclaration(";", nullptr)) {
// empty statement; ignore
return true;
} else if (LookingAt("option")) {
@@ -2116,7 +2112,7 @@ bool Parser::ParseServiceBlock(ServiceDescriptorProto* service,
const FileDescriptorProto* containing_file) {
DO(ConsumeEndOfDeclaration("{", &service_location));
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
AddError("Reached end of input in service definition (missing '}').");
return false;
@@ -2135,7 +2131,7 @@ bool Parser::ParseServiceBlock(ServiceDescriptorProto* service,
bool Parser::ParseServiceStatement(ServiceDescriptorProto* service,
const LocationRecorder& service_location,
const FileDescriptorProto* containing_file) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
+ if (TryConsumeEndOfDeclaration(";", nullptr)) {
// empty statement; ignore
return true;
} else if (LookingAt("option")) {
@@ -2173,7 +2169,6 @@ bool Parser::ParseServiceMethod(MethodDescriptorProto* method,
DescriptorPool::ErrorCollector::OTHER);
method->set_client_streaming(true);
DO(Consume("stream"));
-
}
LocationRecorder location(method_location,
MethodDescriptorProto::kInputTypeFieldNumber);
@@ -2194,7 +2189,6 @@ bool Parser::ParseServiceMethod(MethodDescriptorProto* method,
DescriptorPool::ErrorCollector::OTHER);
DO(Consume("stream"));
method->set_server_streaming(true);
-
}
LocationRecorder location(method_location,
MethodDescriptorProto::kOutputTypeFieldNumber);
@@ -2222,13 +2216,13 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
Message* mutable_options) {
// Options!
ConsumeEndOfDeclaration("{", &parent_location);
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
AddError("Reached end of input in method options (missing '}').");
return false;
}
- if (TryConsumeEndOfDeclaration(";", NULL)) {
+ if (TryConsumeEndOfDeclaration(";", nullptr)) {
// empty statement; ignore
} else {
LocationRecorder location(parent_location, optionsFieldNumber);
@@ -2247,8 +2241,7 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
// -------------------------------------------------------------------
bool Parser::ParseLabel(FieldDescriptorProto::Label* label,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file) {
+ const LocationRecorder& field_location) {
if (!LookingAt("optional") && !LookingAt("repeated") &&
!LookingAt("required")) {
return false;
@@ -2392,7 +2385,7 @@ bool SourceLocationTable::Find(
int* column) const {
const std::pair<int, int>* result =
FindOrNull(location_map_, std::make_pair(descriptor, location));
- if (result == NULL) {
+ if (result == nullptr) {
*line = -1;
*column = 0;
return false;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
index 0a1bfc6827..f60a97c44c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
@@ -42,9 +42,9 @@
#include <string>
#include <utility>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/tokenizer.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/repeated_field.h>
// Must be included last.
@@ -281,9 +281,6 @@ class PROTOBUF_EXPORT Parser {
std::vector<TProtoStringType>* detached_comments) const;
private:
- // Indexes of parent and current location in the parent
- // SourceCodeInfo.location repeated field. For top-level elements,
- // parent_index_ is -1.
Parser* parser_;
SourceCodeInfo* source_code_info_;
SourceCodeInfo::Location* location_;
@@ -434,7 +431,6 @@ class PROTOBUF_EXPORT Parser {
const LocationRecorder& method_location,
const FileDescriptorProto* containing_file);
-
// Parse options of a single method or stream.
bool ParseMethodOptions(const LocationRecorder& parent_location,
const FileDescriptorProto* containing_file,
@@ -444,8 +440,7 @@ class PROTOBUF_EXPORT Parser {
// Parse "required", "optional", or "repeated" and fill in "label"
// with the value. Returns true if such a label is consumed.
bool ParseLabel(FieldDescriptorProto::Label* label,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
+ const LocationRecorder& field_location);
// Parse a type name and fill in "type" (if it is a primitive) or
// "type_name" (if it is not) with the type parsed.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc
index 03aca43b04..b06200a986 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc
@@ -50,28 +50,29 @@ const TProtoStringType kDescriptorMetadataFile =
const TProtoStringType kDescriptorDirName = "Google/Protobuf/Internal";
const TProtoStringType kDescriptorPackageName = "Google\\Protobuf\\Internal";
const char* const kReservedNames[] = {
- "abstract", "and", "array", "as", "break",
- "callable", "case", "catch", "class", "clone",
- "const", "continue", "declare", "default", "die",
- "do", "echo", "else", "elseif", "empty",
- "enddeclare", "endfor", "endforeach", "endif", "endswitch",
- "endwhile", "eval", "exit", "extends", "final",
- "finally", "fn", "for", "foreach", "function",
- "global", "goto", "if", "implements", "include",
- "include_once", "instanceof", "insteadof", "interface", "isset",
- "list", "match", "namespace", "new", "or",
- "print", "private", "protected", "public", "require",
- "require_once", "return", "static", "switch", "throw",
- "trait", "try", "unset", "use", "var",
- "while", "xor", "yield", "int", "float",
- "bool", "string", "true", "false", "null",
- "void", "iterable"};
+ "abstract", "and", "array", "as", "break",
+ "callable", "case", "catch", "class", "clone",
+ "const", "continue", "declare", "default", "die",
+ "do", "echo", "else", "elseif", "empty",
+ "enddeclare", "endfor", "endforeach", "endif", "endswitch",
+ "endwhile", "eval", "exit", "extends", "final",
+ "finally", "fn", "for", "foreach", "function",
+ "global", "goto", "if", "implements", "include",
+ "include_once", "instanceof", "insteadof", "interface", "isset",
+ "list", "match", "namespace", "new", "or",
+ "parent", "print", "private", "protected", "public",
+ "require", "require_once", "return", "self", "static",
+ "switch", "throw", "trait", "try", "unset",
+ "use", "var", "while", "xor", "yield",
+ "int", "float", "bool", "string", "true",
+ "false", "null", "void", "iterable"};
const char* const kValidConstantNames[] = {
"int", "float", "bool", "string", "true",
- "false", "null", "void", "iterable",
+ "false", "null", "void", "iterable", "parent",
+ "self"
};
-const int kReservedNamesSize = 77;
-const int kValidConstantNamesSize = 9;
+const int kReservedNamesSize = 79;
+const int kValidConstantNamesSize = 11;
const int kFieldSetter = 1;
const int kFieldGetter = 2;
const int kFieldProperty = 3;
@@ -85,14 +86,14 @@ struct Options {
bool is_descriptor = false;
bool aggregate_metadata = false;
bool gen_c_wkt = false;
- std::set<string> aggregate_metadata_prefixes;
+ std::set<TProtoStringType> aggregate_metadata_prefixes;
};
namespace {
// Forward decls.
TProtoStringType PhpName(const TProtoStringType& full_name, const Options& options);
-TProtoStringType IntToString(int32 value);
+TProtoStringType IntToString(arc_i32 value);
TProtoStringType FilenameToClassname(const TProtoStringType& filename);
TProtoStringType GeneratedMetadataFileName(const FileDescriptor* file,
const Options& options);
@@ -432,7 +433,7 @@ TProtoStringType GeneratedServiceFileName(const ServiceDescriptor* service,
return result + ".php";
}
-TProtoStringType IntToString(int32 value) {
+TProtoStringType IntToString(arc_i32 value) {
std::ostringstream os;
os << value;
return TProtoStringType{os.str()};
@@ -743,8 +744,8 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options,
// Type check.
if (field->is_map()) {
const Descriptor* map_entry = field->message_type();
- const FieldDescriptor* key = map_entry->FindFieldByName("key");
- const FieldDescriptor* value = map_entry->FindFieldByName("value");
+ const FieldDescriptor* key = map_entry->map_key();
+ const FieldDescriptor* value = map_entry->map_value();
printer->Print(
"$arr = GPBUtil::checkMapField($var, "
"\\Google\\Protobuf\\Internal\\GPBType::^key_type^, "
@@ -891,9 +892,9 @@ void GenerateMessageToPool(const TProtoStringType& name_prefix,
const FieldDescriptor* field = message->field(i);
if (field->is_map()) {
const FieldDescriptor* key =
- field->message_type()->FindFieldByName("key");
+ field->message_type()->map_key();
const FieldDescriptor* val =
- field->message_type()->FindFieldByName("value");
+ field->message_type()->map_value();
printer->Print(
"->map('^field^', \\Google\\Protobuf\\Internal\\GPBType::^key^, "
"\\Google\\Protobuf\\Internal\\GPBType::^value^, ^number^^other^)\n",
@@ -1116,7 +1117,7 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options,
std::map<const FileDescriptor*, int> dependency_count;
std::set<const FileDescriptor*> nodes_without_dependency;
FileDescriptorSet sorted_file_set;
-
+
AnalyzeDependencyForFile(
file, &nodes_without_dependency, &deps, &dependency_count);
@@ -1871,44 +1872,45 @@ void GenerateCEnum(const EnumDescriptor* desc, io::Printer* printer) {
"\n"
"PHP_METHOD($c_name$, name) {\n"
" $file_c_name$_AddDescriptor();\n"
- " const upb_symtab *symtab = DescriptorPool_GetSymbolTable();\n"
- " const upb_enumdef *e = upb_symtab_lookupenum(symtab, \"$name$\");\n"
- " const char *name;\n"
+ " const upb_DefPool *symtab = DescriptorPool_GetSymbolTable();\n"
+ " const upb_EnumDef *e = upb_DefPool_FindEnumByName(symtab, \"$name$\");\n"
" zend_long value;\n"
" if (zend_parse_parameters(ZEND_NUM_ARGS(), \"l\", &value) ==\n"
" FAILURE) {\n"
" return;\n"
" }\n"
- " name = upb_enumdef_iton(e, value);\n"
- " if (!name) {\n"
+ " const upb_EnumValueDef* ev =\n"
+ " upb_EnumDef_FindValueByNumber(e, value);\n"
+ " if (!ev) {\n"
" zend_throw_exception_ex(NULL, 0,\n"
" \"$php_name$ has no name \"\n"
" \"defined for value \" ZEND_LONG_FMT \".\",\n"
" value);\n"
" return;\n"
" }\n"
- " RETURN_STRING(name);\n"
+ " RETURN_STRING(upb_EnumValueDef_Name(ev));\n"
"}\n"
"\n"
"PHP_METHOD($c_name$, value) {\n"
" $file_c_name$_AddDescriptor();\n"
- " const upb_symtab *symtab = DescriptorPool_GetSymbolTable();\n"
- " const upb_enumdef *e = upb_symtab_lookupenum(symtab, \"$name$\");\n"
+ " const upb_DefPool *symtab = DescriptorPool_GetSymbolTable();\n"
+ " const upb_EnumDef *e = upb_DefPool_FindEnumByName(symtab, \"$name$\");\n"
" char *name = NULL;\n"
" size_t name_len;\n"
- " arc_i32 num;\n"
" if (zend_parse_parameters(ZEND_NUM_ARGS(), \"s\", &name,\n"
" &name_len) == FAILURE) {\n"
" return;\n"
" }\n"
- " if (!upb_enumdef_ntoi(e, name, name_len, &num)) {\n"
+ " const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNameWithSize(\n"
+ " e, name, name_len);\n"
+ " if (!ev) {\n"
" zend_throw_exception_ex(NULL, 0,\n"
" \"$php_name$ has no value \"\n"
" \"defined for name %s.\",\n"
" name);\n"
" return;\n"
" }\n"
- " RETURN_LONG(num);\n"
+ " RETURN_LONG(upb_EnumValueDef_Number(ev));\n"
"}\n"
"\n"
"static zend_function_entry $c_name$_phpmethods[] = {\n"
@@ -1967,8 +1969,8 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) {
printer->Print(
"static PHP_METHOD($c_name$, get$camel_name$) {\n"
" Message* intern = (Message*)Z_OBJ_P(getThis());\n"
- " const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,\n"
- " \"$name$\");\n"
+ " const upb_FieldDef *f = upb_MessageDef_FindFieldByName(\n"
+ " intern->desc->msgdef, \"$name$\");\n"
" zval ret;\n"
" Message_get(intern, f, &ret);\n"
" RETURN_COPY_VALUE(&ret);\n"
@@ -1976,8 +1978,8 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) {
"\n"
"static PHP_METHOD($c_name$, set$camel_name$) {\n"
" Message* intern = (Message*)Z_OBJ_P(getThis());\n"
- " const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,\n"
- " \"$name$\");\n"
+ " const upb_FieldDef *f = upb_MessageDef_FindFieldByName(\n"
+ " intern->desc->msgdef, \"$name$\");\n"
" zval *val;\n"
" if (zend_parse_parameters(ZEND_NUM_ARGS(), \"z\", &val)\n"
" == FAILURE) {\n"
@@ -1997,10 +1999,11 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) {
printer->Print(
"static PHP_METHOD($c_name$, get$camel_name$) {\n"
" Message* intern = (Message*)Z_OBJ_P(getThis());\n"
- " const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef,\n"
- " \"$name$\");\n"
- " const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof);\n"
- " RETURN_STRING(field ? upb_fielddef_name(field) : \"\");\n"
+ " const upb_OneofDef *oneof = upb_MessageDef_FindOneofByName(\n"
+ " intern->desc->msgdef, \"$name$\");\n"
+ " const upb_FieldDef *field = \n"
+ " upb_Message_WhichOneof(intern->msg, oneof);\n"
+ " RETURN_STRING(field ? upb_FieldDef_Name(field) : \"\");\n"
"}\n",
"c_name", c_name,
"name", oneof->name(),
@@ -2067,7 +2070,7 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) {
break;
default:
break;
- }
+ }
printer->Print(
" ZEND_FE_END\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
index 3d51e1e1cd..2d7fc6fcb5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
@@ -68,7 +68,7 @@ class GeneratorResponseContext : public GeneratorContext {
: compiler_version_(compiler_version),
response_(response),
parsed_files_(parsed_files) {}
- virtual ~GeneratorResponseContext() {}
+ ~GeneratorResponseContext() override {}
// implements GeneratorContext --------------------------------------
@@ -117,7 +117,7 @@ bool GenerateCode(const CodeGeneratorRequest& request,
DescriptorPool pool;
for (int i = 0; i < request.proto_file_size(); i++) {
const FileDescriptor* file = pool.BuildFile(request.proto_file(i));
- if (file == NULL) {
+ if (file == nullptr) {
// BuildFile() already wrote an error message.
return false;
}
@@ -126,7 +126,7 @@ bool GenerateCode(const CodeGeneratorRequest& request,
std::vector<const FileDescriptor*> parsed_files;
for (int i = 0; i < request.file_to_generate_size(); i++) {
parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i)));
- if (parsed_files.back() == NULL) {
+ if (parsed_files.back() == nullptr) {
*error_msg =
"protoc asked plugin to generate a file but "
"did not provide a descriptor for the file: " +
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
index efbf9e8707..65af26e0f7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
@@ -65,6 +65,7 @@
#include <string>
#include <google/protobuf/stubs/port.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
index 6370bf1fb1..34126b9d9a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
@@ -16,72 +16,76 @@
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
+
+namespace _pb = ::PROTOBUF_NAMESPACE_ID;
+namespace _pbi = _pb::internal;
+
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
-constexpr Version::Version(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : suffix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_CONSTEXPR Version::Version(
+ ::_pbi::ConstantInitialized)
+ : suffix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, major_(0)
, minor_(0)
, patch_(0){}
struct VersionDefaultTypeInternal {
- constexpr VersionDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR VersionDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~VersionDefaultTypeInternal() {}
union {
Version _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT VersionDefaultTypeInternal _Version_default_instance_;
-constexpr CodeGeneratorRequest::CodeGeneratorRequest(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_;
+PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(
+ ::_pbi::ConstantInitialized)
: file_to_generate_()
, proto_file_()
- , parameter_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , parameter_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, compiler_version_(nullptr){}
struct CodeGeneratorRequestDefaultTypeInternal {
- constexpr CodeGeneratorRequestDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorRequestDefaultTypeInternal() {}
union {
CodeGeneratorRequest _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
-constexpr CodeGeneratorResponse_File::CodeGeneratorResponse_File(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
- : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , insertion_point_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
- , content_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
+PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(
+ ::_pbi::ConstantInitialized)
+ : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , insertion_point_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
+ , content_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, generated_code_info_(nullptr){}
struct CodeGeneratorResponse_FileDefaultTypeInternal {
- constexpr CodeGeneratorResponse_FileDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponse_FileDefaultTypeInternal() {}
union {
CodeGeneratorResponse_File _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
-constexpr CodeGeneratorResponse::CodeGeneratorResponse(
- ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
+PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(
+ ::_pbi::ConstantInitialized)
: file_()
- , error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
+ , error_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, supported_features_(arc_ui64{0u}){}
struct CodeGeneratorResponseDefaultTypeInternal {
- constexpr CodeGeneratorResponseDefaultTypeInternal()
- : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal()
+ : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponseDefaultTypeInternal() {}
union {
CodeGeneratorResponse _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
-static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4];
-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;
+static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4];
+static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1];
+static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _has_bits_),
@@ -139,18 +143,18 @@ const arc_ui32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offset
1,
~0u,
};
-static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 10, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)},
{ 14, 24, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)},
{ 28, 38, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)},
{ 42, 51, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)},
};
-static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_),
- reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_),
+static const ::_pb::Message* const file_default_instances[] = {
+ &::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_._instance,
};
const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
@@ -175,22 +179,24 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2epro
"uginProtosZ)google.golang.org/protobuf/t"
"ypes/pluginpb"
;
-static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = {
+static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = {
&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto,
};
-static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once;
-const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = {
- false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto",
- &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4,
- schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets,
- file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
+static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once;
+const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = {
+ false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
+ "google/protobuf/compiler/plugin.proto",
+ &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4,
+ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets,
+ file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
+ file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
};
-PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() {
+PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() {
return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
-PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
+PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor() {
@@ -238,21 +244,18 @@ Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version)
}
Version::Version(const Version& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ suffix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_suffix()) {
- suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(),
+ suffix_.Set(from._internal_suffix(),
GetArenaForAllocation());
}
::memcpy(&major_, &from.major_,
@@ -262,9 +265,9 @@ Version::Version(const Version& from)
}
inline void Version::SharedCtor() {
-suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ suffix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)),
@@ -274,22 +277,18 @@ suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlrea
Version::~Version() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.Version)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void Version::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ suffix_.Destroy();
}
-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);
}
@@ -313,12 +312,12 @@ void Version::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 major = 1;
case 1:
@@ -351,11 +350,11 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
auto str = _internal_mutable_suffix();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.Version.suffix");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.Version.suffix");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -393,19 +392,19 @@ uint8_t* Version::_InternalSerialize(
// optional int32 major = 1;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_major(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_major(), target);
}
// optional int32 minor = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_minor(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_minor(), target);
}
// optional int32 patch = 3;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_patch(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_patch(), target);
}
// optional string suffix = 4;
@@ -419,7 +418,7 @@ uint8_t* Version::_InternalSerialize(
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -445,17 +444,17 @@ size_t Version::ByteSizeLong() const {
// optional int32 major = 1;
if (cached_has_bits & 0x00000002u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_major());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_major());
}
// optional int32 minor = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_minor());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_minor());
}
// optional int32 patch = 3;
if (cached_has_bits & 0x00000008u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_patch());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_patch());
}
}
@@ -518,7 +517,6 @@ void Version::InternalSwap(Version* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&suffix_, lhs_arena,
&other->suffix_, rhs_arena
);
@@ -531,7 +529,7 @@ void Version::InternalSwap(Version* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]);
}
@@ -563,9 +561,6 @@ CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena
file_to_generate_(arena),
proto_file_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
@@ -574,12 +569,12 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
file_to_generate_(from.file_to_generate_),
proto_file_(from.proto_file_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ parameter_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_parameter()) {
- parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(),
+ parameter_.Set(from._internal_parameter(),
GetArenaForAllocation());
}
if (from._internal_has_compiler_version()) {
@@ -591,32 +586,28 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
}
inline void CodeGeneratorRequest::SharedCtor() {
-parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ parameter_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
compiler_version_ = nullptr;
}
CodeGeneratorRequest::~CodeGeneratorRequest() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void CodeGeneratorRequest::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ parameter_.Destroy();
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);
}
@@ -643,12 +634,12 @@ void CodeGeneratorRequest::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated string file_to_generate = 1;
case 1:
@@ -657,11 +648,11 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM
do {
ptr += 1;
auto str = _internal_add_file_to_generate();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
#endif // !NDEBUG
- CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else
@@ -671,11 +662,11 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_parameter();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.parameter");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.parameter");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -753,22 +744,21 @@ uint8_t* CodeGeneratorRequest::_InternalSerialize(
// optional .google.protobuf.compiler.Version compiler_version = 3;
if (cached_has_bits & 0x00000002u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 3, _Internal::compiler_version(this), target, stream);
+ InternalWriteMessage(3, _Internal::compiler_version(this),
+ _Internal::compiler_version(this).GetCachedSize(), target, stream);
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_proto_file_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_proto_file_size()); i < n; i++) {
+ const auto& repfield = this->_internal_proto_file(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(15, this->_internal_proto_file(i), target, stream);
+ InternalWriteMessage(15, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -873,7 +863,6 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
file_to_generate_.InternalSwap(&other->file_to_generate_);
proto_file_.InternalSwap(&other->proto_file_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&parameter_, lhs_arena,
&other->parameter_, rhs_arena
);
@@ -881,7 +870,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]);
}
@@ -918,37 +907,34 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
+ name_.Set(from._internal_name(),
GetArenaForAllocation());
}
- insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ insertion_point_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_insertion_point()) {
- insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(),
+ insertion_point_.Set(from._internal_insertion_point(),
GetArenaForAllocation());
}
- content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ content_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_content()) {
- content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(),
+ content_.Set(from._internal_content(),
GetArenaForAllocation());
}
if (from._internal_has_generated_code_info()) {
@@ -960,42 +946,38 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
}
inline void CodeGeneratorResponse_File::SharedCtor() {
-name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ insertion_point_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ content_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
generated_code_info_ = nullptr;
}
CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void CodeGeneratorResponse_File::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
- content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ name_.Destroy();
+ insertion_point_.Destroy();
+ content_.Destroy();
if (this != internal_default_instance()) delete generated_code_info_;
}
-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);
}
@@ -1026,22 +1008,22 @@ void CodeGeneratorResponse_File::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.name");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.name");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1049,11 +1031,11 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_insertion_point();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1061,11 +1043,11 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
case 15:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) {
auto str = _internal_mutable_content();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.content");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.content");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1140,14 +1122,13 @@ uint8_t* CodeGeneratorResponse_File::_InternalSerialize(
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
if (cached_has_bits & 0x00000008u) {
- target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(
- 16, _Internal::generated_code_info(this), target, stream);
+ InternalWriteMessage(16, _Internal::generated_code_info(this),
+ _Internal::generated_code_info(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1251,17 +1232,14 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena,
&other->name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&insertion_point_, lhs_arena,
&other->insertion_point_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&content_, lhs_arena,
&other->content_, rhs_arena
);
@@ -1269,7 +1247,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]);
}
@@ -1292,9 +1270,6 @@ CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* are
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
file_(arena) {
SharedCtor();
- if (!is_message_owned) {
- RegisterArenaDtor(arena);
- }
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
@@ -1302,12 +1277,12 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
_has_bits_(from._has_bits_),
file_(from.file_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ error_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_error()) {
- error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(),
+ error_.Set(from._internal_error(),
GetArenaForAllocation());
}
supported_features_ = from.supported_features_;
@@ -1315,31 +1290,27 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
}
inline void CodeGeneratorResponse::SharedCtor() {
-error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ error_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
supported_features_ = arc_ui64{0u};
}
CodeGeneratorResponse::~CodeGeneratorResponse() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse)
- if (GetArenaForAllocation() != nullptr) return;
+ if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
+ (void)arena;
+ return;
+ }
SharedDtor();
- _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void CodeGeneratorResponse::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+ error_.Destroy();
}
-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);
}
@@ -1360,22 +1331,22 @@ void CodeGeneratorResponse::Clear() {
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
-const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
+const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
arc_ui32 tag;
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
+ ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string error = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_error();
- ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
#ifndef NDEBUG
- ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.error");
+ ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.error");
#endif // !NDEBUG
- CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -1445,19 +1416,19 @@ uint8_t* CodeGeneratorResponse::_InternalSerialize(
// 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);
+ target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_supported_features(), target);
}
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
- for (unsigned int i = 0,
- n = static_cast<unsigned int>(this->_internal_file_size()); i < n; i++) {
- target = stream->EnsureSpace(target);
+ for (unsigned i = 0,
+ n = static_cast<unsigned>(this->_internal_file_size()); i < n; i++) {
+ const auto& repfield = this->_internal_file(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
- InternalWriteMessage(15, this->_internal_file(i), target, stream);
+ InternalWriteMessage(15, repfield, repfield.GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
- target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
+ target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_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)
@@ -1490,7 +1461,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
// optional uint64 supported_features = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_supported_features());
+ total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_supported_features());
}
}
@@ -1549,7 +1520,6 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
swap(_has_bits_[0], other->_has_bits_[0]);
file_.InternalSwap(&other->file_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&error_, lhs_arena,
&other->error_, rhs_arena
);
@@ -1557,7 +1527,7 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const {
- return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+ return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]);
}
@@ -1566,16 +1536,20 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::Version >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::Version*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::Version >(Arena* 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) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(Arena* 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) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(Arena* 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) {
+template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse*
+Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
index 2edc4f2ce4..64d7be56fd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3019000
+#if PROTOBUF_VERSION < 3020000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3020002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,7 +23,6 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -50,14 +49,6 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4]
- PROTOBUF_SECTION_VARIABLE(protodesc_cold);
- static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
- static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const arc_ui32 offsets[];
};
PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
@@ -116,7 +107,7 @@ class PROTOC_EXPORT Version final :
public:
inline Version() : Version(nullptr) {}
~Version() override;
- explicit constexpr Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Version(const Version& from);
Version(Version&& from) noexcept
@@ -225,9 +216,6 @@ class PROTOC_EXPORT Version final :
protected:
explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -324,7 +312,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
public:
inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {}
~CodeGeneratorRequest() override;
- explicit constexpr CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
CodeGeneratorRequest(const CodeGeneratorRequest& from);
CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept
@@ -433,9 +421,6 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
protected:
explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -553,7 +538,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
public:
inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {}
~CodeGeneratorResponse_File() override;
- explicit constexpr CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from);
CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept
@@ -662,9 +647,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
protected:
explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -776,7 +758,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
public:
inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {}
~CodeGeneratorResponse() override;
- explicit constexpr CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+ explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
CodeGeneratorResponse(const CodeGeneratorResponse& from);
CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept
@@ -885,9 +867,6 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
protected:
explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
- static void ArenaDtor(void* object);
- inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1114,7 +1093,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Version::set_suffix(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
}
inline TProtoStringType* Version::mutable_suffix() {
@@ -1127,11 +1106,11 @@ inline const TProtoStringType& Version::_internal_suffix() const {
}
inline void Version::_internal_set_suffix(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ suffix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Version::_internal_mutable_suffix() {
_has_bits_[0] |= 0x00000001u;
- return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return suffix_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Version::release_suffix() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
@@ -1139,10 +1118,10 @@ inline TProtoStringType* Version::release_suffix() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = suffix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (suffix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (suffix_.IsDefault()) {
+ suffix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -1153,11 +1132,10 @@ inline void Version::set_allocated_suffix(TProtoStringType* suffix) {
} else {
_has_bits_[0] &= ~0x00000001u;
}
- suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix,
- GetArenaForAllocation());
+ suffix_.SetAllocated(suffix, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (suffix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (suffix_.IsDefault()) {
+ suffix_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
@@ -1262,7 +1240,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
inline TProtoStringType* CodeGeneratorRequest::mutable_parameter() {
@@ -1275,11 +1253,11 @@ inline const TProtoStringType& CodeGeneratorRequest::_internal_parameter() const
}
inline void CodeGeneratorRequest::_internal_set_parameter(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ parameter_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorRequest::_internal_mutable_parameter() {
_has_bits_[0] |= 0x00000001u;
- return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return parameter_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorRequest::release_parameter() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@@ -1287,10 +1265,10 @@ inline TProtoStringType* CodeGeneratorRequest::release_parameter() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = parameter_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (parameter_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (parameter_.IsDefault()) {
+ parameter_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -1301,11 +1279,10 @@ inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* para
} else {
_has_bits_[0] &= ~0x00000001u;
}
- parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter,
- GetArenaForAllocation());
+ parameter_.SetAllocated(parameter, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (parameter_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (parameter_.IsDefault()) {
+ parameter_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@@ -1425,7 +1402,7 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAME
}
if (compiler_version) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::compiler::Version>::GetOwningArena(compiler_version);
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(compiler_version);
if (message_arena != submessage_arena) {
compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, compiler_version, submessage_arena);
@@ -1462,7 +1439,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_name() {
@@ -1475,11 +1452,11 @@ inline const TProtoStringType& CodeGeneratorResponse_File::_internal_name() cons
}
inline void CodeGeneratorResponse_File::_internal_set_name(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
- return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return name_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@@ -1487,10 +1464,10 @@ inline TProtoStringType* CodeGeneratorResponse_File::release_name() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -1501,11 +1478,10 @@ inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* nam
} else {
_has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
- GetArenaForAllocation());
+ name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (name_.IsDefault()) {
+ name_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@@ -1531,7 +1507,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
- insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_insertion_point() {
@@ -1544,11 +1520,11 @@ inline const TProtoStringType& CodeGeneratorResponse_File::_internal_insertion_p
}
inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000002u;
- insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ insertion_point_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
_has_bits_[0] |= 0x00000002u;
- return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return insertion_point_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::release_insertion_point() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@@ -1556,10 +1532,10 @@ inline TProtoStringType* CodeGeneratorResponse_File::release_insertion_point() {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
- auto* p = insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = insertion_point_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (insertion_point_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (insertion_point_.IsDefault()) {
+ insertion_point_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -1570,11 +1546,10 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStri
} else {
_has_bits_[0] &= ~0x00000002u;
}
- insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point,
- GetArenaForAllocation());
+ insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (insertion_point_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (insertion_point_.IsDefault()) {
+ insertion_point_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@@ -1600,7 +1575,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
- content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_content() {
@@ -1613,11 +1588,11 @@ inline const TProtoStringType& CodeGeneratorResponse_File::_internal_content() c
}
inline void CodeGeneratorResponse_File::_internal_set_content(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000004u;
- content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ content_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_content() {
_has_bits_[0] |= 0x00000004u;
- return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return content_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::release_content() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@@ -1625,10 +1600,10 @@ inline TProtoStringType* CodeGeneratorResponse_File::release_content() {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
- auto* p = content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = content_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (content_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (content_.IsDefault()) {
+ content_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -1639,11 +1614,10 @@ inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType*
} else {
_has_bits_[0] &= ~0x00000004u;
}
- content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content,
- GetArenaForAllocation());
+ content_.SetAllocated(content, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (content_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (content_.IsDefault()) {
+ content_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@@ -1722,8 +1696,7 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROT
}
if (generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
- ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
- ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
+ ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info));
if (message_arena != submessage_arena) {
generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@@ -1761,7 +1734,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
- error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
}
inline TProtoStringType* CodeGeneratorResponse::mutable_error() {
@@ -1774,11 +1747,11 @@ inline const TProtoStringType& CodeGeneratorResponse::_internal_error() const {
}
inline void CodeGeneratorResponse::_internal_set_error(const TProtoStringType& value) {
_has_bits_[0] |= 0x00000001u;
- error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+ error_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse::_internal_mutable_error() {
_has_bits_[0] |= 0x00000001u;
- return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+ return error_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse::release_error() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
@@ -1786,10 +1759,10 @@ inline TProtoStringType* CodeGeneratorResponse::release_error() {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
- auto* p = error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+ auto* p = error_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (error_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (error_.IsDefault()) {
+ error_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
@@ -1800,11 +1773,10 @@ inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* error)
} else {
_has_bits_[0] &= ~0x00000001u;
}
- error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error,
- GetArenaForAllocation());
+ error_.SetAllocated(error, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (error_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
- error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+ if (error_.IsDefault()) {
+ error_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc
index ba79c25908..7c723febb3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc
@@ -54,13 +54,15 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/compiler/python/python_helpers.h>
+#include <google/protobuf/compiler/python/python_pyi_generator.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/descriptor.pb.h>
namespace google {
namespace protobuf {
@@ -68,22 +70,6 @@ namespace compiler {
namespace python {
namespace {
-
-TProtoStringType FixEv(const TProtoStringType& filename) {
- if (HasSuffixString(filename, ".ev")) {
- return StripSuffixString(filename, ".ev") + "_ev.proto";
- }
- return filename;
-}
-
-// Returns the Python module name expected for a given .proto filename.
-TProtoStringType ModuleName(const TProtoStringType& filename) {
- TProtoStringType basename = StripProto(FixEv(filename));
- ReplaceCharacters(&basename, "-", '_');
- ReplaceCharacters(&basename, "/", '.');
- return basename + "_pb2";
-}
-
// Returns the alias we assign to the module of the given .proto filename
// when importing. See testPackageInitializationImport in
// net/proto2/python/internal/reflection_test.py
@@ -98,78 +84,18 @@ TProtoStringType ModuleAlias(const TProtoStringType& filename) {
return module_name;
}
-// Keywords reserved by the Python language.
-const char* const kKeywords[] = {
- "False", "None", "True", "and", "as", "assert",
- "async", "await", "break", "class", "continue", "def",
- "del", "elif", "else", "except", "finally", "for",
- "from", "global", "if", "import", "in", "is",
- "lambda", "nonlocal", "not", "or", "pass", "raise",
- "return", "try", "while", "with", "yield", "print",
-};
-const char* const* kKeywordsEnd =
- kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
-
-bool ContainsPythonKeyword(const TProtoStringType& module_name) {
- std::vector<TProtoStringType> tokens = Split(module_name, ".");
- for (int i = 0; i < tokens.size(); ++i) {
- if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {
- return true;
- }
- }
- return false;
-}
-
-inline bool IsPythonKeyword(const TProtoStringType& name) {
- return (std::find(kKeywords, kKeywordsEnd, name) != kKeywordsEnd);
-}
-
-TProtoStringType ResolveKeyword(const TProtoStringType& name) {
- if (IsPythonKeyword(name)) {
- return "globals()['" + name + "']";
- }
- return name;
-}
-
-// Returns the name of all containing types for descriptor,
-// in order from outermost to innermost, followed by descriptor's
-// own name. Each name is separated by |separator|.
-template <typename DescriptorT>
-TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
- const TProtoStringType& separator) {
- TProtoStringType name = descriptor.name();
- const Descriptor* parent = descriptor.containing_type();
- if (parent != nullptr) {
- TProtoStringType prefix = NamePrefixedWithNestedTypes(*parent, separator);
- if (separator == "." && IsPythonKeyword(name)) {
- return "getattr(" + prefix + ", '" + name + "')";
- } else {
- return prefix + separator + name;
- }
- }
- if (separator == ".") {
- name = ResolveKeyword(name);
- }
- return name;
-}
-
// Name of the class attribute where we store the Python
// descriptor.Descriptor instance for the generated class.
// Must stay consistent with the _DESCRIPTOR_KEY constant
// in proto2/public/reflection.py.
const char kDescriptorKey[] = "DESCRIPTOR";
+
// Does the file have top-level enums?
inline bool HasTopLevelEnums(const FileDescriptor* file) {
return file->enum_type_count() > 0;
}
-// Should we generate generic services for this file?
-inline bool HasGenericServices(const FileDescriptor* file) {
- return file->service_count() > 0 && file->options().py_generic_services();
-}
-
-// Prints the common boilerplate needed at the top of every .py
// file output by this generator.
void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file,
bool descriptor_proto) {
@@ -180,27 +106,16 @@ void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file,
"# source: $filename$\n"
"\"\"\"Generated protocol buffer code.\"\"\"\n",
"filename", file->name());
- if (HasTopLevelEnums(file)) {
- printer->Print(
- "from google.protobuf.internal import enum_type_wrapper\n");
- }
printer->Print(
+ "from google.protobuf.internal import builder as _builder\n"
"from google.protobuf import descriptor as _descriptor\n"
"from google.protobuf import descriptor_pool as "
"_descriptor_pool\n"
- "from google.protobuf import message as _message\n"
- "from google.protobuf import reflection as _reflection\n"
"from google.protobuf import symbol_database as "
"_symbol_database\n");
- if (HasGenericServices(file)) {
- printer->Print(
- "from google.protobuf import service as _service\n"
- "from google.protobuf import service_reflection\n");
- }
- printer->Print(
- "# @@protoc_insertion_point(imports)\n\n"
- "_sym_db = _symbol_database.Default()\n");
+ printer->Print("# @@protoc_insertion_point(imports)\n\n");
+ printer->Print("_sym_db = _symbol_database.Default()\n");
printer->Print("\n\n");
}
@@ -315,6 +230,11 @@ bool Generator::Generate(const FileDescriptor* file,
for (int i = 0; i < options.size(); i++) {
if (options[i].first == "cpp_generated_lib_linked") {
cpp_generated_lib_linked = true;
+ } else if (options[i].first == "pyi_out") {
+ python::PyiGenerator pyi_generator;
+ if (!pyi_generator.Generate(file, "", context, error)) {
+ return false;
+ }
} else {
*error = "Unknown generator option: " + options[i].first;
return false;
@@ -330,11 +250,8 @@ bool Generator::Generate(const FileDescriptor* file,
// to have any mutable members. Then it is implicitly thread-safe.
MutexLock lock(&mutex_);
file_ = file;
- TProtoStringType module_name = ModuleName(file->name());
- TProtoStringType filename = module_name;
- ReplaceCharacters(&filename, ".", '/');
- filename += ".py";
+ TProtoStringType filename = GetFileName(file, ".py");
pure_python_workable_ = !cpp_generated_lib_linked;
if (HasPrefixString(file->name(), "google/protobuf/")) {
pure_python_workable_ = true;
@@ -355,15 +272,13 @@ bool Generator::Generate(const FileDescriptor* file,
PrintImports();
}
PrintFileDescriptor();
- PrintTopLevelEnums();
- PrintTopLevelExtensions();
if (pure_python_workable_) {
if (GeneratingDescriptorProto()) {
printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
printer_->Indent();
// Create enums before message descriptors
- PrintAllNestedEnumsInFile(StripPrintDescriptor::kCreate);
- PrintMessageDescriptors(StripPrintDescriptor::kCreate);
+ PrintAllNestedEnumsInFile();
+ PrintMessageDescriptors();
FixForeignFieldsInDescriptors();
printer_->Outdent();
printer_->Print("else:\n");
@@ -371,16 +286,18 @@ bool Generator::Generate(const FileDescriptor* file,
}
// Find the message descriptors first and then use the message
// descriptor to find enums.
- PrintMessageDescriptors(StripPrintDescriptor::kFind);
- PrintAllNestedEnumsInFile(StripPrintDescriptor::kFind);
+ printer_->Print(
+ "_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())\n");
if (GeneratingDescriptorProto()) {
printer_->Outdent();
}
}
- PrintMessages();
+ TProtoStringType module_name = ModuleName(file->name());
+ printer_->Print(
+ "_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, '$module_name$', "
+ "globals())\n",
+ "module_name", module_name);
if (pure_python_workable_) {
- PrintServiceDescriptors();
-
printer.Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
printer_->Indent();
@@ -401,7 +318,9 @@ bool Generator::Generate(const FileDescriptor* file,
printer_->Outdent();
}
if (HasGenericServices(file)) {
- PrintServices();
+ printer_->Print(
+ "_builder.BuildServices(DESCRIPTOR, '$module_name$', globals())\n",
+ "module_name", module_name);
}
printer.Print("# @@protoc_insertion_point(module_scope)\n");
@@ -409,7 +328,6 @@ bool Generator::Generate(const FileDescriptor* file,
return !printer.failed();
}
-
// Prints Python imports for all modules imported by |file|.
void Generator::PrintImports() const {
for (int i = 0; i < file_->dependency_count(); ++i) {
@@ -522,47 +440,17 @@ void Generator::PrintFileDescriptor() const {
printer_->Print("\n");
}
-// Prints descriptors and module-level constants for all top-level
-// enums defined in |file|.
-void Generator::PrintTopLevelEnums() const {
- std::vector<std::pair<TProtoStringType, int> > top_level_enum_values;
- for (int i = 0; i < file_->enum_type_count(); ++i) {
- const EnumDescriptor& enum_descriptor = *file_->enum_type(i);
- PrintFindEnum(enum_descriptor);
- printer_->Print(
- "$name$ = "
- "enum_type_wrapper.EnumTypeWrapper($descriptor_name$)",
- "name", ResolveKeyword(enum_descriptor.name()), "descriptor_name",
- ModuleLevelDescriptorName(enum_descriptor));
- printer_->Print("\n");
-
- for (int j = 0; j < enum_descriptor.value_count(); ++j) {
- const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(j);
- top_level_enum_values.push_back(
- std::make_pair(value_descriptor.name(), value_descriptor.number()));
- }
- }
-
- for (int i = 0; i < top_level_enum_values.size(); ++i) {
- printer_->Print("$name$ = $value$\n", "name",
- ResolveKeyword(top_level_enum_values[i].first), "value",
- StrCat(top_level_enum_values[i].second));
- }
- printer_->Print("\n");
-}
-
// Prints all enums contained in all message types in |file|.
-void Generator::PrintAllNestedEnumsInFile(
- StripPrintDescriptor print_mode) const {
+void Generator::PrintAllNestedEnumsInFile() const {
for (int i = 0; i < file_->message_type_count(); ++i) {
- PrintNestedEnums(*file_->message_type(i), print_mode);
+ PrintNestedEnums(*file_->message_type(i));
}
}
// Prints a Python statement assigning the appropriate module-level
// enum name to a Python EnumDescriptor object equivalent to
// enum_descriptor.
-void Generator::PrintCreateEnum(const EnumDescriptor& enum_descriptor) const {
+void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
TProtoStringType module_level_descriptor_name =
ModuleLevelDescriptorName(enum_descriptor);
@@ -606,68 +494,23 @@ void Generator::PrintCreateEnum(const EnumDescriptor& enum_descriptor) const {
printer_->Print("\n");
}
-void Generator::PrintFindEnum(const EnumDescriptor& enum_descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_name"] = ModuleLevelDescriptorName(enum_descriptor);
- m["name"] = enum_descriptor.name();
- m["file"] = kDescriptorKey;
- if (enum_descriptor.containing_type()) {
- m["containing_type"] =
- ModuleLevelDescriptorName(*enum_descriptor.containing_type());
- printer_->Print(m,
- "$descriptor_name$ = "
- "$containing_type$.enum_types_by_name['$name$']\n");
- } else {
- printer_->Print(
- m, "$descriptor_name$ = $file$.enum_types_by_name['$name$']\n");
- }
-}
-
// Recursively prints enums in nested types within descriptor, then
// prints enums contained at the top level in descriptor.
-void Generator::PrintNestedEnums(const Descriptor& descriptor,
- StripPrintDescriptor print_mode) const {
+void Generator::PrintNestedEnums(const Descriptor& descriptor) const {
for (int i = 0; i < descriptor.nested_type_count(); ++i) {
- PrintNestedEnums(*descriptor.nested_type(i), print_mode);
+ PrintNestedEnums(*descriptor.nested_type(i));
}
for (int i = 0; i < descriptor.enum_type_count(); ++i) {
- if (print_mode == StripPrintDescriptor::kCreate) {
- PrintCreateEnum(*descriptor.enum_type(i));
- } else {
- PrintFindEnum(*descriptor.enum_type(i));
- }
+ PrintEnum(*descriptor.enum_type(i));
}
}
-void Generator::PrintTopLevelExtensions() const {
- for (int i = 0; i < file_->extension_count(); ++i) {
- const FieldDescriptor& extension_field = *file_->extension(i);
- TProtoStringType constant_name = extension_field.name() + "_FIELD_NUMBER";
- ToUpper(&constant_name);
- printer_->Print("$constant_name$ = $number$\n", "constant_name",
- constant_name, "number",
- StrCat(extension_field.number()));
- printer_->Print(
- "$resolved_name$ = "
- "$file$.extensions_by_name['$name$']\n",
- "resolved_name", ResolveKeyword(extension_field.name()), "file",
- kDescriptorKey, "name", extension_field.name());
- }
- printer_->Print("\n");
-}
-
// Prints Python equivalents of all Descriptors in |file|.
-void Generator::PrintMessageDescriptors(StripPrintDescriptor print_mode) const {
- if (print_mode == StripPrintDescriptor::kCreate) {
- for (int i = 0; i < file_->message_type_count(); ++i) {
- PrintCreateDescriptor(*file_->message_type(i));
- printer_->Print("\n");
- }
- } else {
- for (int i = 0; i < file_->message_type_count(); ++i) {
- PrintFindDescriptor(*file_->message_type(i));
- }
+void Generator::PrintMessageDescriptors() const {
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ PrintDescriptor(*file_->message_type(i));
+ printer_->Print("\n");
}
}
@@ -736,14 +579,13 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
// to a Python Descriptor object for message_descriptor.
//
// Mutually recursive with PrintNestedDescriptors().
-void Generator::PrintCreateDescriptor(
- const Descriptor& message_descriptor) const {
+void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
m["name"] = message_descriptor.name();
m["full_name"] = message_descriptor.full_name();
m["file"] = kDescriptorKey;
- PrintNestedDescriptors(message_descriptor, StripPrintDescriptor::kCreate);
+ PrintNestedDescriptors(message_descriptor);
printer_->Print("\n");
printer_->Print("$descriptor_name$ = _descriptor.Descriptor(\n",
@@ -829,41 +671,14 @@ void Generator::PrintCreateDescriptor(
printer_->Print(")\n");
}
-void Generator::PrintFindDescriptor(
- const Descriptor& message_descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor);
- m["name"] = message_descriptor.name();
-
- if (message_descriptor.containing_type()) {
- m["containing_type"] =
- ModuleLevelDescriptorName(*message_descriptor.containing_type());
- printer_->Print(m,
- "$descriptor_name$ = "
- "$containing_type$.nested_types_by_name['$name$']\n");
- } else {
- m["file"] = kDescriptorKey;
- printer_->Print(
- m, "$descriptor_name$ = $file$.message_types_by_name['$name$']\n");
- }
-
- PrintNestedDescriptors(message_descriptor, StripPrintDescriptor::kFind);
-}
-
// Prints Python Descriptor objects for all nested types contained in
// message_descriptor.
//
// Mutually recursive with PrintDescriptor().
-void Generator::PrintNestedDescriptors(const Descriptor& containing_descriptor,
- StripPrintDescriptor print_mode) const {
- if (print_mode == StripPrintDescriptor::kCreate) {
- for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
- PrintCreateDescriptor(*containing_descriptor.nested_type(i));
- }
- } else {
- for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
- PrintFindDescriptor(*containing_descriptor.nested_type(i));
- }
+void Generator::PrintNestedDescriptors(
+ const Descriptor& containing_descriptor) const {
+ for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
+ PrintDescriptor(*containing_descriptor.nested_type(i));
}
}
@@ -1469,7 +1284,7 @@ void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const {
if (value_options != "None") {
PrintDescriptorOptionsFixingCode(
StringPrintf("%s.values_by_name[\"%s\"]", descriptor_name.c_str(),
- value_descriptor.name().c_str()),
+ value_descriptor.name().c_str()),
value_options, printer_);
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
index d5af959fce..359d802aee 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
@@ -40,6 +40,7 @@
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/mutex.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
@@ -59,8 +60,6 @@ class Printer;
namespace compiler {
namespace python {
-enum class StripPrintDescriptor { kCreate, kFind };
-
// CodeGenerator implementation for generated Python protocol buffer classes.
// If you create your own protocol compiler binary and you want it to support
// Python output, you can do so by registering an instance of this
@@ -68,7 +67,7 @@ enum class StripPrintDescriptor { kCreate, kFind };
class PROTOC_EXPORT Generator : public CodeGenerator {
public:
Generator();
- virtual ~Generator();
+ ~Generator() override;
// CodeGenerator methods.
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
@@ -80,14 +79,9 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
private:
void PrintImports() const;
void PrintFileDescriptor() const;
- void PrintTopLevelEnums() const;
- void PrintAllNestedEnumsInFile(StripPrintDescriptor print_mode) const;
- void PrintNestedEnums(const Descriptor& descriptor,
- StripPrintDescriptor print_mode) const;
- void PrintCreateEnum(const EnumDescriptor& enum_descriptor) const;
- void PrintFindEnum(const EnumDescriptor& enum_descriptor) const;
-
- void PrintTopLevelExtensions() const;
+ void PrintAllNestedEnumsInFile() const;
+ void PrintNestedEnums(const Descriptor& descriptor) const;
+ void PrintEnum(const EnumDescriptor& enum_descriptor) const;
void PrintFieldDescriptor(const FieldDescriptor& field,
bool is_extension) const;
@@ -97,11 +91,9 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const;
void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const;
void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const;
- void PrintMessageDescriptors(StripPrintDescriptor print_mode) const;
- void PrintCreateDescriptor(const Descriptor& message_descriptor) const;
- void PrintFindDescriptor(const Descriptor& message_descriptor) const;
- void PrintNestedDescriptors(const Descriptor& containing_descriptor,
- StripPrintDescriptor print_mode) const;
+ void PrintMessageDescriptors() const;
+ void PrintDescriptor(const Descriptor& message_descriptor) const;
+ void PrintNestedDescriptors(const Descriptor& containing_descriptor) const;
void PrintMessages() const;
void PrintMessage(const Descriptor& message_descriptor,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc
new file mode 100644
index 0000000000..7a9721c02c
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc
@@ -0,0 +1,138 @@
+// 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.
+
+#include <google/protobuf/compiler/python/python_helpers.h>
+
+#include <algorithm>
+
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/descriptor.pb.h>
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace python {
+
+TProtoStringType FixEv(const TProtoStringType& filename) {
+ if (HasSuffixString(filename, ".ev")) {
+ return StripSuffixString(filename, ".ev") + "_ev.proto";
+ }
+ return filename;
+}
+
+// Returns the Python module name expected for a given .proto filename.
+TProtoStringType ModuleName(const TProtoStringType& filename) {
+ TProtoStringType basename = StripProto(FixEv(filename));
+ ReplaceCharacters(&basename, "-", '_');
+ ReplaceCharacters(&basename, "/", '.');
+ return basename + "_pb2";
+}
+
+TProtoStringType StrippedModuleName(const TProtoStringType& filename) {
+ TProtoStringType module_name = ModuleName(filename);
+ return module_name;
+}
+
+// Keywords reserved by the Python language.
+const char* const kKeywords[] = {
+ "False", "None", "True", "and", "as", "assert",
+ "async", "await", "break", "class", "continue", "def",
+ "del", "elif", "else", "except", "finally", "for",
+ "from", "global", "if", "import", "in", "is",
+ "lambda", "nonlocal", "not", "or", "pass", "raise",
+ "return", "try", "while", "with", "yield", "print",
+};
+const char* const* kKeywordsEnd =
+ kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
+
+bool ContainsPythonKeyword(const TProtoStringType& module_name) {
+ std::vector<TProtoStringType> tokens = Split(module_name, ".");
+ for (int i = 0; i < static_cast<int>(tokens.size()); ++i) {
+ if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool IsPythonKeyword(const TProtoStringType& name) {
+ return (std::find(kKeywords, kKeywordsEnd, name) != kKeywordsEnd);
+}
+
+TProtoStringType ResolveKeyword(const TProtoStringType& name) {
+ if (IsPythonKeyword(name)) {
+ return "globals()['" + name + "']";
+ }
+ return name;
+}
+
+TProtoStringType GetFileName(const FileDescriptor* file_des,
+ const TProtoStringType& suffix) {
+ TProtoStringType module_name = ModuleName(file_des->name());
+ TProtoStringType filename = module_name;
+ ReplaceCharacters(&filename, ".", '/');
+ filename += suffix;
+ return filename;
+}
+
+bool HasGenericServices(const FileDescriptor* file) {
+ return file->service_count() > 0 && file->options().py_generic_services();
+}
+
+template <typename DescriptorT>
+TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
+ const TProtoStringType& separator) {
+ TProtoStringType name = descriptor.name();
+ const Descriptor* parent = descriptor.containing_type();
+ if (parent != nullptr) {
+ TProtoStringType prefix = NamePrefixedWithNestedTypes(*parent, separator);
+ if (separator == "." && IsPythonKeyword(name)) {
+ return "getattr(" + prefix + ", '" + name + "')";
+ } else {
+ return prefix + separator + name;
+ }
+ }
+ if (separator == ".") {
+ name = ResolveKeyword(name);
+ }
+ return name;
+}
+
+template TProtoStringType NamePrefixedWithNestedTypes<Descriptor>(
+ const Descriptor& descriptor, const TProtoStringType& separator);
+template TProtoStringType NamePrefixedWithNestedTypes<EnumDescriptor>(
+ const EnumDescriptor& descriptor, const TProtoStringType& separator);
+
+} // namespace python
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h
new file mode 100644
index 0000000000..8745698acf
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h
@@ -0,0 +1,62 @@
+// 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.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_HELPERS_H__
+#define GOOGLE_PROTOBUF_COMPILER_PYTHON_HELPERS_H__
+
+#include <string>
+
+#include <google/protobuf/descriptor.h>
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace python {
+
+
+TProtoStringType ModuleName(const TProtoStringType& filename);
+TProtoStringType StrippedModuleName(const TProtoStringType& filename);
+bool ContainsPythonKeyword(const TProtoStringType& module_name);
+bool IsPythonKeyword(const TProtoStringType& name);
+TProtoStringType ResolveKeyword(const TProtoStringType& name);
+TProtoStringType GetFileName(const FileDescriptor* file_des,
+ const TProtoStringType& suffix);
+bool HasGenericServices(const FileDescriptor* file);
+
+template <typename DescriptorT>
+TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
+ const TProtoStringType& separator);
+
+} // namespace python
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc
new file mode 100644
index 0000000000..89cfbf86fe
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc
@@ -0,0 +1,558 @@
+// 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.
+
+#include <google/protobuf/compiler/python/python_pyi_generator.h>
+
+#include <string>
+
+#include <google/protobuf/compiler/python/python_helpers.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/descriptor.pb.h>
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace python {
+
+template <typename DescriptorT>
+struct SortByName {
+ bool operator()(const DescriptorT* l, const DescriptorT* r) const {
+ return l->name() < r->name();
+ }
+};
+
+PyiGenerator::PyiGenerator() : file_(nullptr) {}
+
+PyiGenerator::~PyiGenerator() {}
+
+void PyiGenerator::PrintItemMap(
+ const std::map<TProtoStringType, TProtoStringType>& item_map) const {
+ for (const auto& entry : item_map) {
+ printer_->Print("$key$: $value$\n", "key", entry.first, "value",
+ entry.second);
+ }
+}
+
+template <typename DescriptorT>
+TProtoStringType PyiGenerator::ModuleLevelName(const DescriptorT& descriptor) const {
+ TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, ".");
+ if (descriptor.file() != file_) {
+ TProtoStringType module_name = ModuleName(descriptor.file()->name());
+ std::vector<TProtoStringType> tokens = Split(module_name, ".");
+ name = "_" + tokens.back() + "." + name;
+ }
+ return name;
+}
+
+struct ImportModules {
+ bool has_repeated = false; // _containers
+ bool has_iterable = false; // typing.Iterable
+ bool has_messages = false; // _message
+ bool has_enums = false; // _enum_type_wrapper
+ bool has_extendable = false; // _python_message
+ bool has_mapping = false; // typing.Mapping
+ bool has_optional = false; // typing.Optional
+ bool has_union = false; // typing.Uion
+};
+
+// Checks what modules should be imported for this message
+// descriptor.
+void CheckImportModules(const Descriptor* descriptor,
+ ImportModules* import_modules) {
+ if (descriptor->extension_range_count() > 0) {
+ import_modules->has_extendable = true;
+ }
+ if (descriptor->enum_type_count() > 0) {
+ import_modules->has_enums = true;
+ }
+ for (int i = 0; i < descriptor->field_count(); ++i) {
+ const FieldDescriptor* field = descriptor->field(i);
+ if (IsPythonKeyword(field->name())) {
+ continue;
+ }
+ import_modules->has_optional = true;
+ if (field->is_repeated()) {
+ import_modules->has_repeated = true;
+ }
+ if (field->is_map()) {
+ import_modules->has_mapping = true;
+ const FieldDescriptor* value_des = field->message_type()->field(1);
+ if (value_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
+ value_des->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
+ import_modules->has_union = true;
+ }
+ } else {
+ if (field->is_repeated()) {
+ import_modules->has_iterable = true;
+ }
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ import_modules->has_union = true;
+ import_modules->has_mapping = true;
+ }
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
+ import_modules->has_union = true;
+ }
+ }
+ }
+ for (int i = 0; i < descriptor->nested_type_count(); ++i) {
+ CheckImportModules(descriptor->nested_type(i), import_modules);
+ }
+}
+
+void PyiGenerator::PrintImports(
+ std::map<TProtoStringType, TProtoStringType>* item_map) const {
+ // Prints imported dependent _pb2 files.
+ for (int i = 0; i < file_->dependency_count(); ++i) {
+ const TProtoStringType& filename = file_->dependency(i)->name();
+ TProtoStringType module_name = StrippedModuleName(filename);
+ size_t last_dot_pos = module_name.rfind('.');
+ TProtoStringType import_statement;
+ if (last_dot_pos == TProtoStringType::npos) {
+ import_statement = "import " + module_name;
+ } else {
+ import_statement = "from " + module_name.substr(0, last_dot_pos) +
+ " import " + module_name.substr(last_dot_pos + 1);
+ module_name = module_name.substr(last_dot_pos + 1);
+ }
+ printer_->Print("$statement$ as _$module_name$\n", "statement",
+ import_statement, "module_name", module_name);
+ }
+
+ // Checks what modules should be imported.
+ ImportModules import_modules;
+ if (file_->message_type_count() > 0) {
+ import_modules.has_messages = true;
+ }
+ if (file_->enum_type_count() > 0) {
+ import_modules.has_enums = true;
+ }
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ CheckImportModules(file_->message_type(i), &import_modules);
+ }
+
+ // Prints modules (e.g. _containers, _messages, typing) that are
+ // required in the proto file.
+ if (import_modules.has_repeated) {
+ printer_->Print(
+ "from google.protobuf.internal import containers as "
+ "_containers\n");
+ }
+ if (import_modules.has_enums) {
+ printer_->Print(
+ "from google.protobuf.internal import enum_type_wrapper"
+ " as _enum_type_wrapper\n");
+ }
+ if (import_modules.has_extendable) {
+ printer_->Print(
+ "from google.protobuf.internal import python_message"
+ " as _python_message\n");
+ }
+ printer_->Print(
+ "from google.protobuf import"
+ " descriptor as _descriptor\n");
+ if (import_modules.has_messages) {
+ printer_->Print(
+ "from google.protobuf import message as _message\n");
+ }
+ if (HasGenericServices(file_)) {
+ printer_->Print(
+ "from google.protobuf import service as"
+ " _service\n");
+ }
+ printer_->Print("from typing import ");
+ printer_->Print("ClassVar");
+ if (import_modules.has_iterable) {
+ printer_->Print(", Iterable");
+ }
+ if (import_modules.has_mapping) {
+ printer_->Print(", Mapping");
+ }
+ if (import_modules.has_optional) {
+ printer_->Print(", Optional");
+ }
+ if (file_->service_count() > 0) {
+ printer_->Print(", Text");
+ }
+ if (import_modules.has_union) {
+ printer_->Print(", Union");
+ }
+ printer_->Print("\n\n");
+
+ // Public imports
+ for (int i = 0; i < file_->public_dependency_count(); ++i) {
+ const FileDescriptor* public_dep = file_->public_dependency(i);
+ TProtoStringType module_name = StrippedModuleName(public_dep->name());
+ // Top level messages in public imports
+ for (int i = 0; i < public_dep->message_type_count(); ++i) {
+ printer_->Print("from $module$ import $message_class$\n", "module",
+ module_name, "message_class",
+ public_dep->message_type(i)->name());
+ }
+ // Top level enums for public imports
+ for (int i = 0; i < public_dep->enum_type_count(); ++i) {
+ printer_->Print("from $module$ import $enum_class$\n", "module",
+ module_name, "enum_class",
+ public_dep->enum_type(i)->name());
+ }
+ // Enum values for public imports
+ for (int i = 0; i < public_dep->enum_type_count(); ++i) {
+ const EnumDescriptor* enum_descriptor = public_dep->enum_type(i);
+ for (int j = 0; j < enum_descriptor->value_count(); ++j) {
+ (*item_map)[enum_descriptor->value(j)->name()] =
+ ModuleLevelName(*enum_descriptor);
+ }
+ }
+ // Top level extensions for public imports
+ AddExtensions(*public_dep, item_map);
+ }
+}
+
+void PyiGenerator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
+ TProtoStringType enum_name = enum_descriptor.name();
+ printer_->Print(
+ "class $enum_name$(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):\n"
+ " __slots__ = []\n",
+ "enum_name", enum_name);
+}
+
+// Adds enum value to item map which will be ordered and printed later.
+void PyiGenerator::AddEnumValue(
+ const EnumDescriptor& enum_descriptor,
+ std::map<TProtoStringType, TProtoStringType>* item_map) const {
+ // enum values
+ TProtoStringType module_enum_name = ModuleLevelName(enum_descriptor);
+ for (int j = 0; j < enum_descriptor.value_count(); ++j) {
+ const EnumValueDescriptor* value_descriptor = enum_descriptor.value(j);
+ (*item_map)[value_descriptor->name()] = module_enum_name;
+ }
+}
+
+// Prints top level enums
+void PyiGenerator::PrintTopLevelEnums() const {
+ for (int i = 0; i < file_->enum_type_count(); ++i) {
+ printer_->Print("\n");
+ PrintEnum(*file_->enum_type(i));
+ }
+}
+
+// Add top level extensions to item_map which will be ordered and
+// printed later.
+template <typename DescriptorT>
+void PyiGenerator::AddExtensions(
+ const DescriptorT& descriptor,
+ std::map<TProtoStringType, TProtoStringType>* item_map) const {
+ for (int i = 0; i < descriptor.extension_count(); ++i) {
+ const FieldDescriptor* extension_field = descriptor.extension(i);
+ TProtoStringType constant_name = extension_field->name() + "_FIELD_NUMBER";
+ ToUpper(&constant_name);
+ (*item_map)[constant_name] = "ClassVar[int]";
+ (*item_map)[extension_field->name()] = "_descriptor.FieldDescriptor";
+ }
+}
+
+// Returns the string format of a field's cpp_type
+TProtoStringType PyiGenerator::GetFieldType(const FieldDescriptor& field_des) const {
+ switch (field_des.cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ case FieldDescriptor::CPPTYPE_UINT32:
+ case FieldDescriptor::CPPTYPE_INT64:
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return "int";
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return "float";
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return "bool";
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return ModuleLevelName(*field_des.enum_type());
+ case FieldDescriptor::CPPTYPE_STRING:
+ if (field_des.type() == FieldDescriptor::TYPE_STRING) {
+ return "str";
+ } else {
+ return "bytes";
+ }
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return ModuleLevelName(*field_des.message_type());
+ default:
+ GOOGLE_LOG(FATAL) << "Unsuppoted field type.";
+ }
+ return "";
+}
+
+void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
+ bool is_nested) const {
+ if (!is_nested) {
+ printer_->Print("\n");
+ }
+ TProtoStringType class_name = message_descriptor.name();
+ printer_->Print("class $class_name$(_message.Message):\n", "class_name",
+ class_name);
+ printer_->Indent();
+ printer_->Indent();
+
+ std::vector<const FieldDescriptor*> fields;
+ fields.reserve(message_descriptor.field_count());
+ for (int i = 0; i < message_descriptor.field_count(); ++i) {
+ fields.push_back(message_descriptor.field(i));
+ }
+ std::sort(fields.begin(), fields.end(), SortByName<FieldDescriptor>());
+
+ // Prints slots
+ printer_->Print("__slots__ = [", "class_name", class_name);
+ bool first_item = true;
+ for (const auto& field_des : fields) {
+ if (IsPythonKeyword(field_des->name())) {
+ continue;
+ }
+ if (first_item) {
+ first_item = false;
+ } else {
+ printer_->Print(", ");
+ }
+ printer_->Print("\"$field_name$\"", "field_name", field_des->name());
+ }
+ printer_->Print("]\n");
+
+ std::map<TProtoStringType, TProtoStringType> item_map;
+ // Prints Extensions for extendable messages
+ if (message_descriptor.extension_range_count() > 0) {
+ item_map["Extensions"] = "_python_message._ExtensionDict";
+ }
+
+ // Prints nested enums
+ std::vector<const EnumDescriptor*> nested_enums;
+ nested_enums.reserve(message_descriptor.enum_type_count());
+ for (int i = 0; i < message_descriptor.enum_type_count(); ++i) {
+ nested_enums.push_back(message_descriptor.enum_type(i));
+ }
+ std::sort(nested_enums.begin(), nested_enums.end(),
+ SortByName<EnumDescriptor>());
+
+ for (const auto& entry : nested_enums) {
+ PrintEnum(*entry);
+ // Adds enum value to item_map which will be ordered and printed later
+ AddEnumValue(*entry, &item_map);
+ }
+
+ // Prints nested messages
+ std::vector<const Descriptor*> nested_messages;
+ nested_messages.reserve(message_descriptor.nested_type_count());
+ for (int i = 0; i < message_descriptor.nested_type_count(); ++i) {
+ nested_messages.push_back(message_descriptor.nested_type(i));
+ }
+ std::sort(nested_messages.begin(), nested_messages.end(),
+ SortByName<Descriptor>());
+
+ for (const auto& entry : nested_messages) {
+ PrintMessage(*entry, true);
+ }
+
+ // Adds extensions to item_map which will be ordered and printed later
+ AddExtensions(message_descriptor, &item_map);
+
+ // Adds field number and field descriptor to item_map
+ for (int i = 0; i < message_descriptor.field_count(); ++i) {
+ const FieldDescriptor& field_des = *message_descriptor.field(i);
+ item_map[ToUpper(field_des.name()) + "_FIELD_NUMBER"] =
+ "ClassVar[int]";
+ if (IsPythonKeyword(field_des.name())) {
+ continue;
+ }
+ TProtoStringType field_type = "";
+ if (field_des.is_map()) {
+ const FieldDescriptor* key_des = field_des.message_type()->field(0);
+ const FieldDescriptor* value_des = field_des.message_type()->field(1);
+ field_type = (value_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
+ ? "_containers.MessageMap["
+ : "_containers.ScalarMap[");
+ field_type += GetFieldType(*key_des);
+ field_type += ", ";
+ field_type += GetFieldType(*value_des);
+ } else {
+ if (field_des.is_repeated()) {
+ field_type = (field_des.cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
+ ? "_containers.RepeatedCompositeFieldContainer["
+ : "_containers.RepeatedScalarFieldContainer[");
+ }
+ field_type += GetFieldType(field_des);
+ }
+
+ if (field_des.is_repeated()) {
+ field_type += "]";
+ }
+ item_map[field_des.name()] = field_type;
+ }
+
+ // Prints all items in item_map
+ PrintItemMap(item_map);
+
+ // Prints __init__
+ printer_->Print("def __init__(self");
+ bool has_key_words = false;
+ bool is_first = true;
+ for (int i = 0; i < message_descriptor.field_count(); ++i) {
+ const FieldDescriptor* field_des = message_descriptor.field(i);
+ if (IsPythonKeyword(field_des->name())) {
+ has_key_words = true;
+ continue;
+ }
+ TProtoStringType field_name = field_des->name();
+ if (is_first && field_name == "self") {
+ // See b/144146793 for an example of real code that generates a (self,
+ // self) method signature. Since repeating a parameter name is illegal in
+ // Python, we rename the duplicate self.
+ field_name = "self_";
+ }
+ is_first = false;
+ printer_->Print(", $field_name$: ", "field_name", field_name);
+ if (field_des->is_repeated() ||
+ field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
+ printer_->Print("Optional[");
+ }
+ if (field_des->is_map()) {
+ const Descriptor* map_entry = field_des->message_type();
+ printer_->Print("Mapping[$key_type$, $value_type$]", "key_type",
+ GetFieldType(*map_entry->field(0)), "value_type",
+ GetFieldType(*map_entry->field(1)));
+ } else {
+ if (field_des->is_repeated()) {
+ printer_->Print("Iterable[");
+ }
+ if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ printer_->Print("Union[$type_name$, Mapping]", "type_name",
+ GetFieldType(*field_des));
+ } else {
+ if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
+ printer_->Print("Union[$type_name$, str]", "type_name",
+ ModuleLevelName(*field_des->enum_type()));
+ } else {
+ printer_->Print("$type_name$", "type_name", GetFieldType(*field_des));
+ }
+ }
+ if (field_des->is_repeated()) {
+ printer_->Print("]");
+ }
+ }
+ if (field_des->is_repeated() ||
+ field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
+ printer_->Print("]");
+ }
+ printer_->Print(" = ...");
+ }
+ if (has_key_words) {
+ printer_->Print(", **kwargs");
+ }
+ printer_->Print(") -> None: ...\n");
+
+ printer_->Outdent();
+ printer_->Outdent();
+}
+
+void PyiGenerator::PrintMessages() const {
+ // Order the descriptors by name to have same output with proto_to_pyi.py
+ std::vector<const Descriptor*> messages;
+ messages.reserve(file_->message_type_count());
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ messages.push_back(file_->message_type(i));
+ }
+ std::sort(messages.begin(), messages.end(), SortByName<Descriptor>());
+
+ for (const auto& entry : messages) {
+ PrintMessage(*entry, false);
+ }
+}
+
+void PyiGenerator::PrintServices() const {
+ std::vector<const ServiceDescriptor*> services;
+ services.reserve(file_->service_count());
+ for (int i = 0; i < file_->service_count(); ++i) {
+ services.push_back(file_->service(i));
+ }
+ std::sort(services.begin(), services.end(), SortByName<ServiceDescriptor>());
+
+ // Prints $Service$ and $Service$_Stub classes
+ for (const auto& entry : services) {
+ printer_->Print("\n");
+ printer_->Print(
+ "class $service_name$(_service.service): ...\n\n"
+ "class $service_name$_Stub($service_name$): ...\n",
+ "service_name", entry->name());
+ }
+}
+
+bool PyiGenerator::Generate(const FileDescriptor* file,
+ const TProtoStringType& parameter,
+ GeneratorContext* context,
+ TProtoStringType* error) const {
+ MutexLock lock(&mutex_);
+ // Calculate file name.
+ file_ = file;
+ // proto_to_pyi.py may set the output file name directly. To replace
+ // proto_to_pyi.py in google3, protoc also accept --pyi_out to set
+ // the output file name.
+ TProtoStringType filename =
+ parameter.empty() ? GetFileName(file, ".pyi") : parameter;
+
+ std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
+ GOOGLE_CHECK(output.get());
+ io::Printer printer(output.get(), '$');
+ printer_ = &printer;
+
+ // item map will store "DESCRIPTOR", top level extensions, top level enum
+ // values. The items will be sorted and printed later.
+ std::map<TProtoStringType, TProtoStringType> item_map;
+
+ // Adds "DESCRIPTOR" into item_map.
+ item_map["DESCRIPTOR"] = "_descriptor.FileDescriptor";
+ PrintImports(&item_map);
+ // Adds top level enum values to item_map.
+ for (int i = 0; i < file_->enum_type_count(); ++i) {
+ AddEnumValue(*file_->enum_type(i), &item_map);
+ }
+ // Adds top level extensions to item_map.
+ AddExtensions(*file_, &item_map);
+ // Prints item map
+ PrintItemMap(item_map);
+
+ PrintMessages();
+ PrintTopLevelEnums();
+ if (HasGenericServices(file)) {
+ PrintServices();
+ }
+ return true;
+}
+
+} // namespace python
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h
new file mode 100644
index 0000000000..d7f5437e49
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h
@@ -0,0 +1,104 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: jieluo@google.com (Jie Luo)
+//
+// Generates Python stub (.pyi) for a given .proto file.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
+
+#include <map>
+#include <string>
+
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/stubs/mutex.h>
+
+// Must be included last.
+#include <google/protobuf/port_def.inc>
+
+namespace google {
+namespace protobuf {
+class Descriptor;
+class EnumDescriptor;
+class FieldDescriptor;
+class MethodDescriptor;
+class ServiceDescriptor;
+
+namespace io {
+class Printer;
+}
+
+namespace compiler {
+namespace python {
+
+class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenerator {
+ public:
+ PyiGenerator();
+ ~PyiGenerator() override;
+
+ // CodeGenerator methods.
+ bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
+ GeneratorContext* generator_context,
+ TProtoStringType* error) const override;
+
+ private:
+ void PrintImports(std::map<TProtoStringType, TProtoStringType>* item_map) const;
+ void PrintEnum(const EnumDescriptor& enum_descriptor) const;
+ void AddEnumValue(const EnumDescriptor& enum_descriptor,
+ std::map<TProtoStringType, TProtoStringType>* item_map) const;
+ void PrintTopLevelEnums() const;
+ template <typename DescriptorT>
+ void AddExtensions(const DescriptorT& descriptor,
+ std::map<TProtoStringType, TProtoStringType>* item_map) const;
+ void PrintMessages() const;
+ void PrintMessage(const Descriptor& message_descriptor, bool is_nested) const;
+ void PrintServices() const;
+ void PrintItemMap(const std::map<TProtoStringType, TProtoStringType>& item_map) const;
+ TProtoStringType GetFieldType(const FieldDescriptor& field_des) const;
+ template <typename DescriptorT>
+ TProtoStringType ModuleLevelName(const DescriptorT& descriptor) const;
+
+ // Very coarse-grained lock to ensure that Generate() is reentrant.
+ // Guards file_ and printer_.
+ mutable Mutex mutex_;
+ mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_.
+ mutable io::Printer* printer_; // Set in Generate(). Under mutex_.
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PyiGenerator);
+};
+
+} // namespace python
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
+#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc
index d4b4b482d6..0e85c22f1e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc
@@ -421,7 +421,7 @@ int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) {
// -> A.B.C
if (package_name.find("::") != TProtoStringType::npos) {
need_change_to_module = false;
- } else {
+ } else if (package_name.find(".") != TProtoStringType::npos) {
GOOGLE_LOG(WARNING) << "ruby_package option should be in the form of:"
<< " 'A::B::C' and not 'A.B.C'";
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/scc.h b/contrib/libs/protoc/src/google/protobuf/compiler/scc.h
index a1394602f7..7b95689d7a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/scc.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/scc.h
@@ -37,6 +37,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
index 9a660733b3..1d01fb7e83 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
@@ -55,7 +55,7 @@ namespace compiler {
namespace {
char* portable_strdup(const char* s) {
char* ns = (char*)malloc(strlen(s) + 1);
- if (ns != NULL) {
+ if (ns != nullptr) {
strcpy(ns, s);
}
return ns;
@@ -73,15 +73,15 @@ static void CloseHandleOrDie(HANDLE handle) {
Subprocess::Subprocess()
: process_start_error_(ERROR_SUCCESS),
- child_handle_(NULL),
- child_stdin_(NULL),
- child_stdout_(NULL) {}
+ child_handle_(nullptr),
+ child_stdin_(nullptr),
+ child_stdout_(nullptr) {}
Subprocess::~Subprocess() {
- if (child_stdin_ != NULL) {
+ if (child_stdin_ != nullptr) {
CloseHandleOrDie(child_stdin_);
}
- if (child_stdout_ != NULL) {
+ if (child_stdout_ != nullptr) {
CloseHandleOrDie(child_stdout_);
}
}
@@ -93,10 +93,10 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
HANDLE stdout_pipe_read;
HANDLE stdout_pipe_write;
- if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) {
+ if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) {
GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
}
- if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) {
+ if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) {
GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
}
@@ -134,14 +134,14 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
// Create the process.
PROCESS_INFORMATION process_info;
- if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(),
- (search_mode == SEARCH_PATH) ? command_line : NULL,
- NULL, // process security attributes
- NULL, // thread security attributes
- TRUE, // inherit handles?
- 0, // obscure creation flags
- NULL, // environment (inherit from parent)
- NULL, // current directory (inherit from parent)
+ if (CreateProcessA((search_mode == SEARCH_PATH) ? nullptr : program.c_str(),
+ (search_mode == SEARCH_PATH) ? command_line : nullptr,
+ nullptr, // process security attributes
+ nullptr, // thread security attributes
+ TRUE, // inherit handles?
+ 0, // obscure creation flags
+ nullptr, // environment (inherit from parent)
+ nullptr, // current directory (inherit from parent)
&startup_info, &process_info)) {
child_handle_ = process_info.hProcess;
CloseHandleOrDie(process_info.hThread);
@@ -165,28 +165,28 @@ bool Subprocess::Communicate(const Message& input, Message* output,
return false;
}
- GOOGLE_CHECK(child_handle_ != NULL) << "Must call Start() first.";
+ GOOGLE_CHECK(child_handle_ != nullptr) << "Must call Start() first.";
TProtoStringType input_data = input.SerializeAsString();
TProtoStringType output_data;
int input_pos = 0;
- while (child_stdout_ != NULL) {
+ while (child_stdout_ != nullptr) {
HANDLE handles[2];
int handle_count = 0;
- if (child_stdin_ != NULL) {
+ if (child_stdin_ != nullptr) {
handles[handle_count++] = child_stdin_;
}
- if (child_stdout_ != NULL) {
+ if (child_stdout_ != nullptr) {
handles[handle_count++] = child_stdout_;
}
DWORD wait_result =
WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE);
- HANDLE signaled_handle = NULL;
+ HANDLE signaled_handle = nullptr;
if (wait_result >= WAIT_OBJECT_0 &&
wait_result < WAIT_OBJECT_0 + handle_count) {
signaled_handle = handles[wait_result - WAIT_OBJECT_0];
@@ -201,7 +201,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
if (signaled_handle == child_stdin_) {
DWORD n;
if (!WriteFile(child_stdin_, input_data.data() + input_pos,
- input_data.size() - input_pos, &n, NULL)) {
+ input_data.size() - input_pos, &n, nullptr)) {
// Child closed pipe. Presumably it will report an error later.
// Pretend we're done for now.
input_pos = input_data.size();
@@ -212,27 +212,27 @@ bool Subprocess::Communicate(const Message& input, Message* output,
if (input_pos == input_data.size()) {
// We're done writing. Close.
CloseHandleOrDie(child_stdin_);
- child_stdin_ = NULL;
+ child_stdin_ = nullptr;
}
} else if (signaled_handle == child_stdout_) {
char buffer[4096];
DWORD n;
- if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) {
+ if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, nullptr)) {
// We're done reading. Close.
CloseHandleOrDie(child_stdout_);
- child_stdout_ = NULL;
+ child_stdout_ = nullptr;
} else {
output_data.append(buffer, n);
}
}
}
- if (child_stdin_ != NULL) {
+ if (child_stdin_ != nullptr) {
// Child did not finish reading input before it closed the output.
// Presumably it exited with an error.
CloseHandleOrDie(child_stdin_);
- child_stdin_ = NULL;
+ child_stdin_ = nullptr;
}
DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);
@@ -252,7 +252,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
}
CloseHandleOrDie(child_handle_);
- child_handle_ = NULL;
+ child_handle_ = nullptr;
if (exit_code != 0) {
*error = strings::Substitute("Plugin failed with status code $0.", exit_code);
@@ -273,9 +273,10 @@ TProtoStringType Subprocess::Win32ErrorMessage(DWORD error_code) {
// WTF?
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+ nullptr, error_code,
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPSTR)&message, // NOT A BUG!
- 0, NULL);
+ 0, nullptr);
TProtoStringType result = message;
LocalFree(message);
@@ -309,7 +310,7 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
GOOGLE_CHECK(pipe(stdin_pipe) != -1);
GOOGLE_CHECK(pipe(stdout_pipe) != -1);
- char* argv[2] = {portable_strdup(program.c_str()), NULL};
+ char* argv[2] = {portable_strdup(program.c_str()), nullptr};
child_pid_ = fork();
if (child_pid_ == -1) {
@@ -386,7 +387,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
FD_SET(child_stdin_, &write_fds);
}
- if (select(max_fd + 1, &read_fds, &write_fds, NULL, NULL) < 0) {
+ if (select(max_fd + 1, &read_fds, &write_fds, nullptr, nullptr) < 0) {
if (errno == EINTR) {
// Interrupted by signal. Try again.
continue;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
index ed9790f9b5..a6a320ab47 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
@@ -46,6 +46,7 @@
#include <string>
+// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
diff --git a/contrib/libs/protoc/ya.make b/contrib/libs/protoc/ya.make
index 518ae0c171..068322bd35 100644
--- a/contrib/libs/protoc/ya.make
+++ b/contrib/libs/protoc/ya.make
@@ -9,24 +9,31 @@ LICENSE(
PROVIDES(protoc)
-VERSION(3.19.0)
+VERSION(3.20.2)
-ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.19.0.tar.gz)
+ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.20.2.tar.gz)
IF (OPENSOURCE_REPLACE_PROTOBUF AND EXPORT_CMAKE)
-
OPENSOURCE_EXPORT_REPLACEMENT(
- CMAKE Protobuf
- CMAKE_TARGET protobuf::libprotobuf protobuf::libprotoc
- CONAN protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan-requires" protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan_require_tool" protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan-tool_requires" protobuf/${OPENSOURCE_REPLACE_PROTOBUF} "&& conan_import \"bin, protoc* -> ./bin\" && conan-imports \"bin, protoc* -> ./bin\" && vanilla_protobuf"
+ CMAKE
+ Protobuf
+ CMAKE_TARGET
+ protobuf::libprotobuf
+ protobuf::libprotoc
+ CONAN
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan-requires"
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan_require_tool"
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan-tool_requires"
+ protobuf/${OPENSOURCE_REPLACE_PROTOBUF}
+ "&& conan_import \"bin, protoc* -> ./bin\" && conan-imports 'bin, protoc* -> ./bin' && vanilla_protobuf"
)
-
ELSE()
-
ADDINCL(
GLOBAL contrib/libs/protoc/src
)
-
ENDIF()
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
@@ -130,6 +137,8 @@ SRCS(
src/google/protobuf/compiler/plugin.cc
src/google/protobuf/compiler/plugin.pb.cc
src/google/protobuf/compiler/python/python_generator.cc
+ src/google/protobuf/compiler/python/python_helpers.cc
+ src/google/protobuf/compiler/python/python_pyi_generator.cc
src/google/protobuf/compiler/ruby/ruby_generator.cc
src/google/protobuf/compiler/subprocess.cc
src/google/protobuf/compiler/zip_writer.cc
diff --git a/contrib/python/protobuf/py3/.dist-info/METADATA b/contrib/python/protobuf/py3/.dist-info/METADATA
index 79a3401f13..13ac7d644c 100644
--- a/contrib/python/protobuf/py3/.dist-info/METADATA
+++ b/contrib/python/protobuf/py3/.dist-info/METADATA
@@ -1,22 +1,20 @@
Metadata-Version: 2.1
Name: protobuf
-Version: 3.19.0
+Version: 3.20.3
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Download-URL: https://github.com/protocolbuffers/protobuf/releases
Maintainer: protobuf@googlegroups.com
Maintainer-email: protobuf@googlegroups.com
-License: 3-Clause BSD License
+License: BSD-3-Clause
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
-Requires-Python: >=3.5
+Requires-Python: >=3.7
License-File: LICENSE
Protocol Buffers are Google's data interchange format
diff --git a/contrib/python/protobuf/py3/README.md b/contrib/python/protobuf/py3/README.md
index f0c9ce4f44..27f22c82c0 100644
--- a/contrib/python/protobuf/py3/README.md
+++ b/contrib/python/protobuf/py3/README.md
@@ -26,7 +26,7 @@ use python c++ implementation.
Installation
============
-1) Make sure you have Python 3.5 or newer. If in doubt, run:
+1) Make sure you have Python 3.7 or newer. If in doubt, run:
$ python -V
diff --git a/contrib/python/protobuf/py3/google/protobuf/__init__.py b/contrib/python/protobuf/py3/google/protobuf/__init__.py
index 68087e5501..3087605b2e 100644
--- a/contrib/python/protobuf/py3/google/protobuf/__init__.py
+++ b/contrib/python/protobuf/py3/google/protobuf/__init__.py
@@ -30,4 +30,4 @@
# Copyright 2007 Google Inc. All Rights Reserved.
-__version__ = '3.19.0'
+__version__ = '3.20.3'
diff --git a/contrib/python/protobuf/py3/google/protobuf/descriptor.py b/contrib/python/protobuf/py3/google/protobuf/descriptor.py
index 61c242f9df..ad70be9a11 100644
--- a/contrib/python/protobuf/py3/google/protobuf/descriptor.py
+++ b/contrib/python/protobuf/py3/google/protobuf/descriptor.py
@@ -617,6 +617,26 @@ class FieldDescriptor(DescriptorBase):
self._camelcase_name = _ToCamelCase(self.name)
return self._camelcase_name
+ @property
+ def has_presence(self):
+ """Whether the field distinguishes between unpopulated and default values.
+
+ Raises:
+ RuntimeError: singular field that is not linked with message nor file.
+ """
+ if self.label == FieldDescriptor.LABEL_REPEATED:
+ return False
+ if (self.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE or
+ self.containing_oneof):
+ return True
+ if hasattr(self.file, 'syntax'):
+ return self.file.syntax == 'proto2'
+ if hasattr(self.message_type, 'syntax'):
+ return self.message_type.syntax == 'proto2'
+ raise RuntimeError(
+ 'has_presence is not ready to use because field %s is not'
+ ' linked with message type nor file' % self.full_name)
+
@staticmethod
def ProtoTypeToCppProtoType(proto_type):
"""Converts from a Python proto type to a C++ Proto Type.
@@ -647,7 +667,7 @@ class EnumDescriptor(_NestedDescriptorBase):
full_name (str): Full name of the type, including package name
and any enclosing type(s).
- values (list[EnumValueDescriptors]): List of the values
+ values (list[EnumValueDescriptor]): List of the values
in this enum.
values_by_name (dict(str, EnumValueDescriptor)): Same as :attr:`values`,
but indexed by the "name" field of each EnumValueDescriptor.
@@ -879,6 +899,8 @@ class MethodDescriptor(DescriptorBase):
accepts.
output_type (Descriptor): The descriptor of the message that this method
returns.
+ client_streaming (bool): Whether this method uses client streaming.
+ server_streaming (bool): Whether this method uses server streaming.
options (descriptor_pb2.MethodOptions or None): Method options message, or
None to use default method options.
"""
@@ -886,14 +908,32 @@ class MethodDescriptor(DescriptorBase):
if _USE_C_DESCRIPTORS:
_C_DESCRIPTOR_CLASS = _message.MethodDescriptor
- def __new__(cls, name, full_name, index, containing_service,
- input_type, output_type, options=None, serialized_options=None,
+ def __new__(cls,
+ name,
+ full_name,
+ index,
+ containing_service,
+ input_type,
+ output_type,
+ client_streaming=False,
+ server_streaming=False,
+ 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,
+ def __init__(self,
+ name,
+ full_name,
+ index,
+ containing_service,
+ input_type,
+ output_type,
+ client_streaming=False,
+ server_streaming=False,
+ options=None,
+ serialized_options=None,
create_key=None):
"""The arguments are as described in the description of MethodDescriptor
attributes above.
@@ -911,6 +951,8 @@ class MethodDescriptor(DescriptorBase):
self.containing_service = containing_service
self.input_type = input_type
self.output_type = output_type
+ self.client_streaming = client_streaming
+ self.server_streaming = server_streaming
def CopyToProto(self, proto):
"""Copies this to a descriptor_pb2.MethodDescriptorProto.
diff --git a/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py b/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py
index a6955ce81e..911372a8b0 100644
--- a/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py
+++ b/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py
@@ -1213,6 +1213,8 @@ class DescriptorPool(object):
containing_service=None,
input_type=input_type,
output_type=output_type,
+ client_streaming=method_proto.client_streaming,
+ server_streaming=method_proto.server_streaming,
options=_OptionsOrNone(method_proto),
# pylint: disable=protected-access
create_key=descriptor._internal_create_key)
@@ -1233,21 +1235,25 @@ class DescriptorPool(object):
for enum in desc.enum_types:
yield (_PrefixWithDot(enum.full_name), enum)
- def _GetDeps(self, dependencies):
+ def _GetDeps(self, dependencies, visited=None):
"""Recursively finds dependencies for file protos.
Args:
dependencies: The names of the files being depended on.
+ visited: The names of files already found.
Yields:
Each direct and indirect dependency.
"""
+ visited = visited or set()
for dependency in dependencies:
- dep_desc = self.FindFileByName(dependency)
- yield dep_desc
- for parent_dep in dep_desc.dependencies:
- yield parent_dep
+ if dependency not in visited:
+ visited.add(dependency)
+ dep_desc = self.FindFileByName(dependency)
+ yield dep_desc
+ public_files = [d.name for d in dep_desc.public_dependencies]
+ yield from self._GetDeps(public_files, visited)
def _GetTypeFromScope(self, package, type_name, scope):
"""Finds a given type name in the current scope.
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc b/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc
index 6532a81405..33f5b04f49 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc
@@ -28,6 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
namespace google {
@@ -81,24 +82,24 @@ static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
kModuleName,
kModuleDocstring,
-1,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL};
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr};
extern "C" {
PyMODINIT_FUNC PyInit__api_implementation() {
PyObject* module = PyModule_Create(&_module);
- if (module == NULL) {
- return NULL;
+ if (module == nullptr) {
+ return nullptr;
}
// Adds the module variable "api_version".
if (PyModule_AddIntConstant(module, const_cast<char*>(kImplVersionName),
kImplVersion)) {
Py_DECREF(module);
- return NULL;
+ return nullptr;
}
return module;
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/builder.py b/contrib/python/protobuf/py3/google/protobuf/internal/builder.py
new file mode 100644
index 0000000000..64353ee4af
--- /dev/null
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/builder.py
@@ -0,0 +1,130 @@
+# 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.
+
+"""Builds descriptors, message classes and services for generated _pb2.py.
+
+This file is only called in python generated _pb2.py files. It builds
+descriptors, message classes and services that users can directly use
+in generated code.
+"""
+
+__author__ = 'jieluo@google.com (Jie Luo)'
+
+from google.protobuf.internal import enum_type_wrapper
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+
+_sym_db = _symbol_database.Default()
+
+
+def BuildMessageAndEnumDescriptors(file_des, module):
+ """Builds message and enum descriptors.
+
+ Args:
+ file_des: FileDescriptor of the .proto file
+ module: Generated _pb2 module
+ """
+
+ def BuildNestedDescriptors(msg_des, prefix):
+ for (name, nested_msg) in msg_des.nested_types_by_name.items():
+ module_name = prefix + name.upper()
+ module[module_name] = nested_msg
+ BuildNestedDescriptors(nested_msg, module_name + '_')
+ for enum_des in msg_des.enum_types:
+ module[prefix + enum_des.name.upper()] = enum_des
+
+ for (name, msg_des) in file_des.message_types_by_name.items():
+ module_name = '_' + name.upper()
+ module[module_name] = msg_des
+ BuildNestedDescriptors(msg_des, module_name + '_')
+
+
+def BuildTopDescriptorsAndMessages(file_des, module_name, module):
+ """Builds top level descriptors and message classes.
+
+ Args:
+ file_des: FileDescriptor of the .proto file
+ module_name: str, the name of generated _pb2 module
+ module: Generated _pb2 module
+ """
+
+ def BuildMessage(msg_des):
+ create_dict = {}
+ for (name, nested_msg) in msg_des.nested_types_by_name.items():
+ create_dict[name] = BuildMessage(nested_msg)
+ create_dict['DESCRIPTOR'] = msg_des
+ create_dict['__module__'] = module_name
+ message_class = _reflection.GeneratedProtocolMessageType(
+ msg_des.name, (_message.Message,), create_dict)
+ _sym_db.RegisterMessage(message_class)
+ return message_class
+
+ # top level enums
+ for (name, enum_des) in file_des.enum_types_by_name.items():
+ module['_' + name.upper()] = enum_des
+ module[name] = enum_type_wrapper.EnumTypeWrapper(enum_des)
+ for enum_value in enum_des.values:
+ module[enum_value.name] = enum_value.number
+
+ # top level extensions
+ for (name, extension_des) in file_des.extensions_by_name.items():
+ module[name.upper() + '_FIELD_NUMBER'] = extension_des.number
+ module[name] = extension_des
+
+ # services
+ for (name, service) in file_des.services_by_name.items():
+ module['_' + name.upper()] = service
+
+ # Build messages.
+ for (name, msg_des) in file_des.message_types_by_name.items():
+ module[name] = BuildMessage(msg_des)
+
+
+def BuildServices(file_des, module_name, module):
+ """Builds services classes and services stub class.
+
+ Args:
+ file_des: FileDescriptor of the .proto file
+ module_name: str, the name of generated _pb2 module
+ module: Generated _pb2 module
+ """
+ # pylint: disable=g-import-not-at-top
+ from google.protobuf import service as _service
+ from google.protobuf import service_reflection
+ # pylint: enable=g-import-not-at-top
+ for (name, service) in file_des.services_by_name.items():
+ module[name] = service_reflection.GeneratedServiceType(
+ name, (_service.Service,),
+ dict(DESCRIPTOR=service, __module__=module_name))
+ stub_name = name + '_Stub'
+ module[stub_name] = service_reflection.GeneratedServiceStubType(
+ stub_name, (module[name],),
+ dict(DESCRIPTOR=service, __module__=module_name))
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/containers.py b/contrib/python/protobuf/py3/google/protobuf/internal/containers.py
index f0c06df8dd..29fbb53d2f 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/containers.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/containers.py
@@ -40,19 +40,37 @@ are:
includes groups and nested messages.
"""
-__author__ = 'petar@google.com (Petar Petrov)'
-
import collections.abc
-
-
-class BaseContainer(object):
-
+import copy
+import pickle
+from typing import (
+ Any,
+ Iterable,
+ Iterator,
+ List,
+ MutableMapping,
+ MutableSequence,
+ NoReturn,
+ Optional,
+ Sequence,
+ TypeVar,
+ Union,
+ overload,
+)
+
+
+_T = TypeVar('_T')
+_K = TypeVar('_K')
+_V = TypeVar('_V')
+
+
+class BaseContainer(Sequence[_T]):
"""Base container class."""
# Minimizes memory usage and disallows assignment to other attributes.
__slots__ = ['_message_listener', '_values']
- def __init__(self, message_listener):
+ def __init__(self, message_listener: Any) -> None:
"""
Args:
message_listener: A MessageListener implementation.
@@ -62,26 +80,33 @@ class BaseContainer(object):
self._message_listener = message_listener
self._values = []
+ @overload
+ def __getitem__(self, key: int) -> _T:
+ ...
+
+ @overload
+ def __getitem__(self, key: slice) -> List[_T]:
+ ...
+
def __getitem__(self, key):
"""Retrieves item by the specified key."""
return self._values[key]
- def __len__(self):
+ def __len__(self) -> int:
"""Returns the number of elements in the container."""
return len(self._values)
- def __ne__(self, other):
+ def __ne__(self, other: Any) -> bool:
"""Checks if another instance isn't equal to this one."""
# The concrete classes should define __eq__.
return not self == other
- def __hash__(self):
- raise TypeError('unhashable object')
+ __hash__ = None
- def __repr__(self):
+ def __repr__(self) -> str:
return repr(self._values)
- def sort(self, *args, **kwargs):
+ def sort(self, *args, **kwargs) -> None:
# Continue to support the old sort_function keyword argument.
# This is expected to be a rare occurrence, so use LBYL to avoid
# the overhead of actually catching KeyError.
@@ -89,20 +114,26 @@ class BaseContainer(object):
kwargs['cmp'] = kwargs.pop('sort_function')
self._values.sort(*args, **kwargs)
- def reverse(self):
+ def reverse(self) -> None:
self._values.reverse()
+# TODO(slebedev): Remove this. BaseContainer does *not* conform to
+# MutableSequence, only its subclasses do.
collections.abc.MutableSequence.register(BaseContainer)
-class RepeatedScalarFieldContainer(BaseContainer):
+class RepeatedScalarFieldContainer(BaseContainer[_T], MutableSequence[_T]):
"""Simple, type-checked, list-like container for holding repeated scalars."""
# Disallows assignment to other attributes.
__slots__ = ['_type_checker']
- def __init__(self, message_listener, type_checker):
+ def __init__(
+ self,
+ message_listener: Any,
+ type_checker: Any,
+ ) -> None:
"""Args:
message_listener: A MessageListener implementation. The
@@ -111,24 +142,23 @@ class RepeatedScalarFieldContainer(BaseContainer):
type_checker: A type_checkers.ValueChecker instance to run on elements
inserted into this container.
"""
- super(RepeatedScalarFieldContainer, self).__init__(message_listener)
+ super().__init__(message_listener)
self._type_checker = type_checker
- def append(self, value):
+ def append(self, value: _T) -> None:
"""Appends an item to the list. Similar to list.append()."""
self._values.append(self._type_checker.CheckValue(value))
if not self._message_listener.dirty:
self._message_listener.Modified()
- def insert(self, key, value):
+ def insert(self, key: int, value: _T) -> None:
"""Inserts the item at the specified position. Similar to list.insert()."""
self._values.insert(key, self._type_checker.CheckValue(value))
if not self._message_listener.dirty:
self._message_listener.Modified()
- def extend(self, elem_seq):
+ def extend(self, elem_seq: Iterable[_T]) -> None:
"""Extends by appending the given iterable. Similar to list.extend()."""
-
if elem_seq is None:
return
try:
@@ -145,57 +175,52 @@ class RepeatedScalarFieldContainer(BaseContainer):
self._values.extend(new_values)
self._message_listener.Modified()
- def MergeFrom(self, other):
+ def MergeFrom(
+ self,
+ other: Union['RepeatedScalarFieldContainer[_T]', Iterable[_T]],
+ ) -> None:
"""Appends the contents of another repeated field of the same type to this
one. We do not check the types of the individual fields.
"""
- self._values.extend(other._values)
+ self._values.extend(other)
self._message_listener.Modified()
- def remove(self, elem):
+ def remove(self, elem: _T):
"""Removes an item from the list. Similar to list.remove()."""
self._values.remove(elem)
self._message_listener.Modified()
- def pop(self, key=-1):
+ def pop(self, key: Optional[int] = -1) -> _T:
"""Removes and returns an item at a given index. Similar to list.pop()."""
value = self._values[key]
self.__delitem__(key)
return value
- def __setitem__(self, key, value):
+ @overload
+ def __setitem__(self, key: int, value: _T) -> None:
+ ...
+
+ @overload
+ def __setitem__(self, key: slice, value: Iterable[_T]) -> None:
+ ...
+
+ def __setitem__(self, key, value) -> None:
"""Sets the item on the specified position."""
- if isinstance(key, slice): # PY3
+ if isinstance(key, slice):
if key.step is not None:
raise ValueError('Extended slices not supported')
- self.__setslice__(key.start, key.stop, value)
+ self._values[key] = map(self._type_checker.CheckValue, value)
+ self._message_listener.Modified()
else:
self._values[key] = self._type_checker.CheckValue(value)
self._message_listener.Modified()
- def __getslice__(self, start, stop):
- """Retrieves the subset of items from between the specified indices."""
- return self._values[start:stop]
-
- def __setslice__(self, start, stop, values):
- """Sets the subset of items from between the specified indices."""
- new_values = []
- for value in values:
- new_values.append(self._type_checker.CheckValue(value))
- self._values[start:stop] = new_values
- self._message_listener.Modified()
-
- def __delitem__(self, key):
+ def __delitem__(self, key: Union[int, slice]) -> None:
"""Deletes the item at the specified position."""
del self._values[key]
self._message_listener.Modified()
- def __delslice__(self, start, stop):
- """Deletes the subset of items from between the specified indices."""
- del self._values[start:stop]
- self._message_listener.Modified()
-
- def __eq__(self, other):
+ def __eq__(self, other: Any) -> bool:
"""Compares the current instance with another one."""
if self is other:
return True
@@ -205,15 +230,28 @@ class RepeatedScalarFieldContainer(BaseContainer):
# We are presumably comparing against some other sequence type.
return other == self._values
+ def __deepcopy__(
+ self,
+ unused_memo: Any = None,
+ ) -> 'RepeatedScalarFieldContainer[_T]':
+ clone = RepeatedScalarFieldContainer(
+ copy.deepcopy(self._message_listener), self._type_checker)
+ clone.MergeFrom(self)
+ return clone
+
+ def __reduce__(self, **kwargs) -> NoReturn:
+ raise pickle.PickleError(
+ "Can't pickle repeated scalar fields, convert to list first")
-class RepeatedCompositeFieldContainer(BaseContainer):
+# TODO(slebedev): Constrain T to be a subtype of Message.
+class RepeatedCompositeFieldContainer(BaseContainer[_T], MutableSequence[_T]):
"""Simple, list-like container for holding repeated composite fields."""
# Disallows assignment to other attributes.
__slots__ = ['_message_descriptor']
- def __init__(self, message_listener, message_descriptor):
+ def __init__(self, message_listener: Any, message_descriptor: Any) -> None:
"""
Note that we pass in a descriptor instead of the generated directly,
since at the time we construct a _RepeatedCompositeFieldContainer we
@@ -228,10 +266,10 @@ class RepeatedCompositeFieldContainer(BaseContainer):
that should be present in this container. We'll use the
_concrete_class field of this descriptor when the client calls add().
"""
- super(RepeatedCompositeFieldContainer, self).__init__(message_listener)
+ super().__init__(message_listener)
self._message_descriptor = message_descriptor
- def add(self, **kwargs):
+ def add(self, **kwargs: Any) -> _T:
"""Adds a new element at the end of the list and returns it. Keyword
arguments may be used to initialize the element.
"""
@@ -242,7 +280,7 @@ class RepeatedCompositeFieldContainer(BaseContainer):
self._message_listener.Modified()
return new_element
- def append(self, value):
+ def append(self, value: _T) -> None:
"""Appends one element by copying the message."""
new_element = self._message_descriptor._concrete_class()
new_element._SetListener(self._message_listener)
@@ -251,7 +289,7 @@ class RepeatedCompositeFieldContainer(BaseContainer):
if not self._message_listener.dirty:
self._message_listener.Modified()
- def insert(self, key, value):
+ def insert(self, key: int, value: _T) -> None:
"""Inserts the item at the specified position by copying."""
new_element = self._message_descriptor._concrete_class()
new_element._SetListener(self._message_listener)
@@ -260,7 +298,7 @@ class RepeatedCompositeFieldContainer(BaseContainer):
if not self._message_listener.dirty:
self._message_listener.Modified()
- def extend(self, elem_seq):
+ def extend(self, elem_seq: Iterable[_T]) -> None:
"""Extends by appending the given sequence of elements of the same type
as this one, copying each individual message.
@@ -275,38 +313,47 @@ class RepeatedCompositeFieldContainer(BaseContainer):
values.append(new_element)
listener.Modified()
- def MergeFrom(self, other):
+ def MergeFrom(
+ self,
+ other: Union['RepeatedCompositeFieldContainer[_T]', Iterable[_T]],
+ ) -> None:
"""Appends the contents of another repeated field of the same type to this
one, copying each individual message.
"""
- self.extend(other._values)
+ self.extend(other)
- def remove(self, elem):
+ def remove(self, elem: _T) -> None:
"""Removes an item from the list. Similar to list.remove()."""
self._values.remove(elem)
self._message_listener.Modified()
- def pop(self, key=-1):
+ def pop(self, key: Optional[int] = -1) -> _T:
"""Removes and returns an item at a given index. Similar to list.pop()."""
value = self._values[key]
self.__delitem__(key)
return value
- def __getslice__(self, start, stop):
- """Retrieves the subset of items from between the specified indices."""
- return self._values[start:stop]
+ @overload
+ def __setitem__(self, key: int, value: _T) -> None:
+ ...
+
+ @overload
+ def __setitem__(self, key: slice, value: Iterable[_T]) -> None:
+ ...
+
+ def __setitem__(self, key, value):
+ # This method is implemented to make RepeatedCompositeFieldContainer
+ # structurally compatible with typing.MutableSequence. It is
+ # otherwise unsupported and will always raise an error.
+ raise TypeError(
+ f'{self.__class__.__name__} object does not support item assignment')
- def __delitem__(self, key):
+ def __delitem__(self, key: Union[int, slice]) -> None:
"""Deletes the item at the specified position."""
del self._values[key]
self._message_listener.Modified()
- def __delslice__(self, start, stop):
- """Deletes the subset of items from between the specified indices."""
- del self._values[start:stop]
- self._message_listener.Modified()
-
- def __eq__(self, other):
+ def __eq__(self, other: Any) -> bool:
"""Compares the current instance with another one."""
if self is other:
return True
@@ -316,16 +363,20 @@ class RepeatedCompositeFieldContainer(BaseContainer):
return self._values == other._values
-class ScalarMap(collections.abc.MutableMapping):
-
+class ScalarMap(MutableMapping[_K, _V]):
"""Simple, type-checked, dict-like container for holding repeated scalars."""
# Disallows assignment to other attributes.
__slots__ = ['_key_checker', '_value_checker', '_values', '_message_listener',
'_entry_descriptor']
- def __init__(self, message_listener, key_checker, value_checker,
- entry_descriptor):
+ def __init__(
+ self,
+ message_listener: Any,
+ key_checker: Any,
+ value_checker: Any,
+ entry_descriptor: Any,
+ ) -> None:
"""
Args:
message_listener: A MessageListener implementation.
@@ -343,7 +394,7 @@ class ScalarMap(collections.abc.MutableMapping):
self._entry_descriptor = entry_descriptor
self._values = {}
- def __getitem__(self, key):
+ def __getitem__(self, key: _K) -> _V:
try:
return self._values[key]
except KeyError:
@@ -352,12 +403,20 @@ class ScalarMap(collections.abc.MutableMapping):
self._values[key] = val
return val
- def __contains__(self, item):
+ def __contains__(self, item: _K) -> bool:
# We check the key's type to match the strong-typing flavor of the API.
# Also this makes it easier to match the behavior of the C++ implementation.
self._key_checker.CheckValue(item)
return item in self._values
+ @overload
+ def get(self, key: _K) -> Optional[_V]:
+ ...
+
+ @overload
+ def get(self, key: _K, default: _T) -> Union[_V, _T]:
+ ...
+
# We need to override this explicitly, because our defaultdict-like behavior
# will make the default implementation (from our base class) always insert
# the key.
@@ -367,30 +426,30 @@ class ScalarMap(collections.abc.MutableMapping):
else:
return default
- def __setitem__(self, key, value):
+ def __setitem__(self, key: _K, value: _V) -> _T:
checked_key = self._key_checker.CheckValue(key)
checked_value = self._value_checker.CheckValue(value)
self._values[checked_key] = checked_value
self._message_listener.Modified()
- def __delitem__(self, key):
+ def __delitem__(self, key: _K) -> None:
del self._values[key]
self._message_listener.Modified()
- def __len__(self):
+ def __len__(self) -> int:
return len(self._values)
- def __iter__(self):
+ def __iter__(self) -> Iterator[_K]:
return iter(self._values)
- def __repr__(self):
+ def __repr__(self) -> str:
return repr(self._values)
- def MergeFrom(self, other):
+ def MergeFrom(self, other: 'ScalarMap[_K, _V]') -> None:
self._values.update(other._values)
self._message_listener.Modified()
- def InvalidateIterators(self):
+ def InvalidateIterators(self) -> None:
# It appears that the only way to reliably invalidate iterators to
# self._values is to ensure that its size changes.
original = self._values
@@ -398,24 +457,28 @@ class ScalarMap(collections.abc.MutableMapping):
original[None] = None
# This is defined in the abstract base, but we can do it much more cheaply.
- def clear(self):
+ def clear(self) -> None:
self._values.clear()
self._message_listener.Modified()
- def GetEntryClass(self):
+ def GetEntryClass(self) -> Any:
return self._entry_descriptor._concrete_class
-class MessageMap(collections.abc.MutableMapping):
-
+class MessageMap(MutableMapping[_K, _V]):
"""Simple, type-checked, dict-like container for with submessage values."""
# Disallows assignment to other attributes.
__slots__ = ['_key_checker', '_values', '_message_listener',
'_message_descriptor', '_entry_descriptor']
- def __init__(self, message_listener, message_descriptor, key_checker,
- entry_descriptor):
+ def __init__(
+ self,
+ message_listener: Any,
+ message_descriptor: Any,
+ key_checker: Any,
+ entry_descriptor: Any,
+ ) -> None:
"""
Args:
message_listener: A MessageListener implementation.
@@ -433,7 +496,7 @@ class MessageMap(collections.abc.MutableMapping):
self._entry_descriptor = entry_descriptor
self._values = {}
- def __getitem__(self, key):
+ def __getitem__(self, key: _K) -> _V:
key = self._key_checker.CheckValue(key)
try:
return self._values[key]
@@ -442,10 +505,9 @@ class MessageMap(collections.abc.MutableMapping):
new_element._SetListener(self._message_listener)
self._values[key] = new_element
self._message_listener.Modified()
-
return new_element
- def get_or_create(self, key):
+ def get_or_create(self, key: _K) -> _V:
"""get_or_create() is an alias for getitem (ie. map[key]).
Args:
@@ -459,6 +521,14 @@ class MessageMap(collections.abc.MutableMapping):
"""
return self[key]
+ @overload
+ def get(self, key: _K) -> Optional[_V]:
+ ...
+
+ @overload
+ def get(self, key: _K, default: _T) -> Union[_V, _T]:
+ ...
+
# We need to override this explicitly, because our defaultdict-like behavior
# will make the default implementation (from our base class) always insert
# the key.
@@ -468,28 +538,28 @@ class MessageMap(collections.abc.MutableMapping):
else:
return default
- def __contains__(self, item):
+ def __contains__(self, item: _K) -> bool:
item = self._key_checker.CheckValue(item)
return item in self._values
- def __setitem__(self, key, value):
+ def __setitem__(self, key: _K, value: _V) -> NoReturn:
raise ValueError('May not set values directly, call my_map[key].foo = 5')
- def __delitem__(self, key):
+ def __delitem__(self, key: _K) -> None:
key = self._key_checker.CheckValue(key)
del self._values[key]
self._message_listener.Modified()
- def __len__(self):
+ def __len__(self) -> int:
return len(self._values)
- def __iter__(self):
+ def __iter__(self) -> Iterator[_K]:
return iter(self._values)
- def __repr__(self):
+ def __repr__(self) -> str:
return repr(self._values)
- def MergeFrom(self, other):
+ def MergeFrom(self, other: 'MessageMap[_K, _V]') -> None:
# pylint: disable=protected-access
for key in other._values:
# According to documentation: "When parsing from the wire or when merging,
@@ -500,7 +570,7 @@ class MessageMap(collections.abc.MutableMapping):
# self._message_listener.Modified() not required here, because
# mutations to submessages already propagate.
- def InvalidateIterators(self):
+ def InvalidateIterators(self) -> None:
# It appears that the only way to reliably invalidate iterators to
# self._values is to ensure that its size changes.
original = self._values
@@ -508,16 +578,15 @@ class MessageMap(collections.abc.MutableMapping):
original[None] = None
# This is defined in the abstract base, but we can do it much more cheaply.
- def clear(self):
+ def clear(self) -> None:
self._values.clear()
self._message_listener.Modified()
- def GetEntryClass(self):
+ def GetEntryClass(self) -> Any:
return self._entry_descriptor._concrete_class
-class _UnknownField(object):
-
+class _UnknownField:
"""A parsed unknown field."""
# Disallows assignment to other attributes.
@@ -542,12 +611,11 @@ class _UnknownField(object):
self._data == other._data)
-class UnknownFieldRef(object):
+class UnknownFieldRef: # pylint: disable=missing-class-docstring
def __init__(self, parent, index):
self._parent = parent
self._index = index
- return
def _check_valid(self):
if not self._parent:
@@ -576,8 +644,7 @@ class UnknownFieldRef(object):
return self._parent._internal_get(self._index)._data
-class UnknownFieldSet(object):
-
+class UnknownFieldSet:
"""UnknownField container"""
# Disallows assignment to other attributes.
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py b/contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py
index 9b9b859e1e..a53e71fe8e 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py
@@ -48,7 +48,6 @@ __author__ = 'robinson@google.com (Will Robinson)'
import ctypes
import numbers
-from google.protobuf.internal import api_implementation
from google.protobuf.internal import decoder
from google.protobuf.internal import encoder
from google.protobuf.internal import wire_format
@@ -77,7 +76,8 @@ def ToShortestFloat(original):
def SupportsOpenEnums(field_descriptor):
- return field_descriptor.containing_type.syntax == "proto3"
+ return field_descriptor.containing_type.syntax == 'proto3'
+
def GetTypeChecker(field):
"""Returns a type checker for a message field of the specified types.
@@ -105,7 +105,6 @@ def GetTypeChecker(field):
# subclassing builtin types and doing weird things. We're not trying to
# protect against malicious clients here, just people accidentally shooting
# themselves in the foot in obvious ways.
-
class TypeChecker(object):
"""Type checker used to catch type errors as early as possible
@@ -124,11 +123,6 @@ class TypeChecker(object):
message = ('%.1024r has type %s, but expected one of: %s' %
(proposed_value, type(proposed_value), self._acceptable_types))
raise TypeError(message)
- # Some field types(float, double and bool) accept other types, must
- # convert to the correct type in such cases.
- if self._acceptable_types:
- if self._acceptable_types[0] in (bool, float):
- return self._acceptable_types[0](proposed_value)
return proposed_value
@@ -142,6 +136,22 @@ class TypeCheckerWithDefault(TypeChecker):
return self._default_value
+class BoolValueChecker(object):
+ """Type checker used for bool fields."""
+
+ def CheckValue(self, proposed_value):
+ if not hasattr(proposed_value, '__index__') or (
+ type(proposed_value).__module__ == 'numpy' and
+ type(proposed_value).__name__ == 'ndarray'):
+ message = ('%.1024r has type %s, but expected one of: %s' %
+ (proposed_value, type(proposed_value), (bool, int)))
+ raise TypeError(message)
+ return bool(proposed_value)
+
+ def DefaultValue(self):
+ return False
+
+
# IntValueChecker and its subclasses perform integer type-checks
# and bounds-checks.
class IntValueChecker(object):
@@ -149,10 +159,13 @@ class IntValueChecker(object):
"""Checker used for integer fields. Performs type-check and range check."""
def CheckValue(self, proposed_value):
- if not isinstance(proposed_value, numbers.Integral):
+ if not hasattr(proposed_value, '__index__') or (
+ type(proposed_value).__module__ == 'numpy' and
+ type(proposed_value).__name__ == 'ndarray'):
message = ('%.1024r has type %s, but expected one of: %s' %
(proposed_value, type(proposed_value), (int,)))
raise TypeError(message)
+
if not self._MIN <= int(proposed_value) <= self._MAX:
raise ValueError('Value out of range: %d' % proposed_value)
# We force all values to int to make alternate implementations where the
@@ -249,20 +262,38 @@ _INF = float('inf')
_NEG_INF = float('-inf')
-class FloatValueChecker(object):
+class DoubleValueChecker(object):
+ """Checker used for double fields.
- """Checker used for float fields. Performs type-check and range check.
-
- Values exceeding a 32-bit float will be converted to inf/-inf.
+ Performs type-check and range check.
"""
def CheckValue(self, proposed_value):
"""Check and convert proposed_value to float."""
- if not isinstance(proposed_value, numbers.Real):
- message = ('%.1024r has type %s, but expected one of: numbers.Real' %
+ if (not hasattr(proposed_value, '__float__') and
+ not hasattr(proposed_value, '__index__')) or (
+ type(proposed_value).__module__ == 'numpy' and
+ type(proposed_value).__name__ == 'ndarray'):
+ message = ('%.1024r has type %s, but expected one of: int, float' %
(proposed_value, type(proposed_value)))
raise TypeError(message)
- converted_value = float(proposed_value)
+ return float(proposed_value)
+
+ def DefaultValue(self):
+ return 0.0
+
+
+class FloatValueChecker(DoubleValueChecker):
+ """Checker used for float fields.
+
+ Performs type-check and range check.
+
+ Values exceeding a 32-bit float will be converted to inf/-inf.
+ """
+
+ def CheckValue(self, proposed_value):
+ """Check and convert proposed_value to float."""
+ converted_value = super().CheckValue(proposed_value)
# This inf rounding matches the C++ proto SafeDoubleToFloat logic.
if converted_value > _FLOAT_MAX:
return _INF
@@ -271,23 +302,17 @@ class FloatValueChecker(object):
return TruncateToFourByteFloat(converted_value)
- def DefaultValue(self):
- return 0.0
-
-
# Type-checkers for all scalar CPPTYPEs.
_VALUE_CHECKERS = {
_FieldDescriptor.CPPTYPE_INT32: Int32ValueChecker(),
_FieldDescriptor.CPPTYPE_INT64: Int64ValueChecker(),
_FieldDescriptor.CPPTYPE_UINT32: Uint32ValueChecker(),
_FieldDescriptor.CPPTYPE_UINT64: Uint64ValueChecker(),
- _FieldDescriptor.CPPTYPE_DOUBLE: TypeCheckerWithDefault(
- 0.0, float, numbers.Real),
+ _FieldDescriptor.CPPTYPE_DOUBLE: DoubleValueChecker(),
_FieldDescriptor.CPPTYPE_FLOAT: FloatValueChecker(),
- _FieldDescriptor.CPPTYPE_BOOL: TypeCheckerWithDefault(
- False, bool, numbers.Integral),
+ _FieldDescriptor.CPPTYPE_BOOL: BoolValueChecker(),
_FieldDescriptor.CPPTYPE_STRING: TypeCheckerWithDefault(b'', bytes),
- }
+}
# Map from field type to a function F, such that F(field_num, value)
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/well_known_types.py b/contrib/python/protobuf/py3/google/protobuf/internal/well_known_types.py
index e7c059fde1..3f1aa9f846 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/well_known_types.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/well_known_types.py
@@ -42,8 +42,7 @@ __author__ = 'jieluo@google.com (Jie Luo)'
import calendar
import collections.abc
-from datetime import datetime
-from datetime import timedelta
+import datetime
from google.protobuf.descriptor import FieldDescriptor
@@ -89,7 +88,9 @@ class Any(object):
return '/' in self.type_url and self.TypeName() == descriptor.full_name
-_EPOCH_DATETIME = datetime(1970, 1, 1, tzinfo=None)
+_EPOCH_DATETIME_NAIVE = datetime.datetime(1970, 1, 1, tzinfo=None)
+_EPOCH_DATETIME_AWARE = datetime.datetime.fromtimestamp(
+ 0, tz=datetime.timezone.utc)
class Timestamp(object):
@@ -109,7 +110,7 @@ class Timestamp(object):
total_sec = self.seconds + (self.nanos - nanos) // _NANOS_PER_SECOND
seconds = total_sec % _SECONDS_PER_DAY
days = (total_sec - seconds) // _SECONDS_PER_DAY
- dt = datetime(1970, 1, 1) + timedelta(days, seconds)
+ dt = datetime.datetime(1970, 1, 1) + datetime.timedelta(days, seconds)
result = dt.isoformat()
if (nanos % 1e9) == 0:
@@ -159,8 +160,8 @@ class Timestamp(object):
raise ValueError(
'time data \'{0}\' does not match format \'%Y-%m-%dT%H:%M:%S\', '
'lowercase \'t\' is not accepted'.format(second_value))
- date_object = datetime.strptime(second_value, _TIMESTAMPFOMAT)
- td = date_object - datetime(1970, 1, 1)
+ date_object = datetime.datetime.strptime(second_value, _TIMESTAMPFOMAT)
+ td = date_object - datetime.datetime(1970, 1, 1)
seconds = td.seconds + td.days * _SECONDS_PER_DAY
if len(nano_value) > 9:
raise ValueError(
@@ -191,7 +192,7 @@ class Timestamp(object):
def GetCurrentTime(self):
"""Get the current UTC into Timestamp."""
- self.FromDatetime(datetime.utcnow())
+ self.FromDatetime(datetime.datetime.utcnow())
def ToNanoseconds(self):
"""Converts Timestamp to nanoseconds since epoch."""
@@ -231,14 +232,32 @@ class Timestamp(object):
self.seconds = seconds
self.nanos = 0
- def ToDatetime(self):
- """Converts Timestamp to datetime."""
- return _EPOCH_DATETIME + timedelta(
- seconds=self.seconds, microseconds=_RoundTowardZero(
- self.nanos, _NANOS_PER_MICROSECOND))
+ def ToDatetime(self, tzinfo=None):
+ """Converts Timestamp to a datetime.
+
+ Args:
+ tzinfo: A datetime.tzinfo subclass; defaults to None.
+
+ Returns:
+ If tzinfo is None, returns a timezone-naive UTC datetime (with no timezone
+ information, i.e. not aware that it's UTC).
+
+ Otherwise, returns a timezone-aware datetime in the input timezone.
+ """
+ delta = datetime.timedelta(
+ seconds=self.seconds,
+ microseconds=_RoundTowardZero(self.nanos, _NANOS_PER_MICROSECOND))
+ if tzinfo is None:
+ return _EPOCH_DATETIME_NAIVE + delta
+ else:
+ return _EPOCH_DATETIME_AWARE.astimezone(tzinfo) + delta
def FromDatetime(self, dt):
- """Converts datetime to Timestamp."""
+ """Converts datetime to Timestamp.
+
+ Args:
+ dt: A datetime. If it's timezone-naive, it's assumed to be in UTC.
+ """
# Using this guide: http://wiki.python.org/moin/WorkingWithTime
# And this conversion guide: http://docs.python.org/library/time.html
@@ -363,7 +382,7 @@ class Duration(object):
def ToTimedelta(self):
"""Converts Duration to timedelta."""
- return timedelta(
+ return datetime.timedelta(
seconds=self.seconds, microseconds=_RoundTowardZero(
self.nanos, _NANOS_PER_MICROSECOND))
diff --git a/contrib/python/protobuf/py3/google/protobuf/json_format.py b/contrib/python/protobuf/py3/google/protobuf/json_format.py
index e68d29df6a..5024ed89d7 100644
--- a/contrib/python/protobuf/py3/google/protobuf/json_format.py
+++ b/contrib/python/protobuf/py3/google/protobuf/json_format.py
@@ -95,7 +95,8 @@ def MessageToJson(
sort_keys=False,
use_integers_for_enums=False,
descriptor_pool=None,
- float_precision=None):
+ float_precision=None,
+ ensure_ascii=True):
"""Converts protobuf message to JSON format.
Args:
@@ -114,6 +115,8 @@ def MessageToJson(
descriptor_pool: A Descriptor Pool for resolving types. If None use the
default.
float_precision: If set, use this to specify float field valid digits.
+ ensure_ascii: If True, strings with non-ASCII characters are escaped.
+ If False, Unicode strings are returned unchanged.
Returns:
A string containing the JSON formatted protocol buffer message.
@@ -124,7 +127,7 @@ def MessageToJson(
use_integers_for_enums,
descriptor_pool,
float_precision=float_precision)
- return printer.ToJsonString(message, indent, sort_keys)
+ return printer.ToJsonString(message, indent, sort_keys, ensure_ascii)
def MessageToDict(
@@ -190,9 +193,10 @@ class _Printer(object):
else:
self.float_format = None
- def ToJsonString(self, message, indent, sort_keys):
+ def ToJsonString(self, message, indent, sort_keys, ensure_ascii):
js = self._MessageToJsonObject(message)
- return json.dumps(js, indent=indent, sort_keys=sort_keys)
+ return json.dumps(
+ js, indent=indent, sort_keys=sort_keys, ensure_ascii=ensure_ascii)
def _MessageToJsonObject(self, message):
"""Converts message to an object according to Proto3 JSON Specification."""
@@ -395,12 +399,16 @@ def _CreateMessageFromTypeUrl(type_url, descriptor_pool):
message_descriptor = pool.FindMessageTypeByName(type_name)
except KeyError:
raise TypeError(
- 'Can not find message descriptor by type_url: {0}.'.format(type_url))
+ 'Can not find message descriptor by type_url: {0}'.format(type_url))
message_class = db.GetPrototype(message_descriptor)
return message_class()
-def Parse(text, message, ignore_unknown_fields=False, descriptor_pool=None):
+def Parse(text,
+ message,
+ ignore_unknown_fields=False,
+ descriptor_pool=None,
+ max_recursion_depth=100):
"""Parses a JSON representation of a protocol message into a message.
Args:
@@ -408,7 +416,10 @@ def Parse(text, message, ignore_unknown_fields=False, descriptor_pool=None):
message: A protocol buffer message to merge into.
ignore_unknown_fields: If True, do not raise errors for unknown fields.
descriptor_pool: A Descriptor Pool for resolving types. If None use the
- default.
+ default.
+ max_recursion_depth: max recursion depth of JSON message to be
+ deserialized. JSON messages over this depth will fail to be
+ deserialized. Default value is 100.
Returns:
The same message passed as argument.
@@ -422,13 +433,15 @@ def Parse(text, message, ignore_unknown_fields=False, descriptor_pool=None):
js = json.loads(text, object_pairs_hook=_DuplicateChecker)
except ValueError as e:
raise ParseError('Failed to load JSON: {0}.'.format(str(e)))
- return ParseDict(js, message, ignore_unknown_fields, descriptor_pool)
+ return ParseDict(js, message, ignore_unknown_fields, descriptor_pool,
+ max_recursion_depth)
def ParseDict(js_dict,
message,
ignore_unknown_fields=False,
- descriptor_pool=None):
+ descriptor_pool=None,
+ max_recursion_depth=100):
"""Parses a JSON dictionary representation into a message.
Args:
@@ -437,12 +450,15 @@ def ParseDict(js_dict,
ignore_unknown_fields: If True, do not raise errors for unknown fields.
descriptor_pool: A Descriptor Pool for resolving types. If None use the
default.
+ max_recursion_depth: max recursion depth of JSON message to be
+ deserialized. JSON messages over this depth will fail to be
+ deserialized. Default value is 100.
Returns:
The same message passed as argument.
"""
- parser = _Parser(ignore_unknown_fields, descriptor_pool)
- parser.ConvertMessage(js_dict, message)
+ parser = _Parser(ignore_unknown_fields, descriptor_pool, max_recursion_depth)
+ parser.ConvertMessage(js_dict, message, '')
return message
@@ -452,35 +468,47 @@ _INT_OR_FLOAT = (int, float)
class _Parser(object):
"""JSON format parser for protocol message."""
- def __init__(self, ignore_unknown_fields, descriptor_pool):
+ def __init__(self, ignore_unknown_fields, descriptor_pool,
+ max_recursion_depth):
self.ignore_unknown_fields = ignore_unknown_fields
self.descriptor_pool = descriptor_pool
+ self.max_recursion_depth = max_recursion_depth
+ self.recursion_depth = 0
- def ConvertMessage(self, value, message):
+ def ConvertMessage(self, value, message, path):
"""Convert a JSON object into a message.
Args:
value: A JSON object.
message: A WKT or regular protocol message to record the data.
+ path: parent path to log parse error info.
Raises:
ParseError: In case of convert problems.
"""
+ self.recursion_depth += 1
+ if self.recursion_depth > self.max_recursion_depth:
+ raise ParseError('Message too deep. Max recursion depth is {0}'.format(
+ self.max_recursion_depth))
message_descriptor = message.DESCRIPTOR
full_name = message_descriptor.full_name
+ if not path:
+ path = message_descriptor.name
if _IsWrapperMessage(message_descriptor):
- self._ConvertWrapperMessage(value, message)
+ self._ConvertWrapperMessage(value, message, path)
elif full_name in _WKTJSONMETHODS:
- methodcaller(_WKTJSONMETHODS[full_name][1], value, message)(self)
+ methodcaller(_WKTJSONMETHODS[full_name][1], value, message, path)(self)
else:
- self._ConvertFieldValuePair(value, message)
+ self._ConvertFieldValuePair(value, message, path)
+ self.recursion_depth -= 1
- def _ConvertFieldValuePair(self, js, message):
+ def _ConvertFieldValuePair(self, js, message, path):
"""Convert field value pairs into regular message.
Args:
js: A JSON object to convert the field value pairs.
message: A regular protocol message to record the data.
+ path: parent path to log parse error info.
Raises:
ParseError: In case of problems converting.
@@ -496,8 +524,9 @@ class _Parser(object):
field = message_descriptor.fields_by_name.get(name, None)
if not field and _VALID_EXTENSION_NAME.match(name):
if not message_descriptor.is_extendable:
- raise ParseError('Message type {0} does not have extensions'.format(
- message_descriptor.full_name))
+ raise ParseError(
+ 'Message type {0} does not have extensions at {1}'.format(
+ message_descriptor.full_name, path))
identifier = name[1:-1] # strip [] brackets
# pylint: disable=protected-access
field = message.Extensions._FindExtensionByName(identifier)
@@ -513,14 +542,14 @@ class _Parser(object):
if self.ignore_unknown_fields:
continue
raise ParseError(
- ('Message type "{0}" has no field named "{1}".\n'
- ' Available Fields(except extensions): {2}').format(
- message_descriptor.full_name, name,
+ ('Message type "{0}" has no field named "{1}" at "{2}".\n'
+ ' Available Fields(except extensions): "{3}"').format(
+ message_descriptor.full_name, name, path,
[f.json_name for f in message_descriptor.fields]))
if name in names:
raise ParseError('Message type "{0}" should not have multiple '
- '"{1}" fields.'.format(
- message.DESCRIPTOR.full_name, name))
+ '"{1}" fields at "{2}".'.format(
+ message.DESCRIPTOR.full_name, name, path))
names.append(name)
value = js[name]
# Check no other oneof field is parsed.
@@ -528,8 +557,9 @@ class _Parser(object):
oneof_name = field.containing_oneof.name
if oneof_name in names:
raise ParseError('Message type "{0}" should not have multiple '
- '"{1}" oneof fields.'.format(
- message.DESCRIPTOR.full_name, oneof_name))
+ '"{1}" oneof fields at "{2}".'.format(
+ message.DESCRIPTOR.full_name, oneof_name,
+ path))
names.append(oneof_name)
if value is None:
@@ -547,42 +577,51 @@ class _Parser(object):
# Parse field value.
if _IsMapEntry(field):
message.ClearField(field.name)
- self._ConvertMapFieldValue(value, message, field)
+ self._ConvertMapFieldValue(value, message, field,
+ '{0}.{1}'.format(path, name))
elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
message.ClearField(field.name)
if not isinstance(value, list):
raise ParseError('repeated field {0} must be in [] which is '
- '{1}.'.format(name, value))
+ '{1} at {2}'.format(name, value, path))
if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
# Repeated message field.
- for item in value:
+ for index, item in enumerate(value):
sub_message = getattr(message, field.name).add()
# None is a null_value in Value.
if (item is None and
sub_message.DESCRIPTOR.full_name != 'google.protobuf.Value'):
raise ParseError('null is not allowed to be used as an element'
- ' in a repeated field.')
- self.ConvertMessage(item, sub_message)
+ ' in a repeated field at {0}.{1}[{2}]'.format(
+ path, name, index))
+ self.ConvertMessage(item, sub_message,
+ '{0}.{1}[{2}]'.format(path, name, index))
else:
# Repeated scalar field.
- for item in value:
+ for index, item in enumerate(value):
if item is None:
raise ParseError('null is not allowed to be used as an element'
- ' in a repeated field.')
+ ' in a repeated field at {0}.{1}[{2}]'.format(
+ path, name, index))
getattr(message, field.name).append(
- _ConvertScalarFieldValue(item, field))
+ _ConvertScalarFieldValue(
+ item, field, '{0}.{1}[{2}]'.format(path, name, index)))
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
if field.is_extension:
sub_message = message.Extensions[field]
else:
sub_message = getattr(message, field.name)
sub_message.SetInParent()
- self.ConvertMessage(value, sub_message)
+ self.ConvertMessage(value, sub_message, '{0}.{1}'.format(path, name))
else:
if field.is_extension:
- message.Extensions[field] = _ConvertScalarFieldValue(value, field)
+ message.Extensions[field] = _ConvertScalarFieldValue(
+ value, field, '{0}.{1}'.format(path, name))
else:
- setattr(message, field.name, _ConvertScalarFieldValue(value, field))
+ setattr(
+ message, field.name,
+ _ConvertScalarFieldValue(value, field,
+ '{0}.{1}'.format(path, name)))
except ParseError as e:
if field and field.containing_oneof is None:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
@@ -593,46 +632,52 @@ class _Parser(object):
except TypeError as e:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
- def _ConvertAnyMessage(self, value, message):
+ def _ConvertAnyMessage(self, value, message, path):
"""Convert a JSON representation into Any message."""
if isinstance(value, dict) and not value:
return
try:
type_url = value['@type']
except KeyError:
- raise ParseError('@type is missing when parsing any message.')
+ raise ParseError(
+ '@type is missing when parsing any message at {0}'.format(path))
- sub_message = _CreateMessageFromTypeUrl(type_url, self.descriptor_pool)
+ try:
+ sub_message = _CreateMessageFromTypeUrl(type_url, self.descriptor_pool)
+ except TypeError as e:
+ raise ParseError('{0} at {1}'.format(e, path))
message_descriptor = sub_message.DESCRIPTOR
full_name = message_descriptor.full_name
if _IsWrapperMessage(message_descriptor):
- self._ConvertWrapperMessage(value['value'], sub_message)
+ self._ConvertWrapperMessage(value['value'], sub_message,
+ '{0}.value'.format(path))
elif full_name in _WKTJSONMETHODS:
- methodcaller(
- _WKTJSONMETHODS[full_name][1], value['value'], sub_message)(self)
+ methodcaller(_WKTJSONMETHODS[full_name][1], value['value'], sub_message,
+ '{0}.value'.format(path))(
+ self)
else:
del value['@type']
- self._ConvertFieldValuePair(value, sub_message)
+ self._ConvertFieldValuePair(value, sub_message, path)
value['@type'] = type_url
# Sets Any message
message.value = sub_message.SerializeToString()
message.type_url = type_url
- def _ConvertGenericMessage(self, value, message):
+ def _ConvertGenericMessage(self, value, message, path):
"""Convert a JSON representation into message with FromJsonString."""
# Duration, Timestamp, FieldMask have a FromJsonString method to do the
# conversion. Users can also call the method directly.
try:
message.FromJsonString(value)
except ValueError as e:
- raise ParseError(e)
+ raise ParseError('{0} at {1}'.format(e, path))
- def _ConvertValueMessage(self, value, message):
+ def _ConvertValueMessage(self, value, message, path):
"""Convert a JSON representation into Value message."""
if isinstance(value, dict):
- self._ConvertStructMessage(value, message.struct_value)
+ self._ConvertStructMessage(value, message.struct_value, path)
elif isinstance(value, list):
- self. _ConvertListValueMessage(value, message.list_value)
+ self._ConvertListValueMessage(value, message.list_value, path)
elif value is None:
message.null_value = 0
elif isinstance(value, bool):
@@ -642,68 +687,76 @@ class _Parser(object):
elif isinstance(value, _INT_OR_FLOAT):
message.number_value = value
else:
- raise ParseError('Value {0} has unexpected type {1}.'.format(
- value, type(value)))
+ raise ParseError('Value {0} has unexpected type {1} at {2}'.format(
+ value, type(value), path))
- def _ConvertListValueMessage(self, value, message):
+ def _ConvertListValueMessage(self, value, message, path):
"""Convert a JSON representation into ListValue message."""
if not isinstance(value, list):
- raise ParseError(
- 'ListValue must be in [] which is {0}.'.format(value))
+ raise ParseError('ListValue must be in [] which is {0} at {1}'.format(
+ value, path))
message.ClearField('values')
- for item in value:
- self._ConvertValueMessage(item, message.values.add())
+ for index, item in enumerate(value):
+ self._ConvertValueMessage(item, message.values.add(),
+ '{0}[{1}]'.format(path, index))
- def _ConvertStructMessage(self, value, message):
+ def _ConvertStructMessage(self, value, message, path):
"""Convert a JSON representation into Struct message."""
if not isinstance(value, dict):
- raise ParseError(
- 'Struct must be in a dict which is {0}.'.format(value))
+ raise ParseError('Struct must be in a dict which is {0} at {1}'.format(
+ value, path))
# Clear will mark the struct as modified so it will be created even if
# there are no values.
message.Clear()
for key in value:
- self._ConvertValueMessage(value[key], message.fields[key])
+ self._ConvertValueMessage(value[key], message.fields[key],
+ '{0}.{1}'.format(path, key))
return
- def _ConvertWrapperMessage(self, value, message):
+ def _ConvertWrapperMessage(self, value, message, path):
"""Convert a JSON representation into Wrapper message."""
field = message.DESCRIPTOR.fields_by_name['value']
- setattr(message, 'value', _ConvertScalarFieldValue(value, field))
+ setattr(
+ message, 'value',
+ _ConvertScalarFieldValue(value, field, path='{0}.value'.format(path)))
- def _ConvertMapFieldValue(self, value, message, field):
+ def _ConvertMapFieldValue(self, value, message, field, path):
"""Convert map field value for a message map field.
Args:
value: A JSON object to convert the map field value.
message: A protocol message to record the converted data.
field: The descriptor of the map field to be converted.
+ path: parent path to log parse error info.
Raises:
ParseError: In case of convert problems.
"""
if not isinstance(value, dict):
raise ParseError(
- 'Map field {0} must be in a dict which is {1}.'.format(
- field.name, value))
+ 'Map field {0} must be in a dict which is {1} at {2}'.format(
+ field.name, value, path))
key_field = field.message_type.fields_by_name['key']
value_field = field.message_type.fields_by_name['value']
for key in value:
- key_value = _ConvertScalarFieldValue(key, key_field, True)
+ key_value = _ConvertScalarFieldValue(key, key_field,
+ '{0}.key'.format(path), True)
if value_field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
- self.ConvertMessage(value[key], getattr(
- message, field.name)[key_value])
+ self.ConvertMessage(value[key],
+ getattr(message, field.name)[key_value],
+ '{0}[{1}]'.format(path, key_value))
else:
getattr(message, field.name)[key_value] = _ConvertScalarFieldValue(
- value[key], value_field)
+ value[key], value_field, path='{0}[{1}]'.format(path, key_value))
-def _ConvertScalarFieldValue(value, field, require_str=False, path=None):
+def _ConvertScalarFieldValue(value, field, path, require_str=False):
"""Convert a single scalar field value.
Args:
value: A scalar value to convert the scalar field value.
field: The descriptor of the field to convert.
+ path: parent path to log parse error info.
require_str: If True, the field value must be a str.
Returns:
@@ -712,44 +765,47 @@ def _ConvertScalarFieldValue(value, field, require_str=False, path=None):
Raises:
ParseError: In case of convert problems.
"""
- if field.cpp_type in _INT_TYPES:
- return _ConvertInteger(value)
- elif field.cpp_type in _FLOAT_TYPES:
- return _ConvertFloat(value, field)
- elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_BOOL:
- return _ConvertBool(value, require_str)
- elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_STRING:
- if field.type == descriptor.FieldDescriptor.TYPE_BYTES:
- if isinstance(value, str):
- encoded = value.encode('utf-8')
+ try:
+ if field.cpp_type in _INT_TYPES:
+ return _ConvertInteger(value)
+ elif field.cpp_type in _FLOAT_TYPES:
+ return _ConvertFloat(value, field)
+ elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_BOOL:
+ return _ConvertBool(value, require_str)
+ elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_STRING:
+ if field.type == descriptor.FieldDescriptor.TYPE_BYTES:
+ if isinstance(value, str):
+ encoded = value.encode('utf-8')
+ else:
+ encoded = value
+ # Add extra padding '='
+ padded_value = encoded + b'=' * (4 - len(encoded) % 4)
+ return base64.urlsafe_b64decode(padded_value)
else:
- encoded = value
- # Add extra padding '='
- padded_value = encoded + b'=' * (4 - len(encoded) % 4)
- return base64.urlsafe_b64decode(padded_value)
- else:
- # Checking for unpaired surrogates appears to be unreliable,
- # depending on the specific Python version, so we check manually.
- if _UNPAIRED_SURROGATE_PATTERN.search(value):
- raise ParseError('Unpaired surrogate')
- return value
- elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM:
- # Convert an enum value.
- enum_value = field.enum_type.values_by_name.get(value, None)
- if enum_value is None:
- try:
- number = int(value)
- enum_value = field.enum_type.values_by_number.get(number, None)
- except ValueError:
- raise ParseError('Invalid enum value {0} for enum type {1}.'.format(
- value, field.enum_type.full_name))
+ # Checking for unpaired surrogates appears to be unreliable,
+ # depending on the specific Python version, so we check manually.
+ if _UNPAIRED_SURROGATE_PATTERN.search(value):
+ raise ParseError('Unpaired surrogate')
+ return value
+ elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM:
+ # Convert an enum value.
+ enum_value = field.enum_type.values_by_name.get(value, None)
if enum_value is None:
- if field.file.syntax == 'proto3':
- # Proto3 accepts unknown enums.
- return number
- raise ParseError('Invalid enum value {0} for enum type {1}.'.format(
- value, field.enum_type.full_name))
- return enum_value.number
+ try:
+ number = int(value)
+ enum_value = field.enum_type.values_by_number.get(number, None)
+ except ValueError:
+ raise ParseError('Invalid enum value {0} for enum type {1}'.format(
+ value, field.enum_type.full_name))
+ if enum_value is None:
+ if field.file.syntax == 'proto3':
+ # Proto3 accepts unknown enums.
+ return number
+ raise ParseError('Invalid enum value {0} for enum type {1}'.format(
+ value, field.enum_type.full_name))
+ return enum_value.number
+ except ParseError as e:
+ raise ParseError('{0} at {1}'.format(e, path))
def _ConvertInteger(value):
@@ -765,14 +821,14 @@ def _ConvertInteger(value):
ParseError: If an integer couldn't be consumed.
"""
if isinstance(value, float) and not value.is_integer():
- raise ParseError('Couldn\'t parse integer: {0}.'.format(value))
+ raise ParseError('Couldn\'t parse integer: {0}'.format(value))
if isinstance(value, str) and value.find(' ') != -1:
- raise ParseError('Couldn\'t parse integer: "{0}".'.format(value))
+ raise ParseError('Couldn\'t parse integer: "{0}"'.format(value))
if isinstance(value, bool):
raise ParseError('Bool value {0} is not acceptable for '
- 'integer field.'.format(value))
+ 'integer field'.format(value))
return int(value)
@@ -781,14 +837,14 @@ def _ConvertFloat(value, field):
"""Convert an floating point number."""
if isinstance(value, float):
if math.isnan(value):
- raise ParseError('Couldn\'t parse NaN, use quoted "NaN" instead.')
+ raise ParseError('Couldn\'t parse NaN, use quoted "NaN" instead')
if math.isinf(value):
if value > 0:
raise ParseError('Couldn\'t parse Infinity or value too large, '
- 'use quoted "Infinity" instead.')
+ 'use quoted "Infinity" instead')
else:
raise ParseError('Couldn\'t parse -Infinity or value too small, '
- 'use quoted "-Infinity" instead.')
+ 'use quoted "-Infinity" instead')
if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_FLOAT:
# pylint: disable=protected-access
if value > type_checkers._FLOAT_MAX:
@@ -797,7 +853,7 @@ def _ConvertFloat(value, field):
if value < type_checkers._FLOAT_MIN:
raise ParseError('Float value too small')
if value == 'nan':
- raise ParseError('Couldn\'t parse float "nan", use "NaN" instead.')
+ raise ParseError('Couldn\'t parse float "nan", use "NaN" instead')
try:
# Assume Python compatible syntax.
return float(value)
@@ -810,7 +866,7 @@ def _ConvertFloat(value, field):
elif value == _NAN:
return float('nan')
else:
- raise ParseError('Couldn\'t parse float: {0}.'.format(value))
+ raise ParseError('Couldn\'t parse float: {0}'.format(value))
def _ConvertBool(value, require_str):
@@ -832,10 +888,10 @@ def _ConvertBool(value, require_str):
elif value == 'false':
return False
else:
- raise ParseError('Expected "true" or "false", not {0}.'.format(value))
+ raise ParseError('Expected "true" or "false", not {0}'.format(value))
if not isinstance(value, bool):
- raise ParseError('Expected true or false without quotes.')
+ raise ParseError('Expected true or false without quotes')
return value
_WKTJSONMETHODS = {
diff --git a/contrib/python/protobuf/py3/google/protobuf/message.py b/contrib/python/protobuf/py3/google/protobuf/message.py
index ee46d0e4c9..76c6802f70 100644
--- a/contrib/python/protobuf/py3/google/protobuf/message.py
+++ b/contrib/python/protobuf/py3/google/protobuf/message.py
@@ -194,6 +194,9 @@ class Message(object):
"""Parse serialized protocol buffer data into this message.
Like :func:`MergeFromString()`, except we clear the object first.
+
+ Raises:
+ message.DecodeError if the input cannot be parsed.
"""
self.Clear()
return self.MergeFromString(serialized)
diff --git a/contrib/python/protobuf/py3/google/protobuf/proto_api.h b/contrib/python/protobuf/py3/google/protobuf/proto_api.h
index 2e2156a56e..9969a91f44 100644
--- a/contrib/python/protobuf/py3/google/protobuf/proto_api.h
+++ b/contrib/python/protobuf/py3/google/protobuf/proto_api.h
@@ -45,6 +45,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
#define GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/descriptor_database.h>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc
index 0712abc068..a5254ce97b 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc
@@ -32,6 +32,7 @@
#include <google/protobuf/pyext/descriptor.h>
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <frameobject.h>
@@ -49,12 +50,13 @@
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
#include <google/protobuf/stubs/hash.h>
-#define PyString_AsStringAndSize(ob, charpp, sizep) \
- (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>( \
- PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
- ? -1 \
- : 0) \
- : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob) \
+ ? ((*(charpp) = const_cast<char*>( \
+ PyUnicode_AsUTF8AndSize(ob, (sizep)))) == nullptr \
+ ? -1 \
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
static PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
@@ -130,7 +132,7 @@ bool _CalledFromGeneratedFile(int stacklevel) {
PyObject* frame_locals = nullptr;
bool result = false;
- if (frame == NULL) {
+ if (frame == nullptr) {
goto exit;
}
Py_INCREF(frame);
@@ -138,7 +140,7 @@ bool _CalledFromGeneratedFile(int stacklevel) {
PyFrameObject* next_frame = PyFrame_GetBack(frame);
Py_DECREF(frame);
frame = next_frame;
- if (frame == NULL) {
+ if (frame == nullptr) {
goto exit;
}
}
@@ -284,23 +286,23 @@ static PyObject* GetOrBuildOptions(const DescriptorClass *descriptor) {
const Descriptor *message_type = options.GetDescriptor();
CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
message_factory, message_type);
- if (message_class == NULL) {
+ if (message_class == nullptr) {
PyErr_Format(PyExc_TypeError, "Could not retrieve class for Options: %s",
message_type->full_name().c_str());
- return NULL;
+ return nullptr;
}
ScopedPyObjectPtr args(PyTuple_New(0));
ScopedPyObjectPtr value(
- PyObject_Call(message_class->AsPyObject(), args.get(), NULL));
+ PyObject_Call(message_class->AsPyObject(), args.get(), nullptr));
Py_DECREF(message_class);
- if (value == NULL) {
- return NULL;
+ if (value == nullptr) {
+ return nullptr;
}
if (!PyObject_TypeCheck(value.get(), CMessage_Type)) {
PyErr_Format(PyExc_TypeError, "Invalid class for %s: %s",
message_type->full_name().c_str(),
Py_TYPE(value.get())->tp_name);
- return NULL;
+ return nullptr;
}
CMessage* cmsg = reinterpret_cast<CMessage*>(value.get());
@@ -312,7 +314,7 @@ static PyObject* GetOrBuildOptions(const DescriptorClass *descriptor) {
// Reparse options string! XXX call cmessage::MergeFromString
if (!Reparse(message_factory, options, cmsg->message)) {
PyErr_Format(PyExc_ValueError, "Error reparsing Options message");
- return NULL;
+ return nullptr;
}
}
@@ -336,7 +338,7 @@ static PyObject* CopyToPythonProto(const DescriptorClass *descriptor,
message->message->GetDescriptor() != self_descriptor) {
PyErr_Format(PyExc_TypeError, "Not a %s message",
self_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
}
cmessage::AssureWritable(message);
DescriptorProtoClass* descriptor_message =
@@ -372,7 +374,7 @@ typedef struct PyBaseDescriptor {
typedef struct PyFileDescriptor {
PyBaseDescriptor base;
- // The cached version of serialized pb. Either NULL, or a Bytes string.
+ // The cached version of serialized pb. Either null, or a Bytes string.
// We own the reference.
PyObject *serialized_pb;
} PyFileDescriptor;
@@ -393,9 +395,9 @@ PyObject* NewInternedDescriptor(PyTypeObject* type,
if (was_created) {
*was_created = false;
}
- if (descriptor == NULL) {
+ if (descriptor == nullptr) {
PyErr_BadInternalCall();
- return NULL;
+ return nullptr;
}
// See if the object is in the map of interned descriptors
@@ -409,8 +411,8 @@ PyObject* NewInternedDescriptor(PyTypeObject* type,
// Create a new descriptor object
PyBaseDescriptor* py_descriptor = PyObject_GC_New(
PyBaseDescriptor, type);
- if (py_descriptor == NULL) {
- return NULL;
+ if (py_descriptor == nullptr) {
+ return nullptr;
}
py_descriptor->descriptor = descriptor;
@@ -421,10 +423,10 @@ PyObject* NewInternedDescriptor(PyTypeObject* type,
// Ensures that the DescriptorPool stays alive.
PyDescriptorPool* pool = GetDescriptorPool_FromPool(
GetFileDescriptor(descriptor)->pool());
- if (pool == NULL) {
+ if (pool == nullptr) {
// Don't DECREF, the object is not fully initialized.
PyObject_Del(py_descriptor);
- return NULL;
+ return nullptr;
}
Py_INCREF(pool);
py_descriptor->pool = pool;
@@ -461,39 +463,43 @@ static int GcClear(PyObject* pself) {
}
static PyGetSetDef Getters[] = {
- {NULL}
+ {nullptr},
};
PyTypeObject PyBaseDescriptor_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
- ".DescriptorBase", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- (destructor)Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
+ ".DescriptorBase", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ (destructor)Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
"Descriptors base class", // tp_doc
GcTraverse, // tp_traverse
GcClear, // tp_clear
- 0, // tp_richcompare
+ nullptr, // tp_richcompare
0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
Getters, // tp_getset
};
@@ -502,7 +508,7 @@ PyTypeObject PyBaseDescriptor_Type = {
const void* PyDescriptor_AsVoidPtr(PyObject* obj) {
if (!PyObject_TypeCheck(obj, &descriptor::PyBaseDescriptor_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a BaseDescriptor");
- return NULL;
+ return nullptr;
}
return reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor;
}
@@ -664,19 +670,18 @@ static PyObject* CopyToProto(PyBaseDescriptor *self, PyObject *target) {
static PyObject* EnumValueName(PyBaseDescriptor *self, PyObject *args) {
const char *enum_name;
int number;
- if (!PyArg_ParseTuple(args, "si", &enum_name, &number))
- return NULL;
+ if (!PyArg_ParseTuple(args, "si", &enum_name, &number)) return nullptr;
const EnumDescriptor *enum_type =
_GetDescriptor(self)->FindEnumTypeByName(enum_name);
- if (enum_type == NULL) {
+ if (enum_type == nullptr) {
PyErr_SetString(PyExc_KeyError, enum_name);
- return NULL;
+ return nullptr;
}
const EnumValueDescriptor *enum_value =
enum_type->FindValueByNumber(number);
- if (enum_value == NULL) {
+ if (enum_value == nullptr) {
PyErr_Format(PyExc_KeyError, "%d", number);
- return NULL;
+ return nullptr;
}
return PyString_FromCppString(enum_value->name());
}
@@ -687,94 +692,102 @@ static PyObject* GetSyntax(PyBaseDescriptor *self, void *closure) {
}
static PyGetSetDef Getters[] = {
- { "name", (getter)GetName, NULL, "Last name"},
- { "full_name", (getter)GetFullName, NULL, "Full name"},
- { "_concrete_class", (getter)GetConcreteClass, NULL, "concrete class"},
- { "file", (getter)GetFile, NULL, "File descriptor"},
-
- { "fields", (getter)GetFieldsSeq, NULL, "Fields sequence"},
- { "fields_by_name", (getter)GetFieldsByName, NULL, "Fields by name"},
- { "fields_by_camelcase_name", (getter)GetFieldsByCamelcaseName, NULL,
- "Fields by camelCase name"},
- { "fields_by_number", (getter)GetFieldsByNumber, NULL, "Fields by number"},
- { "nested_types", (getter)GetNestedTypesSeq, NULL, "Nested types sequence"},
- { "nested_types_by_name", (getter)GetNestedTypesByName, NULL,
- "Nested types by name"},
- { "extensions", (getter)GetExtensions, NULL, "Extensions Sequence"},
- { "extensions_by_name", (getter)GetExtensionsByName, NULL,
- "Extensions by name"},
- { "extension_ranges", (getter)GetExtensionRanges, NULL, "Extension ranges"},
- { "enum_types", (getter)GetEnumsSeq, NULL, "Enum sequence"},
- { "enum_types_by_name", (getter)GetEnumTypesByName, NULL,
- "Enum types by name"},
- { "enum_values_by_name", (getter)GetEnumValuesByName, NULL,
- "Enum values by name"},
- { "oneofs_by_name", (getter)GetOneofsByName, NULL, "Oneofs by name"},
- { "oneofs", (getter)GetOneofsSeq, NULL, "Oneofs by name"},
- { "containing_type", (getter)GetContainingType, (setter)SetContainingType,
- "Containing type"},
- { "is_extendable", (getter)IsExtendable, (setter)NULL},
- { "has_options", (getter)GetHasOptions, (setter)SetHasOptions, "Has Options"},
- { "_options", (getter)NULL, (setter)SetOptions, "Options"},
- { "_serialized_options", (getter)NULL, (setter)SetSerializedOptions,
- "Serialized Options"},
- { "syntax", (getter)GetSyntax, (setter)NULL, "Syntax"},
- {NULL}
+ {"name", (getter)GetName, nullptr, "Last name"},
+ {"full_name", (getter)GetFullName, nullptr, "Full name"},
+ {"_concrete_class", (getter)GetConcreteClass, nullptr, "concrete class"},
+ {"file", (getter)GetFile, nullptr, "File descriptor"},
+
+ {"fields", (getter)GetFieldsSeq, nullptr, "Fields sequence"},
+ {"fields_by_name", (getter)GetFieldsByName, nullptr, "Fields by name"},
+ {"fields_by_camelcase_name", (getter)GetFieldsByCamelcaseName, nullptr,
+ "Fields by camelCase name"},
+ {"fields_by_number", (getter)GetFieldsByNumber, nullptr,
+ "Fields by number"},
+ {"nested_types", (getter)GetNestedTypesSeq, nullptr,
+ "Nested types sequence"},
+ {"nested_types_by_name", (getter)GetNestedTypesByName, nullptr,
+ "Nested types by name"},
+ {"extensions", (getter)GetExtensions, nullptr, "Extensions Sequence"},
+ {"extensions_by_name", (getter)GetExtensionsByName, nullptr,
+ "Extensions by name"},
+ {"extension_ranges", (getter)GetExtensionRanges, nullptr,
+ "Extension ranges"},
+ {"enum_types", (getter)GetEnumsSeq, nullptr, "Enum sequence"},
+ {"enum_types_by_name", (getter)GetEnumTypesByName, nullptr,
+ "Enum types by name"},
+ {"enum_values_by_name", (getter)GetEnumValuesByName, nullptr,
+ "Enum values by name"},
+ {"oneofs_by_name", (getter)GetOneofsByName, nullptr, "Oneofs by name"},
+ {"oneofs", (getter)GetOneofsSeq, nullptr, "Oneofs by name"},
+ {"containing_type", (getter)GetContainingType, (setter)SetContainingType,
+ "Containing type"},
+ {"is_extendable", (getter)IsExtendable, (setter) nullptr},
+ {"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
+ "Has Options"},
+ {"_options", (getter) nullptr, (setter)SetOptions, "Options"},
+ {"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
+ "Serialized Options"},
+ {"syntax", (getter)GetSyntax, (setter) nullptr, "Syntax"},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS, },
- { "CopyToProto", (PyCFunction)CopyToProto, METH_O, },
- { "EnumValueName", (PyCFunction)EnumValueName, METH_VARARGS, },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {"CopyToProto", (PyCFunction)CopyToProto, METH_O},
+ {"EnumValueName", (PyCFunction)EnumValueName, METH_VARARGS},
+ {nullptr},
};
} // namespace message_descriptor
PyTypeObject PyMessageDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".MessageDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A Message Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- message_descriptor::Methods, // tp_methods
- 0, // tp_members
- message_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".MessageDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A Message Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ message_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ message_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyMessageDescriptor_FromDescriptor(
const Descriptor* message_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyMessageDescriptor_Type, message_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyMessageDescriptor_Type,
+ message_descriptor, nullptr);
}
const Descriptor* PyMessageDescriptor_AsDescriptor(PyObject* obj) {
if (!PyObject_TypeCheck(obj, &PyMessageDescriptor_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a MessageDescriptor");
- return NULL;
+ return nullptr;
}
return reinterpret_cast<const Descriptor*>(
reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
@@ -902,7 +915,7 @@ static PyObject* GetDefaultValue(PyBaseDescriptor *self, void *closure) {
default:
PyErr_Format(PyExc_NotImplementedError, "default value for %s",
_GetDescriptor(self)->full_name().c_str());
- return NULL;
+ return nullptr;
}
return result;
}
@@ -993,6 +1006,14 @@ static int SetHasOptions(PyBaseDescriptor *self, PyObject *value,
return CheckCalledFromGeneratedFile("has_options");
}
+static PyObject* GetHasPresence(PyBaseDescriptor* self, void* closure) {
+ if (_GetDescriptor(self)->has_presence()) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+}
+
static PyObject* GetOptions(PyBaseDescriptor *self) {
return GetOrBuildOptions(_GetDescriptor(self));
}
@@ -1008,89 +1029,95 @@ static int SetSerializedOptions(PyBaseDescriptor *self, PyObject *value,
}
static PyGetSetDef Getters[] = {
- { "full_name", (getter)GetFullName, NULL, "Full name"},
- { "name", (getter)GetName, NULL, "Unqualified name"},
- { "camelcase_name", (getter)GetCamelcaseName, NULL, "Camelcase name"},
- { "json_name", (getter)GetJsonName, NULL, "Json name"},
- { "file", (getter)GetFile, NULL, "File Descriptor"},
- { "type", (getter)GetType, NULL, "C++ Type"},
- { "cpp_type", (getter)GetCppType, NULL, "C++ Type"},
- { "label", (getter)GetLabel, NULL, "Label"},
- { "number", (getter)GetNumber, NULL, "Number"},
- { "index", (getter)GetIndex, NULL, "Index"},
- { "default_value", (getter)GetDefaultValue, NULL, "Default Value"},
- { "has_default_value", (getter)HasDefaultValue},
- { "is_extension", (getter)IsExtension, NULL, "ID"},
- { "id", (getter)GetID, NULL, "ID"},
- { "_cdescriptor", (getter)GetCDescriptor, NULL, "HAACK REMOVE ME"},
-
- { "message_type", (getter)GetMessageType, (setter)SetMessageType,
- "Message type"},
- { "enum_type", (getter)GetEnumType, (setter)SetEnumType, "Enum type"},
- { "containing_type", (getter)GetContainingType, (setter)SetContainingType,
- "Containing type"},
- { "extension_scope", (getter)GetExtensionScope, (setter)NULL,
- "Extension scope"},
- { "containing_oneof", (getter)GetContainingOneof, (setter)SetContainingOneof,
- "Containing oneof"},
- { "has_options", (getter)GetHasOptions, (setter)SetHasOptions, "Has Options"},
- { "_options", (getter)NULL, (setter)SetOptions, "Options"},
- { "_serialized_options", (getter)NULL, (setter)SetSerializedOptions,
- "Serialized Options"},
- {NULL}
+ {"full_name", (getter)GetFullName, nullptr, "Full name"},
+ {"name", (getter)GetName, nullptr, "Unqualified name"},
+ {"camelcase_name", (getter)GetCamelcaseName, nullptr, "Camelcase name"},
+ {"json_name", (getter)GetJsonName, nullptr, "Json name"},
+ {"file", (getter)GetFile, nullptr, "File Descriptor"},
+ {"type", (getter)GetType, nullptr, "C++ Type"},
+ {"cpp_type", (getter)GetCppType, nullptr, "C++ Type"},
+ {"label", (getter)GetLabel, nullptr, "Label"},
+ {"number", (getter)GetNumber, nullptr, "Number"},
+ {"index", (getter)GetIndex, nullptr, "Index"},
+ {"default_value", (getter)GetDefaultValue, nullptr, "Default Value"},
+ {"has_default_value", (getter)HasDefaultValue},
+ {"is_extension", (getter)IsExtension, nullptr, "ID"},
+ {"id", (getter)GetID, nullptr, "ID"},
+ {"_cdescriptor", (getter)GetCDescriptor, nullptr, "HAACK REMOVE ME"},
+
+ {"message_type", (getter)GetMessageType, (setter)SetMessageType,
+ "Message type"},
+ {"enum_type", (getter)GetEnumType, (setter)SetEnumType, "Enum type"},
+ {"containing_type", (getter)GetContainingType, (setter)SetContainingType,
+ "Containing type"},
+ {"extension_scope", (getter)GetExtensionScope, (setter) nullptr,
+ "Extension scope"},
+ {"containing_oneof", (getter)GetContainingOneof, (setter)SetContainingOneof,
+ "Containing oneof"},
+ {"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
+ "Has Options"},
+ {"has_presence", (getter)GetHasPresence, (setter) nullptr, "Has Presence"},
+ {"_options", (getter) nullptr, (setter)SetOptions, "Options"},
+ {"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
+ "Serialized Options"},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS, },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {nullptr},
};
} // namespace field_descriptor
PyTypeObject PyFieldDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".FieldDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A Field Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- field_descriptor::Methods, // tp_methods
- 0, // tp_members
- field_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".FieldDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A Field Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ field_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ field_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyFieldDescriptor_FromDescriptor(
const FieldDescriptor* field_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyFieldDescriptor_Type, field_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyFieldDescriptor_Type,
+ field_descriptor, nullptr);
}
const FieldDescriptor* PyFieldDescriptor_AsDescriptor(PyObject* obj) {
if (!PyObject_TypeCheck(obj, &PyFieldDescriptor_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a FieldDescriptor");
- return NULL;
+ return nullptr;
}
return reinterpret_cast<const FieldDescriptor*>(
reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
@@ -1176,76 +1203,81 @@ static PyObject* CopyToProto(PyBaseDescriptor *self, PyObject *target) {
}
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS, },
- { "CopyToProto", (PyCFunction)CopyToProto, METH_O, },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {"CopyToProto", (PyCFunction)CopyToProto, METH_O},
+ {nullptr},
};
static PyGetSetDef Getters[] = {
- { "full_name", (getter)GetFullName, NULL, "Full name"},
- { "name", (getter)GetName, NULL, "last name"},
- { "file", (getter)GetFile, NULL, "File descriptor"},
- { "values", (getter)GetEnumvaluesSeq, NULL, "values"},
- { "values_by_name", (getter)GetEnumvaluesByName, NULL,
- "Enum values by name"},
- { "values_by_number", (getter)GetEnumvaluesByNumber, NULL,
- "Enum values by number"},
-
- { "containing_type", (getter)GetContainingType, (setter)SetContainingType,
- "Containing type"},
- { "has_options", (getter)GetHasOptions, (setter)SetHasOptions, "Has Options"},
- { "_options", (getter)NULL, (setter)SetOptions, "Options"},
- { "_serialized_options", (getter)NULL, (setter)SetSerializedOptions,
- "Serialized Options"},
- {NULL}
+ {"full_name", (getter)GetFullName, nullptr, "Full name"},
+ {"name", (getter)GetName, nullptr, "last name"},
+ {"file", (getter)GetFile, nullptr, "File descriptor"},
+ {"values", (getter)GetEnumvaluesSeq, nullptr, "values"},
+ {"values_by_name", (getter)GetEnumvaluesByName, nullptr,
+ "Enum values by name"},
+ {"values_by_number", (getter)GetEnumvaluesByNumber, nullptr,
+ "Enum values by number"},
+
+ {"containing_type", (getter)GetContainingType, (setter)SetContainingType,
+ "Containing type"},
+ {"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
+ "Has Options"},
+ {"_options", (getter) nullptr, (setter)SetOptions, "Options"},
+ {"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
+ "Serialized Options"},
+ {nullptr},
};
} // namespace enum_descriptor
PyTypeObject PyEnumDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".EnumDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A Enum Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- enum_descriptor::Methods, // tp_methods
- 0, // tp_members
- enum_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".EnumDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A Enum Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ enum_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ enum_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyEnumDescriptor_FromDescriptor(
const EnumDescriptor* enum_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyEnumDescriptor_Type, enum_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyEnumDescriptor_Type,
+ enum_descriptor, nullptr);
}
const EnumDescriptor* PyEnumDescriptor_AsDescriptor(PyObject* obj) {
if (!PyObject_TypeCheck(obj, &PyEnumDescriptor_Type)) {
PyErr_SetString(PyExc_TypeError, "Not an EnumDescriptor");
- return NULL;
+ return nullptr;
}
return reinterpret_cast<const EnumDescriptor*>(
reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
@@ -1303,63 +1335,68 @@ static int SetSerializedOptions(PyBaseDescriptor *self, PyObject *value,
}
static PyGetSetDef Getters[] = {
- { "name", (getter)GetName, NULL, "name"},
- { "number", (getter)GetNumber, NULL, "number"},
- { "index", (getter)GetIndex, NULL, "index"},
- { "type", (getter)GetType, NULL, "index"},
-
- { "has_options", (getter)GetHasOptions, (setter)SetHasOptions, "Has Options"},
- { "_options", (getter)NULL, (setter)SetOptions, "Options"},
- { "_serialized_options", (getter)NULL, (setter)SetSerializedOptions,
- "Serialized Options"},
- {NULL}
+ {"name", (getter)GetName, nullptr, "name"},
+ {"number", (getter)GetNumber, nullptr, "number"},
+ {"index", (getter)GetIndex, nullptr, "index"},
+ {"type", (getter)GetType, nullptr, "index"},
+
+ {"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
+ "Has Options"},
+ {"_options", (getter) nullptr, (setter)SetOptions, "Options"},
+ {"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
+ "Serialized Options"},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS, },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {nullptr},
};
} // namespace enumvalue_descriptor
PyTypeObject PyEnumValueDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".EnumValueDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A EnumValue Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- enumvalue_descriptor::Methods, // tp_methods
- 0, // tp_members
- enumvalue_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".EnumValueDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A EnumValue Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ enumvalue_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ enumvalue_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyEnumValueDescriptor_FromDescriptor(
const EnumValueDescriptor* enumvalue_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyEnumValueDescriptor_Type, enumvalue_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyEnumValueDescriptor_Type,
+ enumvalue_descriptor, nullptr);
}
namespace file_descriptor {
@@ -1391,7 +1428,7 @@ static PyObject* GetPackage(PyFileDescriptor *self, void *closure) {
static PyObject* GetSerializedPb(PyFileDescriptor *self, void *closure) {
PyObject *serialized_pb = self->serialized_pb;
- if (serialized_pb != NULL) {
+ if (serialized_pb != nullptr) {
Py_INCREF(serialized_pb);
return serialized_pb;
}
@@ -1401,8 +1438,8 @@ static PyObject* GetSerializedPb(PyFileDescriptor *self, void *closure) {
file_proto.SerializePartialToString(&contents);
self->serialized_pb = PyBytes_FromStringAndSize(
contents.c_str(), contents.size());
- if (self->serialized_pb == NULL) {
- return NULL;
+ if (self->serialized_pb == nullptr) {
+ return nullptr;
}
Py_INCREF(self->serialized_pb);
return self->serialized_pb;
@@ -1445,6 +1482,10 @@ static int SetHasOptions(PyFileDescriptor *self, PyObject *value,
return CheckCalledFromGeneratedFile("has_options");
}
+static PyObject* GetDebugString(PyFileDescriptor* self) {
+ return PyString_FromCppString(_GetDescriptor(self)->DebugString());
+}
+
static PyObject* GetOptions(PyFileDescriptor *self) {
return GetOrBuildOptions(_GetDescriptor(self));
}
@@ -1469,31 +1510,36 @@ static PyObject* CopyToProto(PyFileDescriptor *self, PyObject *target) {
}
static PyGetSetDef Getters[] = {
- { "pool", (getter)GetPool, NULL, "pool"},
- { "name", (getter)GetName, NULL, "name"},
- { "package", (getter)GetPackage, NULL, "package"},
- { "serialized_pb", (getter)GetSerializedPb},
- { "message_types_by_name", (getter)GetMessageTypesByName, NULL,
- "Messages by name"},
- { "enum_types_by_name", (getter)GetEnumTypesByName, NULL, "Enums by name"},
- { "extensions_by_name", (getter)GetExtensionsByName, NULL,
- "Extensions by name"},
- { "services_by_name", (getter)GetServicesByName, NULL, "Services by name"},
- { "dependencies", (getter)GetDependencies, NULL, "Dependencies"},
- { "public_dependencies", (getter)GetPublicDependencies, NULL, "Dependencies"},
-
- { "has_options", (getter)GetHasOptions, (setter)SetHasOptions, "Has Options"},
- { "_options", (getter)NULL, (setter)SetOptions, "Options"},
- { "_serialized_options", (getter)NULL, (setter)SetSerializedOptions,
- "Serialized Options"},
- { "syntax", (getter)GetSyntax, (setter)NULL, "Syntax"},
- {NULL}
+ {"pool", (getter)GetPool, nullptr, "pool"},
+ {"name", (getter)GetName, nullptr, "name"},
+ {"package", (getter)GetPackage, nullptr, "package"},
+ {"serialized_pb", (getter)GetSerializedPb},
+ {"message_types_by_name", (getter)GetMessageTypesByName, nullptr,
+ "Messages by name"},
+ {"enum_types_by_name", (getter)GetEnumTypesByName, nullptr,
+ "Enums by name"},
+ {"extensions_by_name", (getter)GetExtensionsByName, nullptr,
+ "Extensions by name"},
+ {"services_by_name", (getter)GetServicesByName, nullptr,
+ "Services by name"},
+ {"dependencies", (getter)GetDependencies, nullptr, "Dependencies"},
+ {"public_dependencies", (getter)GetPublicDependencies, nullptr,
+ "Dependencies"},
+
+ {"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
+ "Has Options"},
+ {"_options", (getter) nullptr, (setter)SetOptions, "Options"},
+ {"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
+ "Serialized Options"},
+ {"syntax", (getter)GetSyntax, (setter) nullptr, "Syntax"},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS, },
- { "CopyToProto", (PyCFunction)CopyToProto, METH_O, },
- {NULL}
+ {"GetDebugString", (PyCFunction)GetDebugString, METH_NOARGS},
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {"CopyToProto", (PyCFunction)CopyToProto, METH_O},
+ {nullptr},
};
} // namespace file_descriptor
@@ -1504,46 +1550,50 @@ PyTypeObject PyFileDescriptor_Type = {
sizeof(PyFileDescriptor), // tp_basicsize
0, // tp_itemsize
(destructor)file_descriptor::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A File Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- file_descriptor::Methods, // tp_methods
- 0, // tp_members
- file_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
- 0, // tp_new
- PyObject_GC_Del, // tp_free
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A File Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ file_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ file_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
+ nullptr, // tp_alloc
+ nullptr, // tp_new
+ PyObject_GC_Del, // tp_free
};
PyObject* PyFileDescriptor_FromDescriptor(
const FileDescriptor* file_descriptor) {
return PyFileDescriptor_FromDescriptorWithSerializedPb(file_descriptor,
- NULL);
+ nullptr);
}
PyObject* PyFileDescriptor_FromDescriptorWithSerializedPb(
@@ -1551,8 +1601,8 @@ PyObject* PyFileDescriptor_FromDescriptorWithSerializedPb(
bool was_created;
PyObject* py_descriptor = descriptor::NewInternedDescriptor(
&PyFileDescriptor_Type, file_descriptor, &was_created);
- if (py_descriptor == NULL) {
- return NULL;
+ if (py_descriptor == nullptr) {
+ return nullptr;
}
if (was_created) {
PyFileDescriptor* cfile_descriptor =
@@ -1569,7 +1619,7 @@ PyObject* PyFileDescriptor_FromDescriptorWithSerializedPb(
const FileDescriptor* PyFileDescriptor_AsDescriptor(PyObject* obj) {
if (!PyObject_TypeCheck(obj, &PyFileDescriptor_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a FileDescriptor");
- return NULL;
+ return nullptr;
}
return reinterpret_cast<const FileDescriptor*>(
reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
@@ -1617,6 +1667,7 @@ static PyObject* GetHasOptions(PyBaseDescriptor *self, void *closure) {
Py_RETURN_FALSE;
}
}
+
static int SetHasOptions(PyBaseDescriptor *self, PyObject *value,
void *closure) {
return CheckCalledFromGeneratedFile("has_options");
@@ -1637,64 +1688,69 @@ static int SetSerializedOptions(PyBaseDescriptor *self, PyObject *value,
}
static PyGetSetDef Getters[] = {
- { "name", (getter)GetName, NULL, "Name"},
- { "full_name", (getter)GetFullName, NULL, "Full name"},
- { "index", (getter)GetIndex, NULL, "Index"},
-
- { "containing_type", (getter)GetContainingType, NULL, "Containing type"},
- { "has_options", (getter)GetHasOptions, (setter)SetHasOptions, "Has Options"},
- { "_options", (getter)NULL, (setter)SetOptions, "Options"},
- { "_serialized_options", (getter)NULL, (setter)SetSerializedOptions,
- "Serialized Options"},
- { "fields", (getter)GetFields, NULL, "Fields"},
- {NULL}
+ {"name", (getter)GetName, nullptr, "Name"},
+ {"full_name", (getter)GetFullName, nullptr, "Full name"},
+ {"index", (getter)GetIndex, nullptr, "Index"},
+
+ {"containing_type", (getter)GetContainingType, nullptr, "Containing type"},
+ {"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
+ "Has Options"},
+ {"_options", (getter) nullptr, (setter)SetOptions, "Options"},
+ {"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
+ "Serialized Options"},
+ {"fields", (getter)GetFields, nullptr, "Fields"},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {nullptr},
};
} // namespace oneof_descriptor
PyTypeObject PyOneofDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".OneofDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A Oneof Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- oneof_descriptor::Methods, // tp_methods
- 0, // tp_members
- oneof_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".OneofDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A Oneof Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ oneof_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ oneof_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyOneofDescriptor_FromDescriptor(
const OneofDescriptor* oneof_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyOneofDescriptor_Type, oneof_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyOneofDescriptor_Type,
+ oneof_descriptor, nullptr);
}
namespace service_descriptor {
@@ -1733,14 +1789,14 @@ static PyObject* FindMethodByName(PyBaseDescriptor *self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const MethodDescriptor* method_descriptor =
_GetDescriptor(self)->FindMethodByName(StringParam(name, name_size));
- if (method_descriptor == NULL) {
+ if (method_descriptor == nullptr) {
PyErr_Format(PyExc_KeyError, "Couldn't find method %.200s", name);
- return NULL;
+ return nullptr;
}
return PyMethodDescriptor_FromDescriptor(method_descriptor);
@@ -1756,69 +1812,73 @@ static PyObject* CopyToProto(PyBaseDescriptor *self, PyObject *target) {
}
static PyGetSetDef Getters[] = {
- { "name", (getter)GetName, NULL, "Name", NULL},
- { "full_name", (getter)GetFullName, NULL, "Full name", NULL},
- { "file", (getter)GetFile, NULL, "File descriptor"},
- { "index", (getter)GetIndex, NULL, "Index", NULL},
-
- { "methods", (getter)GetMethods, NULL, "Methods", NULL},
- { "methods_by_name", (getter)GetMethodsByName, NULL, "Methods by name", NULL},
- {NULL}
+ {"name", (getter)GetName, nullptr, "Name", nullptr},
+ {"full_name", (getter)GetFullName, nullptr, "Full name", nullptr},
+ {"file", (getter)GetFile, nullptr, "File descriptor"},
+ {"index", (getter)GetIndex, nullptr, "Index", nullptr},
+ {"methods", (getter)GetMethods, nullptr, "Methods", nullptr},
+ {"methods_by_name", (getter)GetMethodsByName, nullptr, "Methods by name",
+ nullptr},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS },
- { "CopyToProto", (PyCFunction)CopyToProto, METH_O, },
- { "FindMethodByName", (PyCFunction)FindMethodByName, METH_O },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {"CopyToProto", (PyCFunction)CopyToProto, METH_O},
+ {"FindMethodByName", (PyCFunction)FindMethodByName, METH_O},
+ {nullptr},
};
} // namespace service_descriptor
PyTypeObject PyServiceDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".ServiceDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A Service Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- service_descriptor::Methods, // tp_methods
- 0, // tp_members
- service_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".ServiceDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A Service Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ service_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ service_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyServiceDescriptor_FromDescriptor(
const ServiceDescriptor* service_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyServiceDescriptor_Type, service_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyServiceDescriptor_Type,
+ service_descriptor, nullptr);
}
const ServiceDescriptor* PyServiceDescriptor_AsDescriptor(PyObject* obj) {
if (!PyObject_TypeCheck(obj, &PyServiceDescriptor_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a ServiceDescriptor");
- return NULL;
+ return nullptr;
}
return reinterpret_cast<const ServiceDescriptor*>(
reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
@@ -1860,6 +1920,14 @@ static PyObject* GetOutputType(PyBaseDescriptor *self, void *closure) {
return PyMessageDescriptor_FromDescriptor(output_type);
}
+static PyObject* GetClientStreaming(PyBaseDescriptor* self, void* closure) {
+ return PyBool_FromLong(_GetDescriptor(self)->client_streaming() ? 1 : 0);
+}
+
+static PyObject* GetServerStreaming(PyBaseDescriptor* self, void* closure) {
+ return PyBool_FromLong(_GetDescriptor(self)->server_streaming() ? 1 : 0);
+}
+
static PyObject* GetOptions(PyBaseDescriptor *self) {
return GetOrBuildOptions(_GetDescriptor(self));
}
@@ -1869,62 +1937,70 @@ static PyObject* CopyToProto(PyBaseDescriptor *self, PyObject *target) {
}
static PyGetSetDef Getters[] = {
- { "name", (getter)GetName, NULL, "Name", NULL},
- { "full_name", (getter)GetFullName, NULL, "Full name", NULL},
- { "index", (getter)GetIndex, NULL, "Index", NULL},
- { "containing_service", (getter)GetContainingService, NULL,
- "Containing service", NULL},
- { "input_type", (getter)GetInputType, NULL, "Input type", NULL},
- { "output_type", (getter)GetOutputType, NULL, "Output type", NULL},
- {NULL}
+ {"name", (getter)GetName, nullptr, "Name", nullptr},
+ {"full_name", (getter)GetFullName, nullptr, "Full name", nullptr},
+ {"index", (getter)GetIndex, nullptr, "Index", nullptr},
+ {"containing_service", (getter)GetContainingService, nullptr,
+ "Containing service", nullptr},
+ {"input_type", (getter)GetInputType, nullptr, "Input type", nullptr},
+ {"output_type", (getter)GetOutputType, nullptr, "Output type", nullptr},
+ {"client_streaming", (getter)GetClientStreaming, nullptr,
+ "Client streaming", nullptr},
+ {"server_streaming", (getter)GetServerStreaming, nullptr,
+ "Server streaming", nullptr},
+ {nullptr},
};
static PyMethodDef Methods[] = {
- { "GetOptions", (PyCFunction)GetOptions, METH_NOARGS, },
- { "CopyToProto", (PyCFunction)CopyToProto, METH_O, },
- {NULL}
+ {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS},
+ {"CopyToProto", (PyCFunction)CopyToProto, METH_O},
+ {nullptr},
};
} // namespace method_descriptor
PyTypeObject PyMethodDescriptor_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".MethodDescriptor", // tp_name
- sizeof(PyBaseDescriptor), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A Method Descriptor", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- method_descriptor::Methods, // tp_methods
- 0, // tp_members
- method_descriptor::Getters, // tp_getset
- &descriptor::PyBaseDescriptor_Type, // tp_base
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".MethodDescriptor", // tp_name
+ sizeof(PyBaseDescriptor), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A Method Descriptor", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ method_descriptor::Methods, // tp_methods
+ nullptr, // tp_members
+ method_descriptor::Getters, // tp_getset
+ &descriptor::PyBaseDescriptor_Type, // tp_base
};
PyObject* PyMethodDescriptor_FromDescriptor(
const MethodDescriptor* method_descriptor) {
- return descriptor::NewInternedDescriptor(
- &PyMethodDescriptor_Type, method_descriptor, NULL);
+ return descriptor::NewInternedDescriptor(&PyMethodDescriptor_Type,
+ method_descriptor, nullptr);
}
// Add a enum values to a type dictionary.
@@ -1933,7 +2009,7 @@ static bool AddEnumValues(PyTypeObject *type,
for (int i = 0; i < enum_descriptor->value_count(); ++i) {
const EnumValueDescriptor* value = enum_descriptor->value(i);
ScopedPyObjectPtr obj(PyLong_FromLong(value->number()));
- if (obj == NULL) {
+ if (obj == nullptr) {
return false;
}
if (PyDict_SetItemString(type->tp_dict, value->name().c_str(), obj.get()) <
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h
index 47efbe35d7..a383a7927a 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h
@@ -33,6 +33,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/descriptor.h>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc
index fe85b2e351..b17d8348bf 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc
@@ -49,6 +49,7 @@
// because the Python API is based on C, and does not play well with C++
// inheritance.
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/descriptor.h>
@@ -57,12 +58,13 @@
#include <google/protobuf/pyext/descriptor.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#define PyString_AsStringAndSize(ob, charpp, sizep) \
- (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>( \
- PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
- ? -1 \
- : 0) \
- : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob) \
+ ? ((*(charpp) = const_cast<char*>( \
+ PyUnicode_AsUTF8AndSize(ob, (sizep)))) == nullptr \
+ ? -1 \
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
namespace google {
namespace protobuf {
@@ -157,59 +159,56 @@ namespace descriptor {
// Returns the C++ item descriptor for a given Python key.
// When the descriptor is found, return true and set *item.
-// When the descriptor is not found, return true, but set *item to NULL.
+// When the descriptor is not found, return true, but set *item to null.
// On error, returns false with an exception set.
static bool _GetItemByKey(PyContainer* self, PyObject* key, const void** item) {
switch (self->kind) {
- case PyContainer::KIND_BYNAME:
- {
- char* name;
- Py_ssize_t name_size;
- if (PyString_AsStringAndSize(key, &name, &name_size) < 0) {
- if (PyErr_ExceptionMatches(PyExc_TypeError)) {
- // Not a string, cannot be in the container.
- PyErr_Clear();
- *item = NULL;
- return true;
- }
- return false;
+ case PyContainer::KIND_BYNAME: {
+ char* name;
+ Py_ssize_t name_size;
+ if (PyString_AsStringAndSize(key, &name, &name_size) < 0) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
+ // Not a string, cannot be in the container.
+ PyErr_Clear();
+ *item = nullptr;
+ return true;
}
- *item = self->container_def->get_by_name_fn(
- self, StringParam(name, name_size));
- return true;
+ return false;
}
- case PyContainer::KIND_BYCAMELCASENAME:
- {
- char* camelcase_name;
- Py_ssize_t name_size;
- if (PyString_AsStringAndSize(key, &camelcase_name, &name_size) < 0) {
- if (PyErr_ExceptionMatches(PyExc_TypeError)) {
- // Not a string, cannot be in the container.
- PyErr_Clear();
- *item = NULL;
- return true;
- }
- return false;
+ *item = self->container_def->get_by_name_fn(self,
+ StringParam(name, name_size));
+ return true;
+ }
+ case PyContainer::KIND_BYCAMELCASENAME: {
+ char* camelcase_name;
+ Py_ssize_t name_size;
+ if (PyString_AsStringAndSize(key, &camelcase_name, &name_size) < 0) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
+ // Not a string, cannot be in the container.
+ PyErr_Clear();
+ *item = nullptr;
+ return true;
}
- *item = self->container_def->get_by_camelcase_name_fn(
- self, StringParam(camelcase_name, name_size));
- return true;
+ return false;
}
- case PyContainer::KIND_BYNUMBER:
- {
- Py_ssize_t number = PyNumber_AsSsize_t(key, NULL);
- if (number == -1 && PyErr_Occurred()) {
- if (PyErr_ExceptionMatches(PyExc_TypeError)) {
- // Not a number, cannot be in the container.
- PyErr_Clear();
- *item = NULL;
- return true;
- }
- return false;
+ *item = self->container_def->get_by_camelcase_name_fn(
+ self, StringParam(camelcase_name, name_size));
+ return true;
+ }
+ case PyContainer::KIND_BYNUMBER: {
+ Py_ssize_t number = PyNumber_AsSsize_t(key, nullptr);
+ if (number == -1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
+ // Not a number, cannot be in the container.
+ PyErr_Clear();
+ *item = nullptr;
+ return true;
}
- *item = self->container_def->get_by_number_fn(self, number);
- return true;
+ return false;
}
+ *item = self->container_def->get_by_number_fn(self, number);
+ return true;
+ }
default:
PyErr_SetNone(PyExc_NotImplementedError);
return false;
@@ -221,25 +220,22 @@ static bool _GetItemByKey(PyContainer* self, PyObject* key, const void** item) {
static PyObject* _NewKey_ByIndex(PyContainer* self, Py_ssize_t index) {
const void* item = self->container_def->get_by_index_fn(self, index);
switch (self->kind) {
- case PyContainer::KIND_BYNAME:
- {
+ case PyContainer::KIND_BYNAME: {
const TProtoStringType& name(self->container_def->get_item_name_fn(item));
return PyUnicode_FromStringAndSize(name.c_str(), name.size());
- }
- case PyContainer::KIND_BYCAMELCASENAME:
- {
+ }
+ case PyContainer::KIND_BYCAMELCASENAME: {
const TProtoStringType& name(
self->container_def->get_item_camelcase_name_fn(item));
return PyUnicode_FromStringAndSize(name.c_str(), name.size());
- }
- case PyContainer::KIND_BYNUMBER:
- {
- int value = self->container_def->get_item_number_fn(item);
- return PyLong_FromLong(value);
- }
+ }
+ case PyContainer::KIND_BYNUMBER: {
+ int value = self->container_def->get_item_number_fn(item);
+ return PyLong_FromLong(value);
+ }
default:
PyErr_SetNone(PyExc_NotImplementedError);
- return NULL;
+ return nullptr;
}
}
@@ -257,13 +253,13 @@ static Py_ssize_t Length(PyContainer* self) {
// The DescriptorMapping type.
static PyObject* Subscript(PyContainer* self, PyObject* key) {
- const void* item = NULL;
+ const void* item = nullptr;
if (!_GetItemByKey(self, key, &item)) {
- return NULL;
+ return nullptr;
}
if (!item) {
PyErr_SetObject(PyExc_KeyError, key);
- return NULL;
+ return nullptr;
}
return self->container_def->new_object_from_item_fn(item);
}
@@ -285,7 +281,7 @@ static PyMappingMethods MappingMappingMethods = {
};
static int Contains(PyContainer* self, PyObject* key) {
- const void* item = NULL;
+ const void* item = nullptr;
if (!_GetItemByKey(self, key, &item)) {
return -1;
}
@@ -344,11 +340,11 @@ static int DescriptorSequence_Equal(PyContainer* self, PyObject* other) {
}
for (int index = 0; index < size; index++) {
ScopedPyObjectPtr value1(_NewObj_ByIndex(self, index));
- if (value1 == NULL) {
+ if (value1 == nullptr) {
return -1;
}
PyObject* value2 = PyList_GetItem(other, index);
- if (value2 == NULL) {
+ if (value2 == nullptr) {
return -1;
}
int cmp = PyObject_RichCompareBool(value1.get(), value2, Py_EQ);
@@ -388,15 +384,15 @@ static int DescriptorMapping_Equal(PyContainer* self, PyObject* other) {
}
for (int index = 0; index < size; index++) {
ScopedPyObjectPtr key(_NewKey_ByIndex(self, index));
- if (key == NULL) {
+ if (key == nullptr) {
return -1;
}
ScopedPyObjectPtr value1(_NewObj_ByIndex(self, index));
- if (value1 == NULL) {
+ if (value1 == nullptr) {
return -1;
}
PyObject* value2 = PyDict_GetItem(other, key.get());
- if (value2 == NULL) {
+ if (value2 == nullptr) {
// Not found in the other dictionary
return 0;
}
@@ -426,7 +422,7 @@ static PyObject* RichCompare(PyContainer* self, PyObject* other, int opid) {
result = DescriptorMapping_Equal(self, other);
}
if (result < 0) {
- return NULL;
+ return nullptr;
}
if (result ^ (opid == Py_NE)) {
Py_RETURN_TRUE;
@@ -436,28 +432,28 @@ static PyObject* RichCompare(PyContainer* self, PyObject* other, int opid) {
}
static PySequenceMethods MappingSequenceMethods = {
- 0, // sq_length
- 0, // sq_concat
- 0, // sq_repeat
- 0, // sq_item
- 0, // sq_slice
- 0, // sq_ass_item
- 0, // sq_ass_slice
- (objobjproc)Contains, // sq_contains
+ nullptr, // sq_length
+ nullptr, // sq_concat
+ nullptr, // sq_repeat
+ nullptr, // sq_item
+ nullptr, // sq_slice
+ nullptr, // sq_ass_item
+ nullptr, // sq_ass_slice
+ (objobjproc)Contains, // sq_contains
};
static PyObject* Get(PyContainer* self, PyObject* args) {
PyObject* key;
PyObject* default_value = Py_None;
if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &default_value)) {
- return NULL;
+ return nullptr;
}
const void* item;
if (!_GetItemByKey(self, key, &item)) {
- return NULL;
+ return nullptr;
}
- if (item == NULL) {
+ if (item == nullptr) {
Py_INCREF(default_value);
return default_value;
}
@@ -467,13 +463,13 @@ static PyObject* Get(PyContainer* self, PyObject* args) {
static PyObject* Keys(PyContainer* self, PyObject* args) {
Py_ssize_t count = Length(self);
ScopedPyObjectPtr list(PyList_New(count));
- if (list == NULL) {
- return NULL;
+ if (list == nullptr) {
+ return nullptr;
}
for (Py_ssize_t index = 0; index < count; ++index) {
PyObject* key = _NewKey_ByIndex(self, index);
- if (key == NULL) {
- return NULL;
+ if (key == nullptr) {
+ return nullptr;
}
PyList_SET_ITEM(list.get(), index, key);
}
@@ -483,13 +479,13 @@ static PyObject* Keys(PyContainer* self, PyObject* args) {
static PyObject* Values(PyContainer* self, PyObject* args) {
Py_ssize_t count = Length(self);
ScopedPyObjectPtr list(PyList_New(count));
- if (list == NULL) {
- return NULL;
+ if (list == nullptr) {
+ return nullptr;
}
for (Py_ssize_t index = 0; index < count; ++index) {
PyObject* value = _NewObj_ByIndex(self, index);
- if (value == NULL) {
- return NULL;
+ if (value == nullptr) {
+ return nullptr;
}
PyList_SET_ITEM(list.get(), index, value);
}
@@ -499,22 +495,22 @@ static PyObject* Values(PyContainer* self, PyObject* args) {
static PyObject* Items(PyContainer* self, PyObject* args) {
Py_ssize_t count = Length(self);
ScopedPyObjectPtr list(PyList_New(count));
- if (list == NULL) {
- return NULL;
+ if (list == nullptr) {
+ return nullptr;
}
for (Py_ssize_t index = 0; index < count; ++index) {
ScopedPyObjectPtr obj(PyTuple_New(2));
- if (obj == NULL) {
- return NULL;
+ if (obj == nullptr) {
+ return nullptr;
}
PyObject* key = _NewKey_ByIndex(self, index);
- if (key == NULL) {
- return NULL;
+ if (key == nullptr) {
+ return nullptr;
}
PyTuple_SET_ITEM(obj.get(), 0, key);
PyObject* value = _NewObj_ByIndex(self, index);
- if (value == NULL) {
- return NULL;
+ if (value == nullptr) {
+ return nullptr;
}
PyTuple_SET_ITEM(obj.get(), 1, value);
PyList_SET_ITEM(list.get(), index, obj.release());
@@ -539,56 +535,59 @@ static PyObject* IterItems(PyContainer* self, PyObject* args) {
}
static PyMethodDef MappingMethods[] = {
- { "get", (PyCFunction)Get, METH_VARARGS, },
- { "keys", (PyCFunction)Keys, METH_NOARGS, },
- { "values", (PyCFunction)Values, METH_NOARGS, },
- { "items", (PyCFunction)Items, METH_NOARGS, },
- { "iterkeys", (PyCFunction)IterKeys, METH_NOARGS, },
- { "itervalues", (PyCFunction)IterValues, METH_NOARGS, },
- { "iteritems", (PyCFunction)IterItems, METH_NOARGS, },
- {NULL}
+ {"get", (PyCFunction)Get, METH_VARARGS},
+ {"keys", (PyCFunction)Keys, METH_NOARGS},
+ {"values", (PyCFunction)Values, METH_NOARGS},
+ {"items", (PyCFunction)Items, METH_NOARGS},
+ {"iterkeys", (PyCFunction)IterKeys, METH_NOARGS},
+ {"itervalues", (PyCFunction)IterValues, METH_NOARGS},
+ {"iteritems", (PyCFunction)IterItems, METH_NOARGS},
+ {nullptr},
};
PyTypeObject DescriptorMapping_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "DescriptorMapping", // tp_name
- sizeof(PyContainer), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- (reprfunc)ContainerRepr, // tp_repr
- 0, // tp_as_number
- &MappingSequenceMethods, // tp_as_sequence
- &MappingMappingMethods, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- 0, // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- (richcmpfunc)RichCompare, // tp_richcompare
- 0, // tp_weaklistoffset
- (getiterfunc)Iter, // tp_iter
- 0, // tp_iternext
- MappingMethods, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
- 0, // tp_new
- 0, // tp_free
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) "DescriptorMapping", // tp_name
+ sizeof(PyContainer), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ (reprfunc)ContainerRepr, // tp_repr
+ nullptr, // tp_as_number
+ &MappingSequenceMethods, // tp_as_sequence
+ &MappingMappingMethods, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ nullptr, // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ (richcmpfunc)RichCompare, // tp_richcompare
+ 0, // tp_weaklistoffset
+ (getiterfunc)Iter, // tp_iter
+ nullptr, // tp_iternext
+ MappingMethods, // tp_methods
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
+ nullptr, // tp_alloc
+ nullptr, // tp_new
+ nullptr, // tp_free
};
// The DescriptorSequence type.
@@ -599,7 +598,7 @@ static PyObject* GetItem(PyContainer* self, Py_ssize_t index) {
}
if (index < 0 || index >= Length(self)) {
PyErr_SetString(PyExc_IndexError, "index out of range");
- return NULL;
+ return nullptr;
}
return _NewObj_ByIndex(self, index);
}
@@ -609,15 +608,14 @@ SeqSubscript(PyContainer* self, PyObject* item) {
if (PyIndex_Check(item)) {
Py_ssize_t index;
index = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (index == -1 && PyErr_Occurred())
- return NULL;
+ if (index == -1 && PyErr_Occurred()) return nullptr;
return GetItem(self, index);
}
// Materialize the list and delegate the operation to it.
ScopedPyObjectPtr list(PyObject_CallFunctionObjArgs(
- reinterpret_cast<PyObject*>(&PyList_Type), self, NULL));
- if (list == NULL) {
- return NULL;
+ reinterpret_cast<PyObject*>(&PyList_Type), self, nullptr));
+ if (list == nullptr) {
+ return nullptr;
}
return Py_TYPE(list.get())->tp_as_mapping->mp_subscript(list.get(), item);
}
@@ -632,7 +630,7 @@ int Find(PyContainer* self, PyObject* item) {
// a specific item belongs to only one sequence, depending on its position in
// the .proto file definition.
const void* descriptor_ptr = PyDescriptor_AsVoidPtr(item);
- if (descriptor_ptr == NULL) {
+ if (descriptor_ptr == nullptr) {
PyErr_Clear();
// Not a descriptor, it cannot be in the list.
return -1;
@@ -668,7 +666,7 @@ static PyObject* Index(PyContainer* self, PyObject* item) {
if (position < 0) {
// Not found
PyErr_SetNone(PyExc_ValueError);
- return NULL;
+ return nullptr;
} else {
return PyLong_FromLong(position);
}
@@ -701,7 +699,7 @@ static PyObject* Append(PyContainer* self, PyObject* args) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not a mutable sequence",
Py_TYPE(self)->tp_name);
- return NULL;
+ return nullptr;
}
static PyObject* Reversed(PyContainer* self, PyObject* args) {
@@ -710,77 +708,80 @@ static PyObject* Reversed(PyContainer* self, PyObject* args) {
}
static PyMethodDef SeqMethods[] = {
- { "index", (PyCFunction)Index, METH_O, },
- { "count", (PyCFunction)Count, METH_O, },
- { "append", (PyCFunction)Append, METH_O, },
- { "__reversed__", (PyCFunction)Reversed, METH_NOARGS, },
- {NULL}
+ {"index", (PyCFunction)Index, METH_O},
+ {"count", (PyCFunction)Count, METH_O},
+ {"append", (PyCFunction)Append, METH_O},
+ {"__reversed__", (PyCFunction)Reversed, METH_NOARGS},
+ {nullptr},
};
static PySequenceMethods SeqSequenceMethods = {
- (lenfunc)Length, // sq_length
- 0, // sq_concat
- 0, // sq_repeat
- (ssizeargfunc)GetItem, // sq_item
- 0, // sq_slice
- 0, // sq_ass_item
- 0, // sq_ass_slice
- (objobjproc)SeqContains, // sq_contains
+ (lenfunc)Length, // sq_length
+ nullptr, // sq_concat
+ nullptr, // sq_repeat
+ (ssizeargfunc)GetItem, // sq_item
+ nullptr, // sq_slice
+ nullptr, // sq_ass_item
+ nullptr, // sq_ass_slice
+ (objobjproc)SeqContains, // sq_contains
};
static PyMappingMethods SeqMappingMethods = {
- (lenfunc)Length, // mp_length
- (binaryfunc)SeqSubscript, // mp_subscript
- 0, // mp_ass_subscript
+ (lenfunc)Length, // mp_length
+ (binaryfunc)SeqSubscript, // mp_subscript
+ nullptr, // mp_ass_subscript
};
PyTypeObject DescriptorSequence_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "DescriptorSequence", // tp_name
- sizeof(PyContainer), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- (reprfunc)ContainerRepr, // tp_repr
- 0, // tp_as_number
- &SeqSequenceMethods, // tp_as_sequence
- &SeqMappingMethods, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- 0, // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- (richcmpfunc)RichCompare, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- SeqMethods, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
- 0, // tp_new
- 0, // tp_free
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) "DescriptorSequence", // tp_name
+ sizeof(PyContainer), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ (reprfunc)ContainerRepr, // tp_repr
+ nullptr, // tp_as_number
+ &SeqSequenceMethods, // tp_as_sequence
+ &SeqMappingMethods, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ nullptr, // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ (richcmpfunc)RichCompare, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ SeqMethods, // tp_methods
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
+ nullptr, // tp_alloc
+ nullptr, // tp_new
+ nullptr, // tp_free
};
static PyObject* NewMappingByName(
DescriptorContainerDef* container_def, const void* descriptor) {
PyContainer* self = PyObject_New(PyContainer, &DescriptorMapping_Type);
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
self->descriptor = descriptor;
self->container_def = container_def;
@@ -791,8 +792,8 @@ static PyObject* NewMappingByName(
static PyObject* NewMappingByCamelcaseName(
DescriptorContainerDef* container_def, const void* descriptor) {
PyContainer* self = PyObject_New(PyContainer, &DescriptorMapping_Type);
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
self->descriptor = descriptor;
self->container_def = container_def;
@@ -802,14 +803,14 @@ static PyObject* NewMappingByCamelcaseName(
static PyObject* NewMappingByNumber(
DescriptorContainerDef* container_def, const void* descriptor) {
- if (container_def->get_by_number_fn == NULL ||
- container_def->get_item_number_fn == NULL) {
+ if (container_def->get_by_number_fn == nullptr ||
+ container_def->get_item_number_fn == nullptr) {
PyErr_SetNone(PyExc_NotImplementedError);
- return NULL;
+ return nullptr;
}
PyContainer* self = PyObject_New(PyContainer, &DescriptorMapping_Type);
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
self->descriptor = descriptor;
self->container_def = container_def;
@@ -820,8 +821,8 @@ static PyObject* NewMappingByNumber(
static PyObject* NewSequence(
DescriptorContainerDef* container_def, const void* descriptor) {
PyContainer* self = PyObject_New(PyContainer, &DescriptorSequence_Type);
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
self->descriptor = descriptor;
self->container_def = container_def;
@@ -839,8 +840,8 @@ static void Iterator_Dealloc(PyContainerIterator* self) {
static PyObject* Iterator_Next(PyContainerIterator* self) {
int count = self->container->container_def->count_fn(self->container);
if (self->index >= count) {
- // Return NULL with no exception to indicate the end.
- return NULL;
+ // Return null with no exception to indicate the end.
+ return nullptr;
}
int index = self->index;
self->index += 1;
@@ -851,80 +852,83 @@ static PyObject* Iterator_Next(PyContainerIterator* self) {
return _NewObj_ByIndex(self->container, index);
case PyContainerIterator::KIND_ITERVALUE_REVERSED:
return _NewObj_ByIndex(self->container, count - index - 1);
- case PyContainerIterator::KIND_ITERITEM:
- {
- PyObject* obj = PyTuple_New(2);
- if (obj == NULL) {
- return NULL;
- }
- PyObject* key = _NewKey_ByIndex(self->container, index);
- if (key == NULL) {
- Py_DECREF(obj);
- return NULL;
- }
- PyTuple_SET_ITEM(obj, 0, key);
- PyObject* value = _NewObj_ByIndex(self->container, index);
- if (value == NULL) {
- Py_DECREF(obj);
- return NULL;
- }
- PyTuple_SET_ITEM(obj, 1, value);
- return obj;
+ case PyContainerIterator::KIND_ITERITEM: {
+ PyObject* obj = PyTuple_New(2);
+ if (obj == nullptr) {
+ return nullptr;
+ }
+ PyObject* key = _NewKey_ByIndex(self->container, index);
+ if (key == nullptr) {
+ Py_DECREF(obj);
+ return nullptr;
}
+ PyTuple_SET_ITEM(obj, 0, key);
+ PyObject* value = _NewObj_ByIndex(self->container, index);
+ if (value == nullptr) {
+ Py_DECREF(obj);
+ return nullptr;
+ }
+ PyTuple_SET_ITEM(obj, 1, value);
+ return obj;
+ }
default:
PyErr_SetNone(PyExc_NotImplementedError);
- return NULL;
+ return nullptr;
}
}
static PyTypeObject ContainerIterator_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "DescriptorContainerIterator", // tp_name
- sizeof(PyContainerIterator), // tp_basicsize
- 0, // tp_itemsize
- (destructor)Iterator_Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- 0, // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- PyObject_SelfIter, // tp_iter
- (iternextfunc)Iterator_Next, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
- 0, // tp_new
- 0, // tp_free
+ PyVarObject_HEAD_INIT(&PyType_Type,
+ 0) "DescriptorContainerIterator", // tp_name
+ sizeof(PyContainerIterator), // tp_basicsize
+ 0, // tp_itemsize
+ (destructor)Iterator_Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ nullptr, // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ PyObject_SelfIter, // tp_iter
+ (iternextfunc)Iterator_Next, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
+ nullptr, // tp_alloc
+ nullptr, // tp_new
+ nullptr, // tp_free
};
static PyObject* NewContainerIterator(PyContainer* container,
PyContainerIterator::IterKind kind) {
PyContainerIterator* self = PyObject_New(PyContainerIterator,
&ContainerIterator_Type);
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
Py_INCREF(container);
self->container = container;
@@ -992,17 +996,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "MessageFields",
- Count,
- GetByIndex,
- GetByName,
- GetByCamelcaseName,
- GetByNumber,
- NewObjectFromItem,
- GetItemName,
- GetItemCamelcaseName,
- GetItemNumber,
- GetItemIndex,
+ "MessageFields", Count, GetByIndex, GetByName,
+ GetByCamelcaseName, GetByNumber, NewObjectFromItem, GetItemName,
+ GetItemCamelcaseName, GetItemNumber, GetItemIndex,
};
} // namespace fields
@@ -1053,17 +1049,17 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "MessageNestedTypes",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "MessageNestedTypes",
+ Count,
+ GetByIndex,
+ GetByName,
+ nullptr,
+ nullptr,
+ NewObjectFromItem,
+ GetItemName,
+ nullptr,
+ nullptr,
+ GetItemIndex,
};
} // namespace nested_types
@@ -1105,17 +1101,17 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "MessageNestedEnums",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "MessageNestedEnums",
+ Count,
+ GetByIndex,
+ GetByName,
+ nullptr,
+ nullptr,
+ NewObjectFromItem,
+ GetItemName,
+ nullptr,
+ nullptr,
+ GetItemIndex,
};
} // namespace enums
@@ -1154,7 +1150,7 @@ static const void* GetByName(PyContainer* self, ConstStringParam name) {
static const void* GetByIndex(PyContainer* self, int index) {
// This is not optimal, but the number of enums *types* in a given message
// is small. This function is only used when iterating over the mapping.
- const EnumDescriptor* enum_type = NULL;
+ const EnumDescriptor* enum_type = nullptr;
int enum_type_count = GetDescriptor(self)->enum_type_count();
for (int i = 0; i < enum_type_count; ++i) {
enum_type = GetDescriptor(self)->enum_type(i);
@@ -1180,17 +1176,8 @@ static const TProtoStringType& GetItemName(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "MessageEnumValues",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- NULL,
+ "MessageEnumValues", Count, GetByIndex, GetByName, nullptr, nullptr,
+ NewObjectFromItem, GetItemName, nullptr, nullptr, nullptr,
};
} // namespace enumvalues
@@ -1228,17 +1215,17 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "MessageExtensions",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "MessageExtensions",
+ Count,
+ GetByIndex,
+ GetByName,
+ nullptr,
+ nullptr,
+ NewObjectFromItem,
+ GetItemName,
+ nullptr,
+ nullptr,
+ GetItemIndex,
};
} // namespace extensions
@@ -1280,17 +1267,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "MessageOneofs",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "MessageOneofs", Count, GetByIndex, GetByName,
+ nullptr, nullptr, NewObjectFromItem, GetItemName,
+ nullptr, nullptr, GetItemIndex,
};
} // namespace oneofs
@@ -1351,17 +1330,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "EnumValues",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- GetByNumber,
- NewObjectFromItem,
- GetItemName,
- NULL,
- GetItemNumber,
- GetItemIndex,
+ "EnumValues", Count, GetByIndex, GetByName,
+ nullptr, GetByNumber, NewObjectFromItem, GetItemName,
+ nullptr, GetItemNumber, GetItemIndex,
};
} // namespace enumvalues
@@ -1409,17 +1380,8 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "OneofFields",
- Count,
- GetByIndex,
- NULL,
- NULL,
- NULL,
- NewObjectFromItem,
- NULL,
- NULL,
- NULL,
- GetItemIndex,
+ "OneofFields", Count, GetByIndex, nullptr, nullptr, nullptr,
+ NewObjectFromItem, nullptr, nullptr, nullptr, GetItemIndex,
};
} // namespace fields
@@ -1467,17 +1429,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "ServiceMethods",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "ServiceMethods", Count, GetByIndex, GetByName,
+ nullptr, nullptr, NewObjectFromItem, GetItemName,
+ nullptr, nullptr, GetItemIndex,
};
} // namespace methods
@@ -1529,17 +1483,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "FileMessages",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "FileMessages", Count, GetByIndex, GetByName,
+ nullptr, nullptr, NewObjectFromItem, GetItemName,
+ nullptr, nullptr, GetItemIndex,
};
} // namespace messages
@@ -1577,17 +1523,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "FileEnums",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "FileEnums", Count, GetByIndex, GetByName,
+ nullptr, nullptr, NewObjectFromItem, GetItemName,
+ nullptr, nullptr, GetItemIndex,
};
} // namespace enums
@@ -1625,17 +1563,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "FileExtensions",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "FileExtensions", Count, GetByIndex, GetByName,
+ nullptr, nullptr, NewObjectFromItem, GetItemName,
+ nullptr, nullptr, GetItemIndex,
};
} // namespace extensions
@@ -1673,17 +1603,9 @@ static int GetItemIndex(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "FileServices",
- Count,
- GetByIndex,
- GetByName,
- NULL,
- NULL,
- NewObjectFromItem,
- GetItemName,
- NULL,
- NULL,
- GetItemIndex,
+ "FileServices", Count, GetByIndex, GetByName,
+ nullptr, nullptr, NewObjectFromItem, GetItemName,
+ nullptr, nullptr, GetItemIndex,
};
} // namespace services
@@ -1709,17 +1631,8 @@ static PyObject* NewObjectFromItem(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "FileDependencies",
- Count,
- GetByIndex,
- NULL,
- NULL,
- NULL,
- NewObjectFromItem,
- NULL,
- NULL,
- NULL,
- NULL,
+ "FileDependencies", Count, GetByIndex, nullptr, nullptr, nullptr,
+ NewObjectFromItem, nullptr, nullptr, nullptr, nullptr,
};
} // namespace dependencies
@@ -1745,17 +1658,8 @@ static PyObject* NewObjectFromItem(const void* item) {
}
static DescriptorContainerDef ContainerDef = {
- "FilePublicDependencies",
- Count,
- GetByIndex,
- NULL,
- NULL,
- NULL,
- NewObjectFromItem,
- NULL,
- NULL,
- NULL,
- NULL,
+ "FilePublicDependencies", Count, GetByIndex, nullptr, nullptr, nullptr,
+ NewObjectFromItem, nullptr, nullptr, nullptr, nullptr,
};
} // namespace public_dependencies
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.h b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.h
index 4e05c58e2b..cf2cf4ad0b 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.h
@@ -34,6 +34,7 @@
// Mappings and Sequences of descriptors.
// They implement containers like fields_by_name, EnumDescriptor.values...
// See descriptor_containers.cc for more description.
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
namespace google {
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc
index be8089841c..14f5bf2230 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc
@@ -56,7 +56,7 @@ PyDescriptorDatabase::~PyDescriptorDatabase() { Py_DECREF(py_database_); }
// Handles all kinds of Python errors, which are simply logged.
static bool GetFileDescriptorProto(PyObject* py_descriptor,
FileDescriptorProto* output) {
- if (py_descriptor == NULL) {
+ if (py_descriptor == nullptr) {
if (PyErr_ExceptionMatches(PyExc_KeyError)) {
// Expected error: item was simply not found.
PyErr_Clear();
@@ -83,8 +83,8 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor,
// Slow path: serialize the message. This allows to use databases which
// use a different implementation of FileDescriptorProto.
ScopedPyObjectPtr serialized_pb(
- PyObject_CallMethod(py_descriptor, "SerializeToString", NULL));
- if (serialized_pb == NULL) {
+ PyObject_CallMethod(py_descriptor, "SerializeToString", nullptr));
+ if (serialized_pb == nullptr) {
GOOGLE_LOG(ERROR)
<< "DescriptorDatabase method did not return a FileDescriptorProto";
PyErr_Print();
@@ -134,7 +134,7 @@ bool PyDescriptorDatabase::FindFileContainingExtension(
FileDescriptorProto* output) {
ScopedPyObjectPtr py_method(
PyObject_GetAttrString(py_database_, "FindFileContainingExtension"));
- if (py_method == NULL) {
+ if (py_method == nullptr) {
// This method is not implemented, returns without error.
PyErr_Clear();
return false;
@@ -153,7 +153,7 @@ bool PyDescriptorDatabase::FindAllExtensionNumbers(
const TProtoStringType& containing_type, std::vector<int>* output) {
ScopedPyObjectPtr py_method(
PyObject_GetAttrString(py_database_, "FindAllExtensionNumbers"));
- if (py_method == NULL) {
+ if (py_method == nullptr) {
// This method is not implemented, returns without error.
PyErr_Clear();
return false;
@@ -161,7 +161,7 @@ bool PyDescriptorDatabase::FindAllExtensionNumbers(
ScopedPyObjectPtr py_list(
PyObject_CallFunction(py_method.get(), "s#", containing_type.c_str(),
containing_type.size()));
- if (py_list == NULL) {
+ if (py_list == nullptr) {
PyErr_Print();
return false;
}
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h
index 59918a6d92..08318ff98f 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/descriptor_database.h>
@@ -42,17 +43,18 @@ namespace python {
class PyDescriptorDatabase : public DescriptorDatabase {
public:
explicit PyDescriptorDatabase(PyObject* py_database);
- ~PyDescriptorDatabase();
+ ~PyDescriptorDatabase() override;
// Implement the abstract interface. All these functions fill the output
// with a copy of FileDescriptorProto.
// Find a file by file name.
- bool FindFileByName(const TProtoStringType& filename, FileDescriptorProto* output);
+ bool FindFileByName(const TProtoStringType& filename,
+ FileDescriptorProto* output) override;
// Find the file that declares the given fully-qualified symbol name.
bool FindFileContainingSymbol(const TProtoStringType& symbol_name,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
// Find the file which defines an extension extending the given message type
// with the given field number.
@@ -60,14 +62,14 @@ class PyDescriptorDatabase : public DescriptorDatabase {
// Python objects are not required to implement this method.
bool FindFileContainingExtension(const TProtoStringType& containing_type,
int field_number,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
// Finds the tag numbers used by all known extensions of
// containing_type, and appends them to output in an undefined
// order.
// Python objects are not required to implement this method.
bool FindAllExtensionNumbers(const TProtoStringType& containing_type,
- std::vector<int>* output);
+ std::vector<int>* output) override;
private:
// The python object that implements the database. The reference is owned.
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc
index 1ba01d55d8..2dd47bdb23 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc
@@ -32,6 +32,7 @@
#include <unordered_map>
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/descriptor.pb.h>
@@ -43,12 +44,13 @@
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
#include <google/protobuf/stubs/hash.h>
-#define PyString_AsStringAndSize(ob, charpp, sizep) \
- (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>( \
- PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
- ? -1 \
- : 0) \
- : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob) \
+ ? ((*(charpp) = const_cast<char*>( \
+ PyUnicode_AsUTF8AndSize(ob, (sizep)))) == nullptr \
+ ? -1 \
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
namespace google {
namespace protobuf {
@@ -98,13 +100,13 @@ class BuildFileErrorCollector : public DescriptorPool::ErrorCollector {
static PyDescriptorPool* _CreateDescriptorPool() {
PyDescriptorPool* cpool = PyObject_GC_New(
PyDescriptorPool, &PyDescriptorPool_Type);
- if (cpool == NULL) {
- return NULL;
+ if (cpool == nullptr) {
+ return nullptr;
}
cpool->error_collector = nullptr;
- cpool->underlay = NULL;
- cpool->database = NULL;
+ cpool->underlay = nullptr;
+ cpool->database = nullptr;
cpool->is_owned = false;
cpool->is_mutable = false;
@@ -112,9 +114,9 @@ static PyDescriptorPool* _CreateDescriptorPool() {
cpool->py_message_factory = message_factory::NewMessageFactory(
&PyMessageFactory_Type, cpool);
- if (cpool->py_message_factory == NULL) {
+ if (cpool->py_message_factory == nullptr) {
Py_DECREF(cpool);
- return NULL;
+ return nullptr;
}
PyObject_GC_Track(cpool);
@@ -130,8 +132,8 @@ static PyDescriptorPool* _CreateDescriptorPool() {
static PyDescriptorPool* PyDescriptorPool_NewWithUnderlay(
const DescriptorPool* underlay) {
PyDescriptorPool* cpool = _CreateDescriptorPool();
- if (cpool == NULL) {
- return NULL;
+ if (cpool == nullptr) {
+ return nullptr;
}
cpool->pool = new DescriptorPool(underlay);
cpool->is_owned = true;
@@ -142,7 +144,7 @@ static PyDescriptorPool* PyDescriptorPool_NewWithUnderlay(
std::make_pair(cpool->pool, cpool)).second) {
// Should never happen -- would indicate an internal error / bug.
PyErr_SetString(PyExc_ValueError, "DescriptorPool already registered");
- return NULL;
+ return nullptr;
}
return cpool;
@@ -151,10 +153,10 @@ static PyDescriptorPool* PyDescriptorPool_NewWithUnderlay(
static PyDescriptorPool* PyDescriptorPool_NewWithDatabase(
DescriptorDatabase* database) {
PyDescriptorPool* cpool = _CreateDescriptorPool();
- if (cpool == NULL) {
- return NULL;
+ if (cpool == nullptr) {
+ return nullptr;
}
- if (database != NULL) {
+ if (database != nullptr) {
cpool->error_collector = new BuildFileErrorCollector();
cpool->pool = new DescriptorPool(database, cpool->error_collector);
cpool->is_mutable = false;
@@ -168,7 +170,7 @@ static PyDescriptorPool* PyDescriptorPool_NewWithDatabase(
if (!descriptor_pool_map->insert(std::make_pair(cpool->pool, cpool)).second) {
// Should never happen -- would indicate an internal error / bug.
PyErr_SetString(PyExc_ValueError, "DescriptorPool already registered");
- return NULL;
+ return nullptr;
}
return cpool;
@@ -177,13 +179,13 @@ static PyDescriptorPool* PyDescriptorPool_NewWithDatabase(
// The public DescriptorPool constructor.
static PyObject* New(PyTypeObject* type,
PyObject* args, PyObject* kwargs) {
- static const char* kwlist[] = {"descriptor_db", 0};
- PyObject* py_database = NULL;
+ static const char* kwlist[] = {"descriptor_db", nullptr};
+ PyObject* py_database = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O",
const_cast<char**>(kwlist), &py_database)) {
- return NULL;
+ return nullptr;
}
- DescriptorDatabase* database = NULL;
+ DescriptorDatabase* database = nullptr;
if (py_database && py_database != Py_None) {
database = new PyDescriptorDatabase(py_database);
}
@@ -232,24 +234,24 @@ PyObject* SetErrorFromCollector(DescriptorPool::ErrorCollector* self,
PyErr_Format(PyExc_KeyError, "Couldn't build file for %s %.200s\n%s",
error_type, name, error_collector->error_message.c_str());
error_collector->Clear();
- return NULL;
+ return nullptr;
}
PyErr_Format(PyExc_KeyError, "Couldn't find %s %.200s", error_type, name);
- return NULL;
+ return nullptr;
}
static PyObject* FindMessageByName(PyObject* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const Descriptor* message_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindMessageTypeByName(
StringParam(name, name_size));
- if (message_descriptor == NULL) {
+ if (message_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
"message");
@@ -266,14 +268,14 @@ static PyObject* FindFileByName(PyObject* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
PyDescriptorPool* py_pool = reinterpret_cast<PyDescriptorPool*>(self);
const FileDescriptor* file_descriptor =
py_pool->pool->FindFileByName(StringParam(name, name_size));
- if (file_descriptor == NULL) {
+ if (file_descriptor == nullptr) {
return SetErrorFromCollector(py_pool->error_collector, name, "file");
}
return PyFileDescriptor_FromDescriptor(file_descriptor);
@@ -283,12 +285,12 @@ PyObject* FindFieldByName(PyDescriptorPool* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const FieldDescriptor* field_descriptor =
self->pool->FindFieldByName(StringParam(name, name_size));
- if (field_descriptor == NULL) {
+ if (field_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name, "field");
}
@@ -304,12 +306,12 @@ PyObject* FindExtensionByName(PyDescriptorPool* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const FieldDescriptor* field_descriptor =
self->pool->FindExtensionByName(StringParam(name, name_size));
- if (field_descriptor == NULL) {
+ if (field_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name,
"extension field");
}
@@ -326,12 +328,12 @@ PyObject* FindEnumTypeByName(PyDescriptorPool* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const EnumDescriptor* enum_descriptor =
self->pool->FindEnumTypeByName(StringParam(name, name_size));
- if (enum_descriptor == NULL) {
+ if (enum_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name, "enum");
}
@@ -347,12 +349,12 @@ PyObject* FindOneofByName(PyDescriptorPool* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const OneofDescriptor* oneof_descriptor =
self->pool->FindOneofByName(StringParam(name, name_size));
- if (oneof_descriptor == NULL) {
+ if (oneof_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name, "oneof");
}
@@ -368,13 +370,13 @@ static PyObject* FindServiceByName(PyObject* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const ServiceDescriptor* service_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindServiceByName(
StringParam(name, name_size));
- if (service_descriptor == NULL) {
+ if (service_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
"service");
@@ -388,13 +390,13 @@ static PyObject* FindMethodByName(PyObject* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const MethodDescriptor* method_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindMethodByName(
StringParam(name, name_size));
- if (method_descriptor == NULL) {
+ if (method_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
"method");
@@ -408,13 +410,13 @@ static PyObject* FindFileContainingSymbol(PyObject* self, PyObject* arg) {
Py_ssize_t name_size;
char* name;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
const FileDescriptor* file_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindFileContainingSymbol(
StringParam(name, name_size));
- if (file_descriptor == NULL) {
+ if (file_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
"symbol");
@@ -428,18 +430,18 @@ static PyObject* FindExtensionByNumber(PyObject* self, PyObject* args) {
PyObject* message_descriptor;
int number;
if (!PyArg_ParseTuple(args, "Oi", &message_descriptor, &number)) {
- return NULL;
+ return nullptr;
}
const Descriptor* descriptor = PyMessageDescriptor_AsDescriptor(
message_descriptor);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
const FieldDescriptor* extension_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindExtensionByNumber(
descriptor, number);
- if (extension_descriptor == NULL) {
+ if (extension_descriptor == nullptr) {
BuildFileErrorCollector* error_collector =
reinterpret_cast<BuildFileErrorCollector*>(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector);
@@ -447,10 +449,10 @@ static PyObject* FindExtensionByNumber(PyObject* self, PyObject* args) {
PyErr_Format(PyExc_KeyError, "Couldn't build file for Extension %.d\n%s",
number, error_collector->error_message.c_str());
error_collector->Clear();
- return NULL;
+ return nullptr;
}
PyErr_Format(PyExc_KeyError, "Couldn't find Extension %d", number);
- return NULL;
+ return nullptr;
}
@@ -459,8 +461,8 @@ static PyObject* FindExtensionByNumber(PyObject* self, PyObject* args) {
static PyObject* FindAllExtensions(PyObject* self, PyObject* arg) {
const Descriptor* descriptor = PyMessageDescriptor_AsDescriptor(arg);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
std::vector<const FieldDescriptor*> extensions;
@@ -468,13 +470,13 @@ static PyObject* FindAllExtensions(PyObject* self, PyObject* arg) {
descriptor, &extensions);
ScopedPyObjectPtr result(PyList_New(extensions.size()));
- if (result == NULL) {
- return NULL;
+ if (result == nullptr) {
+ return nullptr;
}
for (int i = 0; i < extensions.size(); i++) {
PyObject* extension = PyFieldDescriptor_FromDescriptor(extensions[i]);
- if (extension == NULL) {
- return NULL;
+ if (extension == nullptr) {
+ return nullptr;
}
PyList_SET_ITEM(result.get(), i, extension); // Steals the reference.
}
@@ -494,7 +496,7 @@ static PyObject* AddFileDescriptor(PyObject* self, PyObject* descriptor) {
const FileDescriptor* file_descriptor =
PyFileDescriptor_AsDescriptor(descriptor);
if (!file_descriptor) {
- return NULL;
+ return nullptr;
}
if (file_descriptor !=
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindFileByName(
@@ -502,7 +504,7 @@ static PyObject* AddFileDescriptor(PyObject* self, PyObject* descriptor) {
PyErr_Format(PyExc_ValueError,
"The file descriptor %s does not belong to this pool",
file_descriptor->name().c_str());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -511,7 +513,7 @@ static PyObject* AddDescriptor(PyObject* self, PyObject* descriptor) {
const Descriptor* message_descriptor =
PyMessageDescriptor_AsDescriptor(descriptor);
if (!message_descriptor) {
- return NULL;
+ return nullptr;
}
if (message_descriptor !=
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindMessageTypeByName(
@@ -519,7 +521,7 @@ static PyObject* AddDescriptor(PyObject* self, PyObject* descriptor) {
PyErr_Format(PyExc_ValueError,
"The message descriptor %s does not belong to this pool",
message_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -528,7 +530,7 @@ static PyObject* AddEnumDescriptor(PyObject* self, PyObject* descriptor) {
const EnumDescriptor* enum_descriptor =
PyEnumDescriptor_AsDescriptor(descriptor);
if (!enum_descriptor) {
- return NULL;
+ return nullptr;
}
if (enum_descriptor !=
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindEnumTypeByName(
@@ -536,7 +538,7 @@ static PyObject* AddEnumDescriptor(PyObject* self, PyObject* descriptor) {
PyErr_Format(PyExc_ValueError,
"The enum descriptor %s does not belong to this pool",
enum_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -545,7 +547,7 @@ static PyObject* AddExtensionDescriptor(PyObject* self, PyObject* descriptor) {
const FieldDescriptor* extension_descriptor =
PyFieldDescriptor_AsDescriptor(descriptor);
if (!extension_descriptor) {
- return NULL;
+ return nullptr;
}
if (extension_descriptor !=
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindExtensionByName(
@@ -553,7 +555,7 @@ static PyObject* AddExtensionDescriptor(PyObject* self, PyObject* descriptor) {
PyErr_Format(PyExc_ValueError,
"The extension descriptor %s does not belong to this pool",
extension_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -562,7 +564,7 @@ static PyObject* AddServiceDescriptor(PyObject* self, PyObject* descriptor) {
const ServiceDescriptor* service_descriptor =
PyServiceDescriptor_AsDescriptor(descriptor);
if (!service_descriptor) {
- return NULL;
+ return nullptr;
}
if (service_descriptor !=
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindServiceByName(
@@ -570,7 +572,7 @@ static PyObject* AddServiceDescriptor(PyObject* self, PyObject* descriptor) {
PyErr_Format(PyExc_ValueError,
"The service descriptor %s does not belong to this pool",
service_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -581,12 +583,12 @@ static PyObject* AddSerializedFile(PyObject* pself, PyObject* serialized_pb) {
char* message_type;
Py_ssize_t message_len;
- if (self->database != NULL) {
+ if (self->database != nullptr) {
PyErr_SetString(
PyExc_ValueError,
"Cannot call Add on a DescriptorPool that uses a DescriptorDatabase. "
"Add your file to the underlying database.");
- return NULL;
+ return nullptr;
}
if (!self->is_mutable) {
PyErr_SetString(
@@ -596,22 +598,22 @@ static PyObject* AddSerializedFile(PyObject* pself, PyObject* serialized_pb) {
}
if (PyBytes_AsStringAndSize(serialized_pb, &message_type, &message_len) < 0) {
- return NULL;
+ return nullptr;
}
FileDescriptorProto file_proto;
if (!file_proto.ParseFromArray(message_type, message_len)) {
PyErr_SetString(PyExc_TypeError, "Couldn't parse file content!");
- return NULL;
+ return nullptr;
}
// If the file was already part of a C++ library, all its descriptors are in
// the underlying pool. No need to do anything else.
- const FileDescriptor* generated_file = NULL;
+ const FileDescriptor* generated_file = nullptr;
if (self->underlay) {
generated_file = self->underlay->FindFileByName(file_proto.name());
}
- if (generated_file != NULL) {
+ if (generated_file != nullptr) {
return PyFileDescriptor_FromDescriptorWithSerializedPb(
generated_file, serialized_pb);
}
@@ -621,11 +623,11 @@ static PyObject* AddSerializedFile(PyObject* pself, PyObject* serialized_pb) {
// Pool is mutable, we can remove the "const".
const_cast<DescriptorPool*>(self->pool)
->BuildFileCollectingErrors(file_proto, &error_collector);
- if (descriptor == NULL) {
+ if (descriptor == nullptr) {
PyErr_Format(PyExc_TypeError,
"Couldn't build proto file into descriptor pool!\n%s",
error_collector.error_message.c_str());
- return NULL;
+ return nullptr;
}
@@ -635,105 +637,109 @@ static PyObject* AddSerializedFile(PyObject* pself, PyObject* serialized_pb) {
static PyObject* Add(PyObject* self, PyObject* file_descriptor_proto) {
ScopedPyObjectPtr serialized_pb(
- PyObject_CallMethod(file_descriptor_proto, "SerializeToString", NULL));
- if (serialized_pb == NULL) {
- return NULL;
+ PyObject_CallMethod(file_descriptor_proto, "SerializeToString", nullptr));
+ if (serialized_pb == nullptr) {
+ return nullptr;
}
return AddSerializedFile(self, serialized_pb.get());
}
static PyMethodDef Methods[] = {
- { "Add", Add, METH_O,
- "Adds the FileDescriptorProto and its types to this pool." },
- { "AddSerializedFile", AddSerializedFile, METH_O,
- "Adds a serialized FileDescriptorProto to this pool." },
-
- // TODO(amauryfa): Understand why the Python implementation differs from
- // this one, ask users to use another API and deprecate these functions.
- { "AddFileDescriptor", AddFileDescriptor, METH_O,
- "No-op. Add() must have been called before." },
- { "AddDescriptor", AddDescriptor, METH_O,
- "No-op. Add() must have been called before." },
- { "AddEnumDescriptor", AddEnumDescriptor, METH_O,
- "No-op. Add() must have been called before." },
- { "AddExtensionDescriptor", AddExtensionDescriptor, METH_O,
- "No-op. Add() must have been called before." },
- { "AddServiceDescriptor", AddServiceDescriptor, METH_O,
- "No-op. Add() must have been called before." },
-
- { "FindFileByName", FindFileByName, METH_O,
- "Searches for a file descriptor by its .proto name." },
- { "FindMessageTypeByName", FindMessageByName, METH_O,
- "Searches for a message descriptor by full name." },
- { "FindFieldByName", FindFieldByNameMethod, METH_O,
- "Searches for a field descriptor by full name." },
- { "FindExtensionByName", FindExtensionByNameMethod, METH_O,
- "Searches for extension descriptor by full name." },
- { "FindEnumTypeByName", FindEnumTypeByNameMethod, METH_O,
- "Searches for enum type descriptor by full name." },
- { "FindOneofByName", FindOneofByNameMethod, METH_O,
- "Searches for oneof descriptor by full name." },
- { "FindServiceByName", FindServiceByName, METH_O,
- "Searches for service descriptor by full name." },
- { "FindMethodByName", FindMethodByName, METH_O,
- "Searches for method descriptor by full name." },
-
- { "FindFileContainingSymbol", FindFileContainingSymbol, METH_O,
- "Gets the FileDescriptor containing the specified symbol." },
- { "FindExtensionByNumber", FindExtensionByNumber, METH_VARARGS,
- "Gets the extension descriptor for the given number." },
- { "FindAllExtensions", FindAllExtensions, METH_O,
- "Gets all known extensions of the given message descriptor." },
- {NULL}
+ {"Add", Add, METH_O,
+ "Adds the FileDescriptorProto and its types to this pool."},
+ {"AddSerializedFile", AddSerializedFile, METH_O,
+ "Adds a serialized FileDescriptorProto to this pool."},
+
+ // TODO(amauryfa): Understand why the Python implementation differs from
+ // this one, ask users to use another API and deprecate these functions.
+ {"AddFileDescriptor", AddFileDescriptor, METH_O,
+ "No-op. Add() must have been called before."},
+ {"AddDescriptor", AddDescriptor, METH_O,
+ "No-op. Add() must have been called before."},
+ {"AddEnumDescriptor", AddEnumDescriptor, METH_O,
+ "No-op. Add() must have been called before."},
+ {"AddExtensionDescriptor", AddExtensionDescriptor, METH_O,
+ "No-op. Add() must have been called before."},
+ {"AddServiceDescriptor", AddServiceDescriptor, METH_O,
+ "No-op. Add() must have been called before."},
+
+ {"FindFileByName", FindFileByName, METH_O,
+ "Searches for a file descriptor by its .proto name."},
+ {"FindMessageTypeByName", FindMessageByName, METH_O,
+ "Searches for a message descriptor by full name."},
+ {"FindFieldByName", FindFieldByNameMethod, METH_O,
+ "Searches for a field descriptor by full name."},
+ {"FindExtensionByName", FindExtensionByNameMethod, METH_O,
+ "Searches for extension descriptor by full name."},
+ {"FindEnumTypeByName", FindEnumTypeByNameMethod, METH_O,
+ "Searches for enum type descriptor by full name."},
+ {"FindOneofByName", FindOneofByNameMethod, METH_O,
+ "Searches for oneof descriptor by full name."},
+ {"FindServiceByName", FindServiceByName, METH_O,
+ "Searches for service descriptor by full name."},
+ {"FindMethodByName", FindMethodByName, METH_O,
+ "Searches for method descriptor by full name."},
+
+ {"FindFileContainingSymbol", FindFileContainingSymbol, METH_O,
+ "Gets the FileDescriptor containing the specified symbol."},
+ {"FindExtensionByNumber", FindExtensionByNumber, METH_VARARGS,
+ "Gets the extension descriptor for the given number."},
+ {"FindAllExtensions", FindAllExtensions, METH_O,
+ "Gets all known extensions of the given message descriptor."},
+ {nullptr},
};
} // namespace cdescriptor_pool
PyTypeObject PyDescriptorPool_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
- ".DescriptorPool", // tp_name
- sizeof(PyDescriptorPool), // tp_basicsize
- 0, // tp_itemsize
- cdescriptor_pool::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
+ ".DescriptorPool", // tp_name
+ sizeof(PyDescriptorPool), // tp_basicsize
+ 0, // tp_itemsize
+ cdescriptor_pool::Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
"A Descriptor Pool", // tp_doc
cdescriptor_pool::GcTraverse, // tp_traverse
cdescriptor_pool::GcClear, // tp_clear
- 0, // tp_richcompare
+ nullptr, // tp_richcompare
0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
cdescriptor_pool::Methods, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
+ nullptr, // tp_init
+ nullptr, // tp_alloc
cdescriptor_pool::New, // tp_new
PyObject_GC_Del, // tp_free
};
// This is the DescriptorPool which contains all the definitions from the
// generated _pb2.py modules.
-static PyDescriptorPool* python_generated_pool = NULL;
+static PyDescriptorPool* python_generated_pool = nullptr;
bool InitDescriptorPool() {
if (PyType_Ready(&PyDescriptorPool_Type) < 0)
@@ -746,7 +752,7 @@ bool InitDescriptorPool() {
new std::unordered_map<const DescriptorPool*, PyDescriptorPool*>;
python_generated_pool = cdescriptor_pool::PyDescriptorPool_NewWithUnderlay(
DescriptorPool::generated_pool());
- if (python_generated_pool == NULL) {
+ if (python_generated_pool == nullptr) {
delete descriptor_pool_map;
return false;
}
@@ -777,7 +783,7 @@ PyDescriptorPool* GetDescriptorPool_FromPool(const DescriptorPool* pool) {
descriptor_pool_map->find(pool);
if (it == descriptor_pool_map->end()) {
PyErr_SetString(PyExc_KeyError, "Unknown descriptor pool");
- return NULL;
+ return nullptr;
}
return it->second;
}
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h
index 48658d3e88..5d3c3a95cc 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <unordered_map>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc
index b36c723266..692029f682 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc
@@ -49,12 +49,13 @@
#include <google/protobuf/pyext/repeated_scalar_container.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#define PyString_AsStringAndSize(ob, charpp, sizep) \
- (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>( \
- PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
- ? -1 \
- : 0) \
- : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob) \
+ ? ((*(charpp) = const_cast<char*>( \
+ PyUnicode_AsUTF8AndSize(ob, (sizep)))) == nullptr \
+ ? -1 \
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
namespace google {
namespace protobuf {
@@ -130,11 +131,11 @@ static void DeallocExtensionIterator(PyObject* _self) {
PyObject* subscript(ExtensionDict* self, PyObject* key) {
const FieldDescriptor* descriptor = cmessage::GetExtensionDescriptor(key);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
if (!CheckFieldBelongsToMessage(descriptor, self->parent->message)) {
- return NULL;
+ return nullptr;
}
if (descriptor->label() != FieldDescriptor::LABEL_REPEATED &&
@@ -154,8 +155,8 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) {
// TODO(plabatut): consider building the class on the fly!
ContainerBase* sub_message = cmessage::InternalGetSubMessage(
self->parent, descriptor);
- if (sub_message == NULL) {
- return NULL;
+ if (sub_message == nullptr) {
+ return nullptr;
}
(*self->parent->composite_fields)[descriptor] = sub_message;
return sub_message->AsPyObject();
@@ -178,33 +179,33 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) {
descriptor->message_type());
ScopedPyObjectPtr message_class_handler(
reinterpret_cast<PyObject*>(message_class));
- if (message_class == NULL) {
- return NULL;
+ if (message_class == nullptr) {
+ return nullptr;
}
ContainerBase* py_container = repeated_composite_container::NewContainer(
self->parent, descriptor, message_class);
- if (py_container == NULL) {
- return NULL;
+ if (py_container == nullptr) {
+ return nullptr;
}
(*self->parent->composite_fields)[descriptor] = py_container;
return py_container->AsPyObject();
} else {
ContainerBase* py_container = repeated_scalar_container::NewContainer(
self->parent, descriptor);
- if (py_container == NULL) {
- return NULL;
+ if (py_container == nullptr) {
+ return nullptr;
}
(*self->parent->composite_fields)[descriptor] = py_container;
return py_container->AsPyObject();
}
}
PyErr_SetString(PyExc_ValueError, "control reached unexpected line");
- return NULL;
+ return nullptr;
}
int ass_subscript(ExtensionDict* self, PyObject* key, PyObject* value) {
const FieldDescriptor* descriptor = cmessage::GetExtensionDescriptor(key);
- if (descriptor == NULL) {
+ if (descriptor == nullptr) {
return -1;
}
if (!CheckFieldBelongsToMessage(descriptor, self->parent->message)) {
@@ -232,13 +233,13 @@ PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) {
char* name;
Py_ssize_t name_size;
if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
- return NULL;
+ return nullptr;
}
PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool;
const FieldDescriptor* message_extension =
pool->pool->FindExtensionByName(StringParam(name, name_size));
- if (message_extension == NULL) {
+ if (message_extension == nullptr) {
// Is is the name of a message set extension?
const Descriptor* message_descriptor =
pool->pool->FindMessageTypeByName(StringParam(name, name_size));
@@ -252,7 +253,7 @@ PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) {
}
}
}
- if (message_extension == NULL) {
+ if (message_extension == nullptr) {
Py_RETURN_NONE;
}
@@ -262,13 +263,13 @@ PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) {
PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* arg) {
int64_t number = PyLong_AsLong(arg);
if (number == -1 && PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool;
const FieldDescriptor* message_extension = pool->pool->FindExtensionByNumber(
self->parent->message->GetDescriptor(), number);
- if (message_extension == NULL) {
+ if (message_extension == nullptr) {
Py_RETURN_NONE;
}
@@ -307,8 +308,8 @@ static int Contains(PyObject* _self, PyObject* key) {
ExtensionDict* NewExtensionDict(CMessage *parent) {
ExtensionDict* self = reinterpret_cast<ExtensionDict*>(
PyType_GenericAlloc(&ExtensionDict_Type, 0));
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
Py_INCREF(parent);
@@ -340,12 +341,12 @@ static PyObject* RichCompare(ExtensionDict* self, PyObject* other, int opid) {
}
static PySequenceMethods SeqMethods = {
(lenfunc)len, // sq_length
- 0, // sq_concat
- 0, // sq_repeat
- 0, // sq_item
- 0, // sq_slice
- 0, // sq_ass_item
- 0, // sq_ass_slice
+ nullptr, // sq_concat
+ nullptr, // sq_repeat
+ nullptr, // sq_item
+ nullptr, // sq_slice
+ nullptr, // sq_ass_item
+ nullptr, // sq_ass_slice
(objobjproc)Contains, // sq_contains
};
@@ -360,48 +361,52 @@ static PyMethodDef Methods[] = {
EDMETHOD(_FindExtensionByName, METH_O, "Finds an extension by name."),
EDMETHOD(_FindExtensionByNumber, METH_O,
"Finds an extension by field number."),
- {NULL, NULL},
+ {nullptr, nullptr},
};
} // namespace extension_dict
PyTypeObject ExtensionDict_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0) //
- FULL_MODULE_NAME ".ExtensionDict", // tp_name
- sizeof(ExtensionDict), // tp_basicsize
- 0, // tp_itemsize
- (destructor)extension_dict::dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) //
+ FULL_MODULE_NAME ".ExtensionDict", // tp_name
+ sizeof(ExtensionDict), // tp_basicsize
+ 0, // tp_itemsize
+ (destructor)extension_dict::dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
&extension_dict::SeqMethods, // tp_as_sequence
&extension_dict::MpMethods, // tp_as_mapping
PyObject_HashNotImplemented, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
Py_TPFLAGS_DEFAULT, // tp_flags
"An extension dict", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
(richcmpfunc)extension_dict::RichCompare, // tp_richcompare
0, // tp_weaklistoffset
extension_dict::GetIter, // tp_iter
- 0, // tp_iternext
+ nullptr, // tp_iternext
extension_dict::Methods, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
0, // tp_dictoffset
- 0, // tp_init
+ nullptr, // tp_init
};
PyObject* IterNext(PyObject* _self) {
@@ -438,37 +443,41 @@ PyTypeObject ExtensionIterator_Type = {
sizeof(extension_dict::ExtensionIterator), // tp_basicsize
0, // tp_itemsize
extension_dict::DeallocExtensionIterator, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A scalar map iterator", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- PyObject_SelfIter, // tp_iter
- IterNext, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A scalar map iterator", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ PyObject_SelfIter, // tp_iter
+ IterNext, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
};
} // namespace python
} // namespace protobuf
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h b/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h
index c9da443161..a0581941bd 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h
@@ -34,6 +34,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <memory>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc
index 5eab3ef2bc..0d3b0b9607 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc
@@ -47,7 +47,7 @@ static PyObject* Repr(PyMessageFieldProperty* self) {
static PyObject* DescrGet(PyMessageFieldProperty* self, PyObject* obj,
PyObject* type) {
- if (obj == NULL) {
+ if (obj == nullptr) {
Py_INCREF(self);
return reinterpret_cast<PyObject*>(self);
}
@@ -57,7 +57,7 @@ static PyObject* DescrGet(PyMessageFieldProperty* self, PyObject* obj,
static int DescrSet(PyMessageFieldProperty* self, PyObject* obj,
PyObject* value) {
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_AttributeError, "Cannot delete field attribute");
return -1;
}
@@ -75,50 +75,55 @@ static PyObject* GetDoc(PyMessageFieldProperty* self, void* closure) {
}
static PyGetSetDef Getters[] = {
- {"DESCRIPTOR", (getter)GetDescriptor, NULL, "Field descriptor"},
- {"__doc__", (getter)GetDoc, NULL, NULL},
- {NULL}};
+ {"DESCRIPTOR", (getter)GetDescriptor, nullptr, "Field descriptor"},
+ {"__doc__", (getter)GetDoc, nullptr, nullptr},
+ {nullptr},
+};
} // namespace field
static PyTypeObject _CFieldProperty_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0) // head
- FULL_MODULE_NAME ".FieldProperty", // tp_name
- sizeof(PyMessageFieldProperty), // tp_basicsize
- 0, // tp_itemsize
- 0, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- (reprfunc)field::Repr, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "Field property of a Message", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
- field::Getters, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- (descrgetfunc)field::DescrGet, // tp_descr_get
- (descrsetfunc)field::DescrSet, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
- 0, // tp_new
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) // head
+ FULL_MODULE_NAME ".FieldProperty", // tp_name
+ sizeof(PyMessageFieldProperty), // tp_basicsize
+ 0, // tp_itemsize
+ nullptr, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ (reprfunc)field::Repr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "Field property of a Message", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
+ field::Getters, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ (descrgetfunc)field::DescrGet, // tp_descr_get
+ (descrsetfunc)field::DescrSet, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
+ nullptr, // tp_alloc
+ nullptr, // tp_new
};
PyTypeObject* CFieldProperty_Type = &_CFieldProperty_Type;
@@ -126,8 +131,8 @@ PyObject* NewFieldProperty(const FieldDescriptor* field_descriptor) {
// Create a new descriptor object
PyMessageFieldProperty* property =
PyObject_New(PyMessageFieldProperty, CFieldProperty_Type);
- if (property == NULL) {
- return NULL;
+ if (property == nullptr) {
+ return nullptr;
}
property->field_descriptor = field_descriptor;
return reinterpret_cast<PyObject*>(property);
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/field.h b/contrib/python/protobuf/py3/google/protobuf/pyext/field.h
index 7b4660cab5..f9f94c4983 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/field.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/field.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
namespace google {
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc
index 94a5e2dad9..2c22e022d0 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc
@@ -187,7 +187,7 @@ static PyObject* MapKeyToPython(MapContainer* self, const MapKey& key) {
PyErr_Format(
PyExc_SystemError, "Couldn't convert type %d to value",
field_descriptor->cpp_type());
- return NULL;
+ return nullptr;
}
}
@@ -219,7 +219,7 @@ PyObject* MapValueRefToPython(MapContainer* self, const MapValueRef& value) {
PyErr_Format(
PyExc_SystemError, "Couldn't convert type %d to value",
field_descriptor->cpp_type());
- return NULL;
+ return nullptr;
}
}
@@ -283,7 +283,7 @@ static bool PythonToMapValueRef(MapContainer* self, PyObject* obj,
const EnumDescriptor* enum_descriptor = field_descriptor->enum_type();
const EnumValueDescriptor* enum_value =
enum_descriptor->FindValueByNumber(value);
- if (enum_value != NULL) {
+ if (enum_value != nullptr) {
value_ref->SetEnumValue(value);
return true;
} else {
@@ -362,7 +362,7 @@ PyObject* MapReflectionFriend::Contains(PyObject* _self, PyObject* key) {
MapKey map_key;
if (!PythonToMapKey(self, key, &map_key)) {
- return NULL;
+ return nullptr;
}
if (reflection->ContainsMapKey(*message, self->parent_field_descriptor,
@@ -378,14 +378,14 @@ PyObject* MapReflectionFriend::Contains(PyObject* _self, PyObject* key) {
MapContainer* NewScalarMapContainer(
CMessage* parent, const google::protobuf::FieldDescriptor* parent_field_descriptor) {
if (!CheckFieldBelongsToMessage(parent_field_descriptor, parent->message)) {
- return NULL;
+ return nullptr;
}
PyObject* obj(PyType_GenericAlloc(ScalarMapContainer_Type, 0));
- if (obj == NULL) {
+ if (obj == nullptr) {
PyErr_Format(PyExc_RuntimeError,
"Could not allocate new container.");
- return NULL;
+ return nullptr;
}
MapContainer* self = GetMap(obj);
@@ -408,7 +408,7 @@ PyObject* MapReflectionFriend::ScalarMapGetItem(PyObject* _self,
MapValueRef value;
if (!PythonToMapKey(self, key, &map_key)) {
- return NULL;
+ return nullptr;
}
if (reflection->InsertOrLookupMapValue(message, self->parent_field_descriptor,
@@ -432,12 +432,12 @@ int MapReflectionFriend::ScalarMapSetItem(PyObject* _self, PyObject* key,
return -1;
}
- self->version++;
-
if (v) {
// Set item to v.
- reflection->InsertOrLookupMapValue(message, self->parent_field_descriptor,
- map_key, &value);
+ if (reflection->InsertOrLookupMapValue(
+ message, self->parent_field_descriptor, map_key, &value)) {
+ self->version++;
+ }
if (!PythonToMapValueRef(self, v, reflection->SupportsUnknownEnumValues(),
&value)) {
@@ -448,6 +448,7 @@ int MapReflectionFriend::ScalarMapSetItem(PyObject* _self, PyObject* key,
// Delete key from map.
if (reflection->DeleteMapValue(message, self->parent_field_descriptor,
map_key)) {
+ self->version++;
return 0;
} else {
PyErr_Format(PyExc_KeyError, "Key not present in map");
@@ -460,22 +461,22 @@ static PyObject* ScalarMapGet(PyObject* self, PyObject* args,
PyObject* kwargs) {
static const char* kwlist[] = {"key", "default", nullptr};
PyObject* key;
- PyObject* default_value = NULL;
+ PyObject* default_value = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O",
const_cast<char**>(kwlist), &key,
&default_value)) {
- return NULL;
+ return nullptr;
}
ScopedPyObjectPtr is_present(MapReflectionFriend::Contains(self, key));
- if (is_present.get() == NULL) {
- return NULL;
+ if (is_present.get() == nullptr) {
+ return nullptr;
}
if (PyObject_IsTrue(is_present.get())) {
return MapReflectionFriend::ScalarMapGetItem(self, key);
} else {
- if (default_value != NULL) {
+ if (default_value != nullptr) {
Py_INCREF(default_value);
return default_value;
} else {
@@ -486,8 +487,8 @@ static PyObject* ScalarMapGet(PyObject* self, PyObject* args,
PyObject* MapReflectionFriend::ScalarMapToStr(PyObject* _self) {
ScopedPyObjectPtr dict(PyDict_New());
- if (dict == NULL) {
- return NULL;
+ if (dict == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr key;
ScopedPyObjectPtr value;
@@ -500,15 +501,15 @@ PyObject* MapReflectionFriend::ScalarMapToStr(PyObject* _self) {
it != reflection->MapEnd(message, self->parent_field_descriptor);
++it) {
key.reset(MapKeyToPython(self, it.GetKey()));
- if (key == NULL) {
- return NULL;
+ if (key == nullptr) {
+ return nullptr;
}
value.reset(MapValueRefToPython(self, it.GetValueRef()));
- if (value == NULL) {
- return NULL;
+ if (value == nullptr) {
+ return nullptr;
}
if (PyDict_SetItem(dict.get(), key.get(), value.get()) < 0) {
- return NULL;
+ return nullptr;
}
}
return PyObject_Repr(dict.get());
@@ -545,7 +546,7 @@ static PyMethodDef ScalarMapMethods[] = {
{ "__reduce__", (PyCFunction)Reduce, METH_NOARGS,
"Outputs picklable representation of the repeated field." },
*/
- {NULL, NULL},
+ {nullptr, nullptr},
};
PyTypeObject* ScalarMapContainer_Type;
@@ -557,7 +558,7 @@ static PyType_Slot ScalarMapContainer_Type_slots[] = {
{Py_tp_methods, (void*)ScalarMapMethods},
{Py_tp_iter, (void*)MapReflectionFriend::GetIterator},
{Py_tp_repr, (void*)MapReflectionFriend::ScalarMapToStr},
- {0, 0},
+ {0, nullptr},
};
PyType_Spec ScalarMapContainer_Type_spec = {
@@ -582,13 +583,13 @@ MessageMapContainer* NewMessageMapContainer(
CMessage* parent, const google::protobuf::FieldDescriptor* parent_field_descriptor,
CMessageClass* message_class) {
if (!CheckFieldBelongsToMessage(parent_field_descriptor, parent->message)) {
- return NULL;
+ return nullptr;
}
PyObject* obj = PyType_GenericAlloc(MessageMapContainer_Type, 0);
- if (obj == NULL) {
+ if (obj == nullptr) {
PyErr_SetString(PyExc_RuntimeError, "Could not allocate new container.");
- return NULL;
+ return nullptr;
}
MessageMapContainer* self = GetMessageMap(obj);
@@ -663,7 +664,7 @@ PyObject* MapReflectionFriend::MessageMapGetItem(PyObject* _self,
MapValueRef value;
if (!PythonToMapKey(self, key, &map_key)) {
- return NULL;
+ return nullptr;
}
if (reflection->InsertOrLookupMapValue(message, self->parent_field_descriptor,
@@ -676,8 +677,8 @@ PyObject* MapReflectionFriend::MessageMapGetItem(PyObject* _self,
PyObject* MapReflectionFriend::MessageMapToStr(PyObject* _self) {
ScopedPyObjectPtr dict(PyDict_New());
- if (dict == NULL) {
- return NULL;
+ if (dict == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr key;
ScopedPyObjectPtr value;
@@ -690,15 +691,15 @@ PyObject* MapReflectionFriend::MessageMapToStr(PyObject* _self) {
it != reflection->MapEnd(message, self->parent_field_descriptor);
++it) {
key.reset(MapKeyToPython(self, it.GetKey()));
- if (key == NULL) {
- return NULL;
+ if (key == nullptr) {
+ return nullptr;
}
value.reset(GetCMessage(self, it.MutableValueRef()->MutableMessageValue()));
- if (value == NULL) {
- return NULL;
+ if (value == nullptr) {
+ return nullptr;
}
if (PyDict_SetItem(dict.get(), key.get(), value.get()) < 0) {
- return NULL;
+ return nullptr;
}
}
return PyObject_Repr(dict.get());
@@ -707,22 +708,22 @@ PyObject* MapReflectionFriend::MessageMapToStr(PyObject* _self) {
PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) {
static const char* kwlist[] = {"key", "default", nullptr};
PyObject* key;
- PyObject* default_value = NULL;
+ PyObject* default_value = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O",
const_cast<char**>(kwlist), &key,
&default_value)) {
- return NULL;
+ return nullptr;
}
ScopedPyObjectPtr is_present(MapReflectionFriend::Contains(self, key));
- if (is_present.get() == NULL) {
- return NULL;
+ if (is_present.get() == nullptr) {
+ return nullptr;
}
if (PyObject_IsTrue(is_present.get())) {
return MapReflectionFriend::MessageMapGetItem(self, key);
} else {
- if (default_value != NULL) {
+ if (default_value != nullptr) {
Py_INCREF(default_value);
return default_value;
} else {
@@ -765,7 +766,7 @@ static PyMethodDef MessageMapMethods[] = {
{ "__reduce__", (PyCFunction)Reduce, METH_NOARGS,
"Outputs picklable representation of the repeated field." },
*/
- {NULL, NULL},
+ {nullptr, nullptr},
};
PyTypeObject* MessageMapContainer_Type;
@@ -777,7 +778,7 @@ static PyType_Slot MessageMapContainer_Type_slots[] = {
{Py_tp_methods, (void*)MessageMapMethods},
{Py_tp_iter, (void*)MapReflectionFriend::GetIterator},
{Py_tp_repr, (void*)MapReflectionFriend::MessageMapToStr},
- {0, 0}};
+ {0, nullptr}};
PyType_Spec MessageMapContainer_Type_spec = {
FULL_MODULE_NAME ".MessageMapContainer", sizeof(MessageMapContainer), 0,
@@ -793,7 +794,7 @@ PyObject* MapReflectionFriend::GetIterator(PyObject *_self) {
MapContainer* self = GetMap(_self);
ScopedPyObjectPtr obj(PyType_GenericAlloc(&MapIterator_Type, 0));
- if (obj == NULL) {
+ if (obj == nullptr) {
return PyErr_Format(PyExc_KeyError, "Could not allocate iterator");
}
@@ -830,8 +831,8 @@ PyObject* MapReflectionFriend::IterNext(PyObject* _self) {
"Map cleared during iteration.");
}
- if (self->iter.get() == NULL) {
- return NULL;
+ if (self->iter.get() == nullptr) {
+ return nullptr;
}
Message* message = self->container->GetMutableMessage();
@@ -839,7 +840,7 @@ PyObject* MapReflectionFriend::IterNext(PyObject* _self) {
if (*self->iter ==
reflection->MapEnd(message, self->container->parent_field_descriptor)) {
- return NULL;
+ return nullptr;
}
PyObject* ret = MapKeyToPython(self->container, self->iter->GetKey());
@@ -858,60 +859,64 @@ static void DeallocMapIterator(PyObject* _self) {
}
PyTypeObject MapIterator_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".MapIterator", // tp_name
- sizeof(MapIterator), // tp_basicsize
- 0, // tp_itemsize
- DeallocMapIterator, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "A scalar map iterator", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- PyObject_SelfIter, // tp_iter
- MapReflectionFriend::IterNext, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".MapIterator", // tp_name
+ sizeof(MapIterator), // tp_basicsize
+ 0, // tp_itemsize
+ DeallocMapIterator, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "A scalar map iterator", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ PyObject_SelfIter, // tp_iter
+ MapReflectionFriend::IterNext, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
};
bool InitMapContainers() {
// ScalarMapContainer_Type derives from our MutableMapping type.
ScopedPyObjectPtr abc(PyImport_ImportModule("collections.abc"));
- if (abc == NULL) {
+ if (abc == nullptr) {
return false;
}
ScopedPyObjectPtr mutable_mapping(
PyObject_GetAttrString(abc.get(), "MutableMapping"));
- if (mutable_mapping == NULL) {
+ if (mutable_mapping == nullptr) {
return false;
}
Py_INCREF(mutable_mapping.get());
ScopedPyObjectPtr bases(PyTuple_Pack(1, mutable_mapping.get()));
- if (bases == NULL) {
+ if (bases == nullptr) {
return false;
}
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h b/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h
index 842602e79f..e14136efab 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <cstdint>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc
index 3254be8a21..d416925f53 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc
@@ -79,12 +79,13 @@
#define PyString_AsString(ob) \
(PyUnicode_Check(ob) ? PyUnicode_AsUTF8(ob) : PyBytes_AsString(ob))
-#define PyString_AsStringAndSize(ob, charpp, sizep) \
- (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>( \
- PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
- ? -1 \
- : 0) \
- : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob) \
+ ? ((*(charpp) = const_cast<char*>( \
+ PyUnicode_AsUTF8AndSize(ob, (sizep)))) == nullptr \
+ ? -1 \
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
namespace google {
namespace protobuf {
@@ -108,7 +109,7 @@ static PyObject* kDESCRIPTOR;
PyObject* EnumTypeWrapper_class;
static PyObject* PythonMessage_class;
static PyObject* kEmptyWeakref;
-static PyObject* WKT_classes = NULL;
+static PyObject* WKT_classes = nullptr;
namespace message_meta {
@@ -125,7 +126,7 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
for (int i = 0; i < descriptor->field_count(); ++i) {
const FieldDescriptor* field_descriptor = descriptor->field(i);
ScopedPyObjectPtr property(NewFieldProperty(field_descriptor));
- if (property == NULL) {
+ if (property == nullptr) {
return -1;
}
if (PyObject_SetAttrString(cls, field_descriptor->name().c_str(),
@@ -139,13 +140,13 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
const EnumDescriptor* enum_descriptor = descriptor->enum_type(i);
ScopedPyObjectPtr enum_type(
PyEnumDescriptor_FromDescriptor(enum_descriptor));
- if (enum_type == NULL) {
+ if (enum_type == nullptr) {
return -1;
}
// Add wrapped enum type to message class.
ScopedPyObjectPtr wrapped(PyObject_CallFunctionObjArgs(
- EnumTypeWrapper_class, enum_type.get(), NULL));
- if (wrapped == NULL) {
+ EnumTypeWrapper_class, enum_type.get(), nullptr));
+ if (wrapped == nullptr) {
return -1;
}
if (PyObject_SetAttrString(
@@ -159,7 +160,7 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
enum_descriptor->value(j);
ScopedPyObjectPtr value_number(
PyLong_FromLong(enum_value_descriptor->number()));
- if (value_number == NULL) {
+ if (value_number == nullptr) {
return -1;
}
if (PyObject_SetAttrString(cls, enum_value_descriptor->name().c_str(),
@@ -177,7 +178,7 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
for (int i = 0; i < descriptor->extension_count(); ++i) {
const google::protobuf::FieldDescriptor* field = descriptor->extension(i);
ScopedPyObjectPtr extension_field(PyFieldDescriptor_FromDescriptor(field));
- if (extension_field == NULL) {
+ if (extension_field == nullptr) {
return -1;
}
@@ -192,7 +193,7 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
}
static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
- static const char* kwlist[] = {"name", "bases", "dict", 0};
+ static const char* kwlist[] = {"name", "bases", "dict", nullptr};
PyObject *bases, *dict;
const char* name;
@@ -200,7 +201,7 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
if (!PyArg_ParseTupleAndKeywords(
args, kwargs, "sO!O!:type", const_cast<char**>(kwlist), &name,
&PyTuple_Type, &bases, &PyDict_Type, &dict)) {
- return NULL;
+ return nullptr;
}
// Check bases: only (), or (message.Message,) are allowed
@@ -209,7 +210,7 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
PyTuple_GET_ITEM(bases, 0) == PythonMessage_class))) {
PyErr_SetString(PyExc_TypeError,
"A Message class can only inherit from Message");
- return NULL;
+ return nullptr;
}
// Check dict['DESCRIPTOR']
@@ -232,25 +233,25 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
// Messages have no __dict__
ScopedPyObjectPtr slots(PyTuple_New(0));
if (PyDict_SetItemString(dict, "__slots__", slots.get()) < 0) {
- return NULL;
+ return nullptr;
}
// Build the arguments to the base metaclass.
// We change the __bases__ classes.
ScopedPyObjectPtr new_args;
- if (WKT_classes == NULL) {
+ if (WKT_classes == nullptr) {
ScopedPyObjectPtr well_known_types(PyImport_ImportModule(
"google.protobuf.internal.well_known_types"));
- GOOGLE_DCHECK(well_known_types != NULL);
+ GOOGLE_DCHECK(well_known_types != nullptr);
WKT_classes = PyObject_GetAttrString(well_known_types.get(), "WKTBASES");
- GOOGLE_DCHECK(WKT_classes != NULL);
+ GOOGLE_DCHECK(WKT_classes != nullptr);
}
PyObject* well_known_class = PyDict_GetItemString(
WKT_classes, message_descriptor->full_name().c_str());
- if (well_known_class == NULL) {
+ if (well_known_class == nullptr) {
new_args.reset(Py_BuildValue("s(OO)O", name, CMessage_Type,
PythonMessage_class, dict));
} else {
@@ -258,21 +259,21 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
PythonMessage_class, well_known_class, dict));
}
- if (new_args == NULL) {
- return NULL;
+ if (new_args == nullptr) {
+ return nullptr;
}
// Call the base metaclass.
- ScopedPyObjectPtr result(PyType_Type.tp_new(type, new_args.get(), NULL));
- if (result == NULL) {
- return NULL;
+ ScopedPyObjectPtr result(PyType_Type.tp_new(type, new_args.get(), nullptr));
+ if (result == nullptr) {
+ return nullptr;
}
CMessageClass* newtype = reinterpret_cast<CMessageClass*>(result.get());
// Cache the descriptor, both as Python object and as C++ pointer.
const Descriptor* descriptor =
PyMessageDescriptor_AsDescriptor(py_descriptor);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
Py_INCREF(py_descriptor);
newtype->py_message_descriptor = py_descriptor;
@@ -281,8 +282,8 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
// use the MessageFactory optionally passed in the class dict.
PyDescriptorPool* py_descriptor_pool =
GetDescriptorPool_FromPool(descriptor->file()->pool());
- if (py_descriptor_pool == NULL) {
- return NULL;
+ if (py_descriptor_pool == nullptr) {
+ return nullptr;
}
newtype->py_message_factory = py_descriptor_pool->py_message_factory;
Py_INCREF(newtype->py_message_factory);
@@ -292,12 +293,12 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
// MessageFactory is fully implemented in C++.
if (message_factory::RegisterMessageClass(newtype->py_message_factory,
descriptor, newtype) < 0) {
- return NULL;
+ return nullptr;
}
// Continue with type initialization: add other descriptors, enum values...
if (AddDescriptors(result.get(), descriptor) < 0) {
- return NULL;
+ return nullptr;
}
return result.release();
}
@@ -325,11 +326,11 @@ static int GcClear(PyObject* pself) {
// The _extensions_by_name dictionary is built on every access.
// TODO(amauryfa): Migrate all users to pool.FindAllExtensions()
static PyObject* GetExtensionsByName(CMessageClass *self, void *closure) {
- if (self->message_descriptor == NULL) {
+ if (self->message_descriptor == nullptr) {
// This is the base Message object, simply raise AttributeError.
PyErr_SetString(PyExc_AttributeError,
"Base Message class has no DESCRIPTOR");
- return NULL;
+ return nullptr;
}
const PyDescriptorPool* pool = self->py_message_factory->pool;
@@ -341,12 +342,12 @@ static PyObject* GetExtensionsByName(CMessageClass *self, void *closure) {
for (int i = 0; i < extensions.size(); i++) {
ScopedPyObjectPtr extension(
PyFieldDescriptor_FromDescriptor(extensions[i]));
- if (extension == NULL) {
- return NULL;
+ if (extension == nullptr) {
+ return nullptr;
}
if (PyDict_SetItemString(result.get(), extensions[i]->full_name().c_str(),
extension.get()) < 0) {
- return NULL;
+ return nullptr;
}
}
return result.release();
@@ -355,11 +356,11 @@ static PyObject* GetExtensionsByName(CMessageClass *self, void *closure) {
// The _extensions_by_number dictionary is built on every access.
// TODO(amauryfa): Migrate all users to pool.FindExtensionByNumber()
static PyObject* GetExtensionsByNumber(CMessageClass *self, void *closure) {
- if (self->message_descriptor == NULL) {
+ if (self->message_descriptor == nullptr) {
// This is the base Message object, simply raise AttributeError.
PyErr_SetString(PyExc_AttributeError,
"Base Message class has no DESCRIPTOR");
- return NULL;
+ return nullptr;
}
const PyDescriptorPool* pool = self->py_message_factory->pool;
@@ -371,24 +372,24 @@ static PyObject* GetExtensionsByNumber(CMessageClass *self, void *closure) {
for (int i = 0; i < extensions.size(); i++) {
ScopedPyObjectPtr extension(
PyFieldDescriptor_FromDescriptor(extensions[i]));
- if (extension == NULL) {
- return NULL;
+ if (extension == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr number(PyLong_FromLong(extensions[i]->number()));
- if (number == NULL) {
- return NULL;
+ if (number == nullptr) {
+ return nullptr;
}
if (PyDict_SetItem(result.get(), number.get(), extension.get()) < 0) {
- return NULL;
+ return nullptr;
}
}
return result.release();
}
static PyGetSetDef Getters[] = {
- {"_extensions_by_name", (getter)GetExtensionsByName, NULL},
- {"_extensions_by_number", (getter)GetExtensionsByNumber, NULL},
- {NULL}
+ {"_extensions_by_name", (getter)GetExtensionsByName, nullptr},
+ {"_extensions_by_number", (getter)GetExtensionsByNumber, nullptr},
+ {nullptr},
};
// Compute some class attributes on the fly:
@@ -416,17 +417,17 @@ static PyObject* GetClassAttribute(CMessageClass *self, PyObject* name) {
}
}
PyErr_SetObject(PyExc_AttributeError, name);
- return NULL;
+ return nullptr;
}
static PyObject* GetAttr(CMessageClass* self, PyObject* name) {
PyObject* result = CMessageClass_Type->tp_base->tp_getattro(
reinterpret_cast<PyObject*>(self), name);
- if (result != NULL) {
+ if (result != nullptr) {
return result;
}
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
- return NULL;
+ return nullptr;
}
PyErr_Clear();
@@ -449,42 +450,46 @@ static bool allow_oversize_protos = false;
static PyTypeObject _CMessageClass_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
- ".MessageMeta", // tp_name
- sizeof(CMessageClass), // tp_basicsize
- 0, // tp_itemsize
- message_meta::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
+ ".MessageMeta", // tp_name
+ sizeof(CMessageClass), // tp_basicsize
+ 0, // tp_itemsize
+ message_meta::Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, /* tp_print */
+#else
+ 0, /* tp_vectorcall_offset */
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
(getattrofunc)message_meta::GetAttr, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, // tp_flags
"The metaclass of ProtocolMessages", // tp_doc
message_meta::GcTraverse, // tp_traverse
message_meta::GcClear, // tp_clear
- 0, // tp_richcompare
+ nullptr, // tp_richcompare
0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
message_meta::Getters, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
+ nullptr, // tp_init
+ nullptr, // tp_alloc
message_meta::New, // tp_new
};
PyTypeObject* CMessageClass_Type = &_CMessageClass_Type;
@@ -492,15 +497,15 @@ PyTypeObject* CMessageClass_Type = &_CMessageClass_Type;
static CMessageClass* CheckMessageClass(PyTypeObject* cls) {
if (!PyObject_TypeCheck(cls, CMessageClass_Type)) {
PyErr_Format(PyExc_TypeError, "Class %s is not a Message", cls->tp_name);
- return NULL;
+ return nullptr;
}
return reinterpret_cast<CMessageClass*>(cls);
}
static const Descriptor* GetMessageDescriptor(PyTypeObject* cls) {
CMessageClass* type = CheckMessageClass(cls);
- if (type == NULL) {
- return NULL;
+ if (type == nullptr) {
+ return nullptr;
}
return type->message_descriptor;
}
@@ -567,32 +572,24 @@ template <class T>
bool CheckAndGetInteger(PyObject* arg, T* value) {
// This effectively defines an integer as "an object that can be cast as
// an integer and can be used as an ordinal number".
- // This definition includes everything that implements numbers.Integral
+ // This definition includes everything with a valid __index__() implementation
// and shouldn't cast the net too wide.
- if (PROTOBUF_PREDICT_FALSE(!PyIndex_Check(arg))) {
- FormatTypeError(arg, "int, long");
+ if (!strcmp(Py_TYPE(arg)->tp_name, "numpy.ndarray") ||
+ PROTOBUF_PREDICT_FALSE(!PyIndex_Check(arg))) {
+ FormatTypeError(arg, "int");
+ return false;
+ }
+
+ PyObject* arg_py_int = PyNumber_Index(arg);
+ if (PyErr_Occurred()) {
+ // Propagate existing error.
return false;
}
- // Now we have an integral number so we can safely use PyLong_ functions.
- // We need to treat the signed and unsigned cases differently in case arg is
- // holding a value above the maximum for signed longs.
if (std::numeric_limits<T>::min() == 0) {
// Unsigned case.
- unsigned PY_LONG_LONG ulong_result;
- if (PyLong_Check(arg)) {
- ulong_result = PyLong_AsUnsignedLongLong(arg);
- } else {
- // Unlike PyLong_AsLongLong, PyLong_AsUnsignedLongLong is very
- // picky about the exact type.
- PyObject* casted = PyNumber_Long(arg);
- if (PROTOBUF_PREDICT_FALSE(casted == nullptr)) {
- // Propagate existing error.
- return false;
- }
- ulong_result = PyLong_AsUnsignedLongLong(casted);
- Py_DECREF(casted);
- }
+ unsigned PY_LONG_LONG ulong_result = PyLong_AsUnsignedLongLong(arg_py_int);
+ Py_DECREF(arg_py_int);
if (VerifyIntegerCastAndRange<T, unsigned PY_LONG_LONG>(arg,
ulong_result)) {
*value = static_cast<T>(ulong_result);
@@ -601,30 +598,14 @@ bool CheckAndGetInteger(PyObject* arg, T* value) {
}
} else {
// Signed case.
- PY_LONG_LONG long_result;
- PyNumberMethods *nb;
- if ((nb = arg->ob_type->tp_as_number) != NULL && nb->nb_int != NULL) {
- // PyLong_AsLongLong requires it to be a long or to have an __int__()
- // method.
- long_result = PyLong_AsLongLong(arg);
- } else {
- // Valid subclasses of numbers.Integral should have a __long__() method
- // so fall back to that.
- PyObject* casted = PyNumber_Long(arg);
- if (PROTOBUF_PREDICT_FALSE(casted == nullptr)) {
- // Propagate existing error.
- return false;
- }
- long_result = PyLong_AsLongLong(casted);
- Py_DECREF(casted);
- }
+ Py_DECREF(arg_py_int);
+ PY_LONG_LONG long_result = PyLong_AsLongLong(arg);
if (VerifyIntegerCastAndRange<T, PY_LONG_LONG>(arg, long_result)) {
*value = static_cast<T>(long_result);
} else {
return false;
}
}
-
return true;
}
@@ -637,8 +618,9 @@ template bool CheckAndGetInteger<uint64>(PyObject*, uint64*);
bool CheckAndGetDouble(PyObject* arg, double* value) {
*value = PyFloat_AsDouble(arg);
- if (PROTOBUF_PREDICT_FALSE(*value == -1 && PyErr_Occurred())) {
- FormatTypeError(arg, "int, long, float");
+ if (!strcmp(Py_TYPE(arg)->tp_name, "numpy.ndarray") ||
+ PROTOBUF_PREDICT_FALSE(*value == -1 && PyErr_Occurred())) {
+ FormatTypeError(arg, "int, float");
return false;
}
return true;
@@ -655,8 +637,9 @@ bool CheckAndGetFloat(PyObject* arg, float* value) {
bool CheckAndGetBool(PyObject* arg, bool* value) {
long long_value = PyLong_AsLong(arg); // NOLINT
- if (long_value == -1 && PyErr_Occurred()) {
- FormatTypeError(arg, "int, long, bool");
+ if (!strcmp(Py_TYPE(arg)->tp_name, "numpy.ndarray") ||
+ (long_value == -1 && PyErr_Occurred())) {
+ FormatTypeError(arg, "int, bool");
return false;
}
*value = static_cast<bool>(long_value);
@@ -668,7 +651,7 @@ bool CheckAndGetBool(PyObject* arg, bool* value) {
// valid UTF-8.
bool IsValidUTF8(PyObject* obj) {
if (PyBytes_Check(obj)) {
- PyObject* unicode = PyUnicode_FromEncodedObject(obj, "utf-8", NULL);
+ PyObject* unicode = PyUnicode_FromEncodedObject(obj, "utf-8", nullptr);
// Clear the error indicator; we report our own error when desired.
PyErr_Clear();
@@ -693,7 +676,7 @@ PyObject* CheckString(PyObject* arg, const FieldDescriptor* descriptor) {
if (descriptor->type() == FieldDescriptor::TYPE_STRING) {
if (!PyBytes_Check(arg) && !PyUnicode_Check(arg)) {
FormatTypeError(arg, "bytes, unicode");
- return NULL;
+ return nullptr;
}
if (!IsValidUTF8(arg) && !AllowInvalidUTF8(descriptor)) {
@@ -704,21 +687,21 @@ PyObject* CheckString(PyObject* arg, const FieldDescriptor* descriptor) {
"unicode objects before being added.",
PyString_AsString(repr));
Py_DECREF(repr);
- return NULL;
+ return nullptr;
}
} else if (!PyBytes_Check(arg)) {
FormatTypeError(arg, "bytes");
- return NULL;
+ return nullptr;
}
- PyObject* encoded_string = NULL;
+ PyObject* encoded_string = nullptr;
if (descriptor->type() == FieldDescriptor::TYPE_STRING) {
if (PyBytes_Check(arg)) {
// The bytes were already validated as correctly encoded UTF-8 above.
encoded_string = arg; // Already encoded.
Py_INCREF(encoded_string);
} else {
- encoded_string = PyUnicode_AsEncodedString(arg, "utf-8", NULL);
+ encoded_string = PyUnicode_AsEncodedString(arg, "utf-8", nullptr);
}
} else {
// In this case field type is "bytes".
@@ -737,7 +720,7 @@ bool CheckAndSetString(
int index) {
ScopedPyObjectPtr encoded_string(CheckString(arg, descriptor));
- if (encoded_string.get() == NULL) {
+ if (encoded_string.get() == nullptr) {
return false;
}
@@ -765,12 +748,13 @@ PyObject* ToStringObject(const FieldDescriptor* descriptor,
return PyBytes_FromStringAndSize(value.c_str(), value.length());
}
- PyObject* result = PyUnicode_DecodeUTF8(value.c_str(), value.length(), NULL);
+ PyObject* result =
+ PyUnicode_DecodeUTF8(value.c_str(), value.length(), nullptr);
// If the string can't be decoded in UTF-8, just return a string object that
// contains the raw bytes. This can't happen if the value was assigned using
// the members of the Python message object, but can happen if the values were
// parsed from the wire (binary).
- if (result == NULL) {
+ if (result == nullptr) {
PyErr_Clear();
result = PyBytes_FromStringAndSize(value.c_str(), value.length());
}
@@ -798,7 +782,6 @@ PyMessageFactory* GetFactoryForMessage(CMessage* message) {
static int MaybeReleaseOverlappingOneofField(
CMessage* cmessage,
const FieldDescriptor* field) {
-#ifdef GOOGLE_PROTOBUF_HAS_ONEOF
Message* message = cmessage->message;
const Reflection* reflection = message->GetReflection();
if (!field->containing_oneof() ||
@@ -818,7 +801,6 @@ static int MaybeReleaseOverlappingOneofField(
if (InternalReleaseFieldByDescriptor(cmessage, existing_field) < 0) {
return -1;
}
-#endif
return 0;
}
@@ -860,7 +842,7 @@ int FixupMessageAfterMerge(CMessage* self) {
// Making a message writable
int AssureWritable(CMessage* self) {
- if (self == NULL || !self->read_only) {
+ if (self == nullptr || !self->read_only) {
return 0;
}
@@ -883,7 +865,7 @@ int AssureWritable(CMessage* self) {
Message* mutable_message = reflection->MutableMessage(
parent_message, self->parent_field_descriptor,
GetFactoryForMessage(self->parent)->message_factory);
- if (mutable_message == NULL) {
+ if (mutable_message == nullptr) {
return -1;
}
self->message = mutable_message;
@@ -902,7 +884,7 @@ const FieldDescriptor* GetExtensionDescriptor(PyObject* extension) {
// allow input which is not a field descriptor, and simply pretend it does
// not exist.
PyErr_SetObject(PyExc_KeyError, extension);
- return NULL;
+ return nullptr;
}
return PyFieldDescriptor_AsDescriptor(extension);
}
@@ -913,20 +895,20 @@ static PyObject* GetIntegerEnumValue(const FieldDescriptor& descriptor,
PyObject* value) {
if (PyUnicode_Check(value)) {
const EnumDescriptor* enum_descriptor = descriptor.enum_type();
- if (enum_descriptor == NULL) {
+ if (enum_descriptor == nullptr) {
PyErr_SetString(PyExc_TypeError, "not an enum field");
- return NULL;
+ return nullptr;
}
char* enum_label;
Py_ssize_t size;
if (PyString_AsStringAndSize(value, &enum_label, &size) < 0) {
- return NULL;
+ return nullptr;
}
const EnumValueDescriptor* enum_value_descriptor =
enum_descriptor->FindValueByName(StringParam(enum_label, size));
- if (enum_value_descriptor == NULL) {
+ if (enum_value_descriptor == nullptr) {
PyErr_Format(PyExc_ValueError, "unknown enum label \"%s\"", enum_label);
- return NULL;
+ return nullptr;
}
return PyLong_FromLong(enum_value_descriptor->number());
}
@@ -996,7 +978,7 @@ int DeleteRepeatedField(
}
}
- Arena* arena = Arena::InternalHelper<Message>::GetArenaForAllocation(message);
+ Arena* arena = Arena::InternalGetArenaForAllocation(message);
GOOGLE_DCHECK_EQ(arena, nullptr)
<< "python protobuf is expected to be allocated from heap";
// Remove items, starting from the end.
@@ -1034,12 +1016,12 @@ int DeleteRepeatedField(
// Initializes fields of a message. Used in constructors.
int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
- if (args != NULL && PyTuple_Size(args) != 0) {
+ if (args != nullptr && PyTuple_Size(args) != 0) {
PyErr_SetString(PyExc_TypeError, "No positional arguments allowed");
return -1;
}
- if (kwargs == NULL) {
+ if (kwargs == nullptr) {
return 0;
}
@@ -1053,7 +1035,7 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
}
ScopedPyObjectPtr property(
PyObject_GetAttr(reinterpret_cast<PyObject*>(Py_TYPE(self)), name));
- if (property == NULL ||
+ if (property == nullptr ||
!PyObject_TypeCheck(property.get(), CFieldProperty_Type)) {
PyErr_Format(PyExc_ValueError, "Protocol message %s has no \"%s\" field.",
self->message->GetDescriptor()->name().c_str(),
@@ -1070,23 +1052,24 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
if (descriptor->is_map()) {
ScopedPyObjectPtr map(GetFieldValue(self, descriptor));
const FieldDescriptor* value_descriptor =
- descriptor->message_type()->FindFieldByName("value");
+ descriptor->message_type()->map_value();
if (value_descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
ScopedPyObjectPtr iter(PyObject_GetIter(value));
- if (iter == NULL) {
- PyErr_Format(PyExc_TypeError, "Argument %s is not iterable", PyString_AsString(name));
+ if (iter == nullptr) {
+ PyErr_Format(PyExc_TypeError, "Argument %s is not iterable",
+ PyString_AsString(name));
return -1;
}
ScopedPyObjectPtr next;
- while ((next.reset(PyIter_Next(iter.get()))) != NULL) {
+ while ((next.reset(PyIter_Next(iter.get()))) != nullptr) {
ScopedPyObjectPtr source_value(PyObject_GetItem(value, next.get()));
ScopedPyObjectPtr dest_value(PyObject_GetItem(map.get(), next.get()));
- if (source_value.get() == NULL || dest_value.get() == NULL) {
+ if (source_value.get() == nullptr || dest_value.get() == nullptr) {
return -1;
}
ScopedPyObjectPtr ok(PyObject_CallMethod(
dest_value.get(), "MergeFrom", "O", source_value.get()));
- if (ok.get() == NULL) {
+ if (ok.get() == nullptr) {
return -1;
}
}
@@ -1094,36 +1077,36 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
ScopedPyObjectPtr function_return;
function_return.reset(
PyObject_CallMethod(map.get(), "update", "O", value));
- if (function_return.get() == NULL) {
+ if (function_return.get() == nullptr) {
return -1;
}
}
} else if (descriptor->label() == FieldDescriptor::LABEL_REPEATED) {
ScopedPyObjectPtr container(GetFieldValue(self, descriptor));
- if (container == NULL) {
+ if (container == nullptr) {
return -1;
}
if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
RepeatedCompositeContainer* rc_container =
reinterpret_cast<RepeatedCompositeContainer*>(container.get());
ScopedPyObjectPtr iter(PyObject_GetIter(value));
- if (iter == NULL) {
+ if (iter == nullptr) {
PyErr_SetString(PyExc_TypeError, "Value must be iterable");
return -1;
}
ScopedPyObjectPtr next;
- while ((next.reset(PyIter_Next(iter.get()))) != NULL) {
- PyObject* kwargs = (PyDict_Check(next.get()) ? next.get() : NULL);
+ while ((next.reset(PyIter_Next(iter.get()))) != nullptr) {
+ PyObject* kwargs = (PyDict_Check(next.get()) ? next.get() : nullptr);
ScopedPyObjectPtr new_msg(
- repeated_composite_container::Add(rc_container, NULL, kwargs));
- if (new_msg == NULL) {
+ repeated_composite_container::Add(rc_container, nullptr, kwargs));
+ if (new_msg == nullptr) {
return -1;
}
- if (kwargs == NULL) {
+ if (kwargs == nullptr) {
// next was not a dict, it's a message we need to merge
ScopedPyObjectPtr merged(MergeFrom(
reinterpret_cast<CMessage*>(new_msg.get()), next.get()));
- if (merged.get() == NULL) {
+ if (merged.get() == nullptr) {
return -1;
}
}
@@ -1136,20 +1119,20 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
RepeatedScalarContainer* rs_container =
reinterpret_cast<RepeatedScalarContainer*>(container.get());
ScopedPyObjectPtr iter(PyObject_GetIter(value));
- if (iter == NULL) {
+ if (iter == nullptr) {
PyErr_SetString(PyExc_TypeError, "Value must be iterable");
return -1;
}
ScopedPyObjectPtr next;
- while ((next.reset(PyIter_Next(iter.get()))) != NULL) {
+ while ((next.reset(PyIter_Next(iter.get()))) != nullptr) {
ScopedPyObjectPtr enum_value(
GetIntegerEnumValue(*descriptor, next.get()));
- if (enum_value == NULL) {
+ if (enum_value == nullptr) {
return -1;
}
ScopedPyObjectPtr new_msg(repeated_scalar_container::Append(
rs_container, enum_value.get()));
- if (new_msg == NULL) {
+ if (new_msg == nullptr) {
return -1;
}
}
@@ -1160,26 +1143,25 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
} else {
if (ScopedPyObjectPtr(repeated_scalar_container::Extend(
reinterpret_cast<RepeatedScalarContainer*>(container.get()),
- value)) ==
- NULL) {
+ value)) == nullptr) {
return -1;
}
}
} else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
ScopedPyObjectPtr message(GetFieldValue(self, descriptor));
- if (message == NULL) {
+ if (message == nullptr) {
return -1;
}
CMessage* cmessage = reinterpret_cast<CMessage*>(message.get());
if (PyDict_Check(value)) {
// Make the message exist even if the dict is empty.
AssureWritable(cmessage);
- if (InitAttributes(cmessage, NULL, value) < 0) {
+ if (InitAttributes(cmessage, nullptr, value) < 0) {
return -1;
}
} else {
ScopedPyObjectPtr merged(MergeFrom(cmessage, value));
- if (merged == NULL) {
+ if (merged == nullptr) {
return -1;
}
}
@@ -1187,7 +1169,7 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
ScopedPyObjectPtr new_val;
if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
new_val.reset(GetIntegerEnumValue(*descriptor, value));
- if (new_val == NULL) {
+ if (new_val == nullptr) {
return -1;
}
value = new_val.get();
@@ -1205,19 +1187,19 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
CMessage* NewEmptyMessage(CMessageClass* type) {
CMessage* self = reinterpret_cast<CMessage*>(
PyType_GenericAlloc(&type->super.ht_type, 0));
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
- self->message = NULL;
- self->parent = NULL;
- self->parent_field_descriptor = NULL;
+ self->message = nullptr;
+ self->parent = nullptr;
+ self->parent_field_descriptor = nullptr;
self->read_only = false;
- self->composite_fields = NULL;
- self->child_submessages = NULL;
+ self->composite_fields = nullptr;
+ self->child_submessages = nullptr;
- self->unknown_field_set = NULL;
+ self->unknown_field_set = nullptr;
return self;
}
@@ -1309,30 +1291,27 @@ static void Dealloc(CMessage* self) {
PyObject* IsInitialized(CMessage* self, PyObject* args) {
- PyObject* errors = NULL;
+ PyObject* errors = nullptr;
if (!PyArg_ParseTuple(args, "|O", &errors)) {
- return NULL;
+ return nullptr;
}
if (self->message->IsInitialized()) {
Py_RETURN_TRUE;
}
- if (errors != NULL) {
+ if (errors != nullptr) {
ScopedPyObjectPtr initialization_errors(
FindInitializationErrors(self));
- if (initialization_errors == NULL) {
- return NULL;
+ if (initialization_errors == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr extend_name(PyUnicode_FromString("extend"));
- if (extend_name == NULL) {
- return NULL;
+ if (extend_name == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr result(PyObject_CallMethodObjArgs(
- errors,
- extend_name.get(),
- initialization_errors.get(),
- NULL));
- if (result == NULL) {
- return NULL;
+ errors, extend_name.get(), initialization_errors.get(), nullptr));
+ if (result == nullptr) {
+ return nullptr;
}
}
Py_RETURN_FALSE;
@@ -1359,17 +1338,17 @@ const FieldDescriptor* FindFieldWithOneofs(const Message* message,
const Descriptor* descriptor = message->GetDescriptor();
const FieldDescriptor* field_descriptor =
descriptor->FindFieldByName(field_name);
- if (field_descriptor != NULL) {
+ if (field_descriptor != nullptr) {
return field_descriptor;
}
const OneofDescriptor* oneof_desc =
descriptor->FindOneofByName(field_name);
- if (oneof_desc != NULL) {
+ if (oneof_desc != nullptr) {
*in_oneof = true;
return message->GetReflection()->GetOneofFieldDescriptor(*message,
oneof_desc);
}
- return NULL;
+ return nullptr;
}
bool CheckHasPresence(const FieldDescriptor* field_descriptor, bool in_oneof) {
@@ -1397,25 +1376,25 @@ PyObject* HasField(CMessage* self, PyObject* arg) {
Py_ssize_t size;
field_name = const_cast<char*>(PyUnicode_AsUTF8AndSize(arg, &size));
if (!field_name) {
- return NULL;
+ return nullptr;
}
Message* message = self->message;
bool is_in_oneof;
const FieldDescriptor* field_descriptor =
FindFieldWithOneofs(message, StringParam(field_name, size), &is_in_oneof);
- if (field_descriptor == NULL) {
+ if (field_descriptor == nullptr) {
if (!is_in_oneof) {
PyErr_Format(PyExc_ValueError, "Protocol message %s has no field %s.",
message->GetDescriptor()->name().c_str(), field_name);
- return NULL;
+ return nullptr;
} else {
Py_RETURN_FALSE;
}
}
if (!CheckHasPresence(field_descriptor, is_in_oneof)) {
- return NULL;
+ return nullptr;
}
if (message->GetReflection()->HasField(*message, field_descriptor)) {
@@ -1427,8 +1406,8 @@ PyObject* HasField(CMessage* self, PyObject* arg) {
PyObject* ClearExtension(CMessage* self, PyObject* extension) {
const FieldDescriptor* descriptor = GetExtensionDescriptor(extension);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
if (ClearFieldByDescriptor(self, descriptor) < 0) {
return nullptr;
@@ -1438,8 +1417,8 @@ PyObject* ClearExtension(CMessage* self, PyObject* extension) {
PyObject* HasExtension(CMessage* self, PyObject* extension) {
const FieldDescriptor* descriptor = GetExtensionDescriptor(extension);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
int has_field = HasFieldByDescriptor(self, descriptor);
if (has_field < 0) {
@@ -1582,20 +1561,20 @@ PyObject* ClearField(CMessage* self, PyObject* arg) {
char* field_name;
Py_ssize_t field_size;
if (PyString_AsStringAndSize(arg, &field_name, &field_size) < 0) {
- return NULL;
+ return nullptr;
}
AssureWritable(self);
bool is_in_oneof;
const FieldDescriptor* field_descriptor = FindFieldWithOneofs(
self->message, StringParam(field_name, field_size), &is_in_oneof);
- if (field_descriptor == NULL) {
+ if (field_descriptor == nullptr) {
if (is_in_oneof) {
// We gave the name of a oneof, and none of its fields are set.
Py_RETURN_NONE;
} else {
PyErr_Format(PyExc_ValueError,
"Protocol message has no \"%s\" field.", field_name);
- return NULL;
+ return nullptr;
}
}
@@ -1622,7 +1601,7 @@ PyObject* Clear(CMessage* self) {
}
if (InternalReparentFields(self, messages_to_release, containers_to_release) <
0) {
- return NULL;
+ return nullptr;
}
if (self->unknown_field_set) {
unknown_fields::Clear(
@@ -1636,7 +1615,7 @@ PyObject* Clear(CMessage* self) {
// ---------------------------------------------------------------------
static TProtoStringType GetMessageName(CMessage* self) {
- if (self->parent_field_descriptor != NULL) {
+ if (self->parent_field_descriptor != nullptr) {
return self->parent_field_descriptor->full_name();
} else {
return self->message->GetDescriptor()->full_name();
@@ -1647,33 +1626,33 @@ static PyObject* InternalSerializeToString(
CMessage* self, PyObject* args, PyObject* kwargs,
bool require_initialized) {
// Parse the "deterministic" kwarg; defaults to False.
- static const char* kwlist[] = {"deterministic", 0};
+ static const char* kwlist[] = {"deterministic", nullptr};
PyObject* deterministic_obj = Py_None;
if (!PyArg_ParseTupleAndKeywords(
args, kwargs, "|O", const_cast<char**>(kwlist), &deterministic_obj)) {
- return NULL;
+ return nullptr;
}
// Preemptively convert to a bool first, so we don't need to back out of
// allocating memory if this raises an exception.
// NOTE: This is unused later if deterministic == Py_None, but that's fine.
int deterministic = PyObject_IsTrue(deterministic_obj);
if (deterministic < 0) {
- return NULL;
+ return nullptr;
}
if (require_initialized && !self->message->IsInitialized()) {
ScopedPyObjectPtr errors(FindInitializationErrors(self));
- if (errors == NULL) {
- return NULL;
+ if (errors == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr comma(PyUnicode_FromString(","));
- if (comma == NULL) {
- return NULL;
+ if (comma == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr joined(
PyObject_CallMethod(comma.get(), "join", "O", errors.get()));
- if (joined == NULL) {
- return NULL;
+ if (joined == nullptr) {
+ return nullptr;
}
// TODO(haberman): this is a (hopefully temporary) hack. The unit testing
@@ -1685,19 +1664,19 @@ static PyObject* InternalSerializeToString(
// again every time.
ScopedPyObjectPtr message_module(PyImport_ImportModule(
"google.protobuf.message"));
- if (message_module.get() == NULL) {
- return NULL;
+ if (message_module.get() == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr encode_error(
PyObject_GetAttrString(message_module.get(), "EncodeError"));
- if (encode_error.get() == NULL) {
- return NULL;
+ if (encode_error.get() == nullptr) {
+ return nullptr;
}
PyErr_Format(encode_error.get(),
"Message %s is missing required fields: %s",
GetMessageName(self).c_str(), PyString_AsString(joined.get()));
- return NULL;
+ return nullptr;
}
// Ok, arguments parsed and errors checked, now encode to a string
@@ -1714,9 +1693,9 @@ static PyObject* InternalSerializeToString(
return nullptr;
}
- PyObject* result = PyBytes_FromStringAndSize(NULL, size);
- if (result == NULL) {
- return NULL;
+ PyObject* result = PyBytes_FromStringAndSize(nullptr, size);
+ if (result == nullptr) {
+ return nullptr;
}
io::ArrayOutputStream out(PyBytes_AS_STRING(result), size);
io::CodedOutputStream coded_out(&out);
@@ -1790,7 +1769,7 @@ static PyObject* ToStr(CMessage* self) {
TProtoStringType output;
if (!printer.PrintToString(*self->message, &output)) {
PyErr_SetString(PyExc_ValueError, "Unable to convert message to str");
- return NULL;
+ return nullptr;
}
return PyUnicode_FromString(output.c_str());
}
@@ -1803,7 +1782,7 @@ PyObject* MergeFrom(CMessage* self, PyObject* arg) {
"expected %s got %s.",
self->message->GetDescriptor()->full_name().c_str(),
Py_TYPE(arg)->tp_name);
- return NULL;
+ return nullptr;
}
other_message = reinterpret_cast<CMessage*>(arg);
@@ -1814,7 +1793,7 @@ PyObject* MergeFrom(CMessage* self, PyObject* arg) {
"expected %s got %s.",
self->message->GetDescriptor()->full_name().c_str(),
other_message->message->GetDescriptor()->full_name().c_str());
- return NULL;
+ return nullptr;
}
AssureWritable(self);
@@ -1822,7 +1801,7 @@ PyObject* MergeFrom(CMessage* self, PyObject* arg) {
// Child message might be lazily created before MergeFrom. Make sure they
// are mutable at this point if child messages are really created.
if (FixupMessageAfterMerge(self) < 0) {
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
@@ -1836,7 +1815,7 @@ static PyObject* CopyFrom(CMessage* self, PyObject* arg) {
"expected %s got %s.",
self->message->GetDescriptor()->full_name().c_str(),
Py_TYPE(arg)->tp_name);
- return NULL;
+ return nullptr;
}
other_message = reinterpret_cast<CMessage*>(arg);
@@ -1852,7 +1831,7 @@ static PyObject* CopyFrom(CMessage* self, PyObject* arg) {
"expected %s got %s.",
self->message->GetDescriptor()->full_name().c_str(),
other_message->message->GetDescriptor()->full_name().c_str());
- return NULL;
+ return nullptr;
}
AssureWritable(self);
@@ -1872,7 +1851,7 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg) {
if (!arg || !PyBool_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"Argument to SetAllowOversizeProtos must be boolean");
- return NULL;
+ return nullptr;
}
allow_oversize_protos = PyObject_IsTrue(arg);
if (allow_oversize_protos) {
@@ -1885,7 +1864,7 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg) {
static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
Py_buffer data;
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) < 0) {
- return NULL;
+ return nullptr;
}
AssureWritable(self);
@@ -1907,19 +1886,29 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
// Child message might be lazily created before MergeFrom. Make sure they
// are mutable at this point if child messages are really created.
if (FixupMessageAfterMerge(self) < 0) {
- return NULL;
+ return nullptr;
}
// Python makes distinction in error message, between a general parse failure
// and in-correct ending on a terminating tag. Hence we need to be a bit more
// explicit in our correctness checks.
- if (ptr == nullptr || ctx.BytesUntilLimit(ptr) < 0) {
- // Parse error or the parser overshoot the limit.
+ if (ptr == nullptr) {
+ // Parse error.
PyErr_Format(
DecodeError_class, "Error parsing message with type '%s'",
self->GetMessageClass()->message_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
+ }
+ if (ctx.BytesUntilLimit(ptr) < 0) {
+ // The parser overshot the limit.
+ PyErr_Format(
+ DecodeError_class,
+ "Error parsing message as the message exceeded the protobuf limit "
+ "with type '%s'",
+ self->GetMessageClass()->message_descriptor->full_name().c_str());
+ return nullptr;
}
+
// ctx has an explicit limit set (length of string_view), so we have to
// check we ended at that limit.
if (!ctx.EndedAtLimit()) {
@@ -1930,8 +1919,8 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
}
static PyObject* ParseFromString(CMessage* self, PyObject* arg) {
- if (ScopedPyObjectPtr(Clear(self)) == NULL) {
- return NULL;
+ if (ScopedPyObjectPtr(Clear(self)) == nullptr) {
+ return nullptr;
}
return MergeFromString(self, arg);
}
@@ -1943,25 +1932,25 @@ static PyObject* ByteSize(CMessage* self, PyObject* args) {
PyObject* RegisterExtension(PyObject* cls, PyObject* extension_handle) {
const FieldDescriptor* descriptor =
GetExtensionDescriptor(extension_handle);
- if (descriptor == NULL) {
- return NULL;
+ if (descriptor == nullptr) {
+ return nullptr;
}
if (!PyObject_TypeCheck(cls, CMessageClass_Type)) {
PyErr_Format(PyExc_TypeError, "Expected a message class, got %s",
cls->ob_type->tp_name);
- return NULL;
+ return nullptr;
}
CMessageClass *message_class = reinterpret_cast<CMessageClass*>(cls);
- if (message_class == NULL) {
- return NULL;
+ if (message_class == nullptr) {
+ return nullptr;
}
// If the extension was already registered, check that it is the same.
const FieldDescriptor* existing_extension =
message_class->py_message_factory->pool->pool->FindExtensionByNumber(
descriptor->containing_type(), descriptor->number());
- if (existing_extension != NULL && existing_extension != descriptor) {
+ if (existing_extension != nullptr && existing_extension != descriptor) {
PyErr_SetString(PyExc_ValueError, "Double registration of Extensions");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -1974,20 +1963,19 @@ static PyObject* SetInParent(CMessage* self, PyObject* args) {
static PyObject* WhichOneof(CMessage* self, PyObject* arg) {
Py_ssize_t name_size;
char *name_data;
- if (PyString_AsStringAndSize(arg, &name_data, &name_size) < 0)
- return NULL;
+ if (PyString_AsStringAndSize(arg, &name_data, &name_size) < 0) return nullptr;
const OneofDescriptor* oneof_desc =
self->message->GetDescriptor()->FindOneofByName(
StringParam(name_data, name_size));
- if (oneof_desc == NULL) {
+ if (oneof_desc == nullptr) {
PyErr_Format(PyExc_ValueError,
"Protocol message has no oneof \"%s\" field.", name_data);
- return NULL;
+ return nullptr;
}
const FieldDescriptor* field_in_oneof =
self->message->GetReflection()->GetOneofFieldDescriptor(
*self->message, oneof_desc);
- if (field_in_oneof == NULL) {
+ if (field_in_oneof == nullptr) {
Py_RETURN_NONE;
} else {
const TProtoStringType& name = field_in_oneof->name();
@@ -2003,8 +1991,8 @@ static PyObject* ListFields(CMessage* self) {
// Normally, the list will be exactly the size of the fields.
ScopedPyObjectPtr all_fields(PyList_New(fields.size()));
- if (all_fields == NULL) {
- return NULL;
+ if (all_fields == nullptr) {
+ return nullptr;
}
// When there are unknown extensions, the py list will *not* contain
@@ -2013,36 +2001,36 @@ static PyObject* ListFields(CMessage* self) {
Py_ssize_t actual_size = 0;
for (size_t i = 0; i < fields.size(); ++i) {
ScopedPyObjectPtr t(PyTuple_New(2));
- if (t == NULL) {
- return NULL;
+ if (t == nullptr) {
+ return nullptr;
}
if (fields[i]->is_extension()) {
ScopedPyObjectPtr extension_field(
PyFieldDescriptor_FromDescriptor(fields[i]));
- if (extension_field == NULL) {
- return NULL;
+ if (extension_field == nullptr) {
+ return nullptr;
}
// With C++ descriptors, the field can always be retrieved, but for
// unknown extensions which have not been imported in Python code, there
// is no message class and we cannot retrieve the value.
// TODO(amauryfa): consider building the class on the fly!
- if (fields[i]->message_type() != NULL &&
- message_factory::GetMessageClass(
- GetFactoryForMessage(self),
- fields[i]->message_type()) == NULL) {
+ if (fields[i]->message_type() != nullptr &&
+ message_factory::GetMessageClass(GetFactoryForMessage(self),
+ fields[i]->message_type()) ==
+ nullptr) {
PyErr_Clear();
continue;
}
- ScopedPyObjectPtr extensions(GetExtensionDict(self, NULL));
- if (extensions == NULL) {
- return NULL;
+ ScopedPyObjectPtr extensions(GetExtensionDict(self, nullptr));
+ if (extensions == nullptr) {
+ return nullptr;
}
// 'extension' reference later stolen by PyTuple_SET_ITEM.
PyObject* extension = PyObject_GetItem(
extensions.get(), extension_field.get());
- if (extension == NULL) {
- return NULL;
+ if (extension == nullptr) {
+ return nullptr;
}
PyTuple_SET_ITEM(t.get(), 0, extension_field.release());
// Steals reference to 'extension'
@@ -2051,14 +2039,14 @@ static PyObject* ListFields(CMessage* self) {
// Normal field
ScopedPyObjectPtr field_descriptor(
PyFieldDescriptor_FromDescriptor(fields[i]));
- if (field_descriptor == NULL) {
- return NULL;
+ if (field_descriptor == nullptr) {
+ return nullptr;
}
PyObject* field_value = GetFieldValue(self, fields[i]);
- if (field_value == NULL) {
+ if (field_value == nullptr) {
PyErr_SetString(PyExc_ValueError, fields[i]->name().c_str());
- return NULL;
+ return nullptr;
}
PyTuple_SET_ITEM(t.get(), 0, field_descriptor.release());
PyTuple_SET_ITEM(t.get(), 1, field_value);
@@ -2067,9 +2055,9 @@ static PyObject* ListFields(CMessage* self) {
++actual_size;
}
if (static_cast<size_t>(actual_size) != fields.size() &&
- (PyList_SetSlice(all_fields.get(), actual_size, fields.size(), NULL) <
+ (PyList_SetSlice(all_fields.get(), actual_size, fields.size(), nullptr) <
0)) {
- return NULL;
+ return nullptr;
}
return all_fields.release();
}
@@ -2086,16 +2074,16 @@ PyObject* FindInitializationErrors(CMessage* self) {
message->FindInitializationErrors(&errors);
PyObject* error_list = PyList_New(errors.size());
- if (error_list == NULL) {
- return NULL;
+ if (error_list == nullptr) {
+ return nullptr;
}
for (size_t i = 0; i < errors.size(); ++i) {
const TProtoStringType& error = errors[i];
PyObject* error_string =
PyUnicode_FromStringAndSize(error.c_str(), error.length());
- if (error_string == NULL) {
+ if (error_string == nullptr) {
Py_DECREF(error_list);
- return NULL;
+ return nullptr;
}
PyList_SET_ITEM(error_list, i, error_string);
}
@@ -2141,10 +2129,10 @@ PyObject* InternalGetScalar(const Message* message,
const Reflection* reflection = message->GetReflection();
if (!CheckFieldBelongsToMessage(field_descriptor, message)) {
- return NULL;
+ return nullptr;
}
- PyObject* result = NULL;
+ PyObject* result = nullptr;
switch (field_descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
int32_t value = reflection->GetInt32(*message, field_descriptor);
@@ -2212,13 +2200,13 @@ CMessage* InternalGetSubMessage(
factory, field_descriptor->message_type());
ScopedPyObjectPtr message_class_owner(
reinterpret_cast<PyObject*>(message_class));
- if (message_class == NULL) {
- return NULL;
+ if (message_class == nullptr) {
+ return nullptr;
}
CMessage* cmsg = cmessage::NewEmptyMessage(message_class);
- if (cmsg == NULL) {
- return NULL;
+ if (cmsg == nullptr) {
+ return nullptr;
}
Py_INCREF(self);
@@ -2304,7 +2292,7 @@ int InternalSetNonOneofScalar(
const EnumDescriptor* enum_descriptor = field_descriptor->enum_type();
const EnumValueDescriptor* enum_value =
enum_descriptor->FindValueByNumber(value);
- if (enum_value != NULL) {
+ if (enum_value != nullptr) {
reflection->SetEnum(message, field_descriptor, enum_value);
} else {
PyErr_Format(PyExc_ValueError, "Unknown enum value: %d", value);
@@ -2339,37 +2327,37 @@ int InternalSetScalar(
}
PyObject* FromString(PyTypeObject* cls, PyObject* serialized) {
- PyObject* py_cmsg = PyObject_CallObject(
- reinterpret_cast<PyObject*>(cls), NULL);
- if (py_cmsg == NULL) {
- return NULL;
+ PyObject* py_cmsg =
+ PyObject_CallObject(reinterpret_cast<PyObject*>(cls), nullptr);
+ if (py_cmsg == nullptr) {
+ return nullptr;
}
CMessage* cmsg = reinterpret_cast<CMessage*>(py_cmsg);
ScopedPyObjectPtr py_length(MergeFromString(cmsg, serialized));
- if (py_length == NULL) {
+ if (py_length == nullptr) {
Py_DECREF(py_cmsg);
- return NULL;
+ return nullptr;
}
return py_cmsg;
}
PyObject* DeepCopy(CMessage* self, PyObject* arg) {
- PyObject* clone = PyObject_CallObject(
- reinterpret_cast<PyObject*>(Py_TYPE(self)), NULL);
- if (clone == NULL) {
- return NULL;
+ PyObject* clone =
+ PyObject_CallObject(reinterpret_cast<PyObject*>(Py_TYPE(self)), nullptr);
+ if (clone == nullptr) {
+ return nullptr;
}
if (!PyObject_TypeCheck(clone, CMessage_Type)) {
Py_DECREF(clone);
- return NULL;
+ return nullptr;
}
- if (ScopedPyObjectPtr(MergeFrom(
- reinterpret_cast<CMessage*>(clone),
- reinterpret_cast<PyObject*>(self))) == NULL) {
+ if (ScopedPyObjectPtr(MergeFrom(reinterpret_cast<CMessage*>(clone),
+ reinterpret_cast<PyObject*>(self))) ==
+ nullptr) {
Py_DECREF(clone);
- return NULL;
+ return nullptr;
}
return clone;
}
@@ -2378,23 +2366,24 @@ PyObject* ToUnicode(CMessage* self) {
// Lazy import to prevent circular dependencies
ScopedPyObjectPtr text_format(
PyImport_ImportModule("google.protobuf.text_format"));
- if (text_format == NULL) {
- return NULL;
+ if (text_format == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr method_name(PyUnicode_FromString("MessageToString"));
- if (method_name == NULL) {
- return NULL;
+ if (method_name == nullptr) {
+ return nullptr;
}
Py_INCREF(Py_True);
ScopedPyObjectPtr encoded(PyObject_CallMethodObjArgs(
- text_format.get(), method_name.get(), self, Py_True, NULL));
+ text_format.get(), method_name.get(), self, Py_True, nullptr));
Py_DECREF(Py_True);
- if (encoded == NULL) {
- return NULL;
+ if (encoded == nullptr) {
+ return nullptr;
}
- PyObject* decoded = PyUnicode_FromEncodedObject(encoded.get(), "utf-8", NULL);
- if (decoded == NULL) {
- return NULL;
+ PyObject* decoded =
+ PyUnicode_FromEncodedObject(encoded.get(), "utf-8", nullptr);
+ if (decoded == nullptr) {
+ return nullptr;
}
return decoded;
}
@@ -2406,7 +2395,7 @@ PyObject* _CheckCalledFromGeneratedFile(PyObject* unused,
PyErr_SetString(PyExc_TypeError,
"Descriptors should not be created directly, "
"but only retrieved from their parent.");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -2417,20 +2406,20 @@ static PyObject* GetExtensionDict(CMessage* self, void *closure) {
const Descriptor* descriptor = GetMessageDescriptor(Py_TYPE(self));
if (!descriptor->extension_range_count()) {
PyErr_SetNone(PyExc_AttributeError);
- return NULL;
+ return nullptr;
}
if (!self->composite_fields) {
self->composite_fields = new CMessage::CompositeFieldsMap();
}
if (!self->composite_fields) {
- return NULL;
+ return nullptr;
}
ExtensionDict* extension_dict = extension_dict::NewExtensionDict(self);
return reinterpret_cast<PyObject*>(extension_dict);
}
static PyObject* UnknownFieldSet(CMessage* self) {
- if (self->unknown_field_set == NULL) {
+ if (self->unknown_field_set == nullptr) {
self->unknown_field_set = unknown_fields::NewPyUnknownFields(self);
} else {
Py_INCREF(self->unknown_field_set);
@@ -2449,75 +2438,70 @@ static PyObject* GetExtensionsByNumber(CMessage *self, void *closure) {
}
static PyGetSetDef Getters[] = {
- {"Extensions", (getter)GetExtensionDict, NULL, "Extension dict"},
- {"_extensions_by_name", (getter)GetExtensionsByName, NULL},
- {"_extensions_by_number", (getter)GetExtensionsByNumber, NULL},
- {NULL}
+ {"Extensions", (getter)GetExtensionDict, nullptr, "Extension dict"},
+ {"_extensions_by_name", (getter)GetExtensionsByName, nullptr},
+ {"_extensions_by_number", (getter)GetExtensionsByNumber, nullptr},
+ {nullptr},
};
-
static PyMethodDef Methods[] = {
- { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS,
- "Makes a deep copy of the class." },
- { "__unicode__", (PyCFunction)ToUnicode, METH_NOARGS,
- "Outputs a unicode representation of the message." },
- { "ByteSize", (PyCFunction)ByteSize, METH_NOARGS,
- "Returns the size of the message in bytes." },
- { "Clear", (PyCFunction)Clear, METH_NOARGS,
- "Clears the message." },
- { "ClearExtension", (PyCFunction)ClearExtension, METH_O,
- "Clears a message field." },
- { "ClearField", (PyCFunction)ClearField, METH_O,
- "Clears a message field." },
- { "CopyFrom", (PyCFunction)CopyFrom, METH_O,
- "Copies a protocol message into the current message." },
- { "DiscardUnknownFields", (PyCFunction)DiscardUnknownFields, METH_NOARGS,
- "Discards the unknown fields." },
- { "FindInitializationErrors", (PyCFunction)FindInitializationErrors,
- METH_NOARGS,
- "Finds unset required fields." },
- { "FromString", (PyCFunction)FromString, METH_O | METH_CLASS,
- "Creates new method instance from given serialized data." },
- { "HasExtension", (PyCFunction)HasExtension, METH_O,
- "Checks if a message field is set." },
- { "HasField", (PyCFunction)HasField, METH_O,
- "Checks if a message field is set." },
- { "IsInitialized", (PyCFunction)IsInitialized, METH_VARARGS,
- "Checks if all required fields of a protocol message are set." },
- { "ListFields", (PyCFunction)ListFields, METH_NOARGS,
- "Lists all set fields of a message." },
- { "MergeFrom", (PyCFunction)MergeFrom, METH_O,
- "Merges a protocol message into the current message." },
- { "MergeFromString", (PyCFunction)MergeFromString, METH_O,
- "Merges a serialized message into the current message." },
- { "ParseFromString", (PyCFunction)ParseFromString, METH_O,
- "Parses a serialized message into the current message." },
- { "RegisterExtension", (PyCFunction)RegisterExtension, METH_O | METH_CLASS,
- "Registers an extension with the current message." },
- { "SerializePartialToString", (PyCFunction)SerializePartialToString,
- METH_VARARGS | METH_KEYWORDS,
- "Serializes the message to a string, even if it isn't initialized." },
- { "SerializeToString", (PyCFunction)SerializeToString,
- METH_VARARGS | METH_KEYWORDS,
- "Serializes the message to a string, only for initialized messages." },
- { "SetInParent", (PyCFunction)SetInParent, METH_NOARGS,
- "Sets the has bit of the given field in its parent message." },
- { "UnknownFields", (PyCFunction)UnknownFieldSet, METH_NOARGS,
- "Parse unknown field set"},
- { "WhichOneof", (PyCFunction)WhichOneof, METH_O,
- "Returns the name of the field set inside a oneof, "
- "or None if no field is set." },
-
- // Static Methods.
- { "_CheckCalledFromGeneratedFile", (PyCFunction)_CheckCalledFromGeneratedFile,
- METH_NOARGS | METH_STATIC,
- "Raises TypeError if the caller is not in a _pb2.py file."},
- { NULL, NULL}
-};
+ {"__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS,
+ "Makes a deep copy of the class."},
+ {"__unicode__", (PyCFunction)ToUnicode, METH_NOARGS,
+ "Outputs a unicode representation of the message."},
+ {"ByteSize", (PyCFunction)ByteSize, METH_NOARGS,
+ "Returns the size of the message in bytes."},
+ {"Clear", (PyCFunction)Clear, METH_NOARGS, "Clears the message."},
+ {"ClearExtension", (PyCFunction)ClearExtension, METH_O,
+ "Clears a message field."},
+ {"ClearField", (PyCFunction)ClearField, METH_O, "Clears a message field."},
+ {"CopyFrom", (PyCFunction)CopyFrom, METH_O,
+ "Copies a protocol message into the current message."},
+ {"DiscardUnknownFields", (PyCFunction)DiscardUnknownFields, METH_NOARGS,
+ "Discards the unknown fields."},
+ {"FindInitializationErrors", (PyCFunction)FindInitializationErrors,
+ METH_NOARGS, "Finds unset required fields."},
+ {"FromString", (PyCFunction)FromString, METH_O | METH_CLASS,
+ "Creates new method instance from given serialized data."},
+ {"HasExtension", (PyCFunction)HasExtension, METH_O,
+ "Checks if a message field is set."},
+ {"HasField", (PyCFunction)HasField, METH_O,
+ "Checks if a message field is set."},
+ {"IsInitialized", (PyCFunction)IsInitialized, METH_VARARGS,
+ "Checks if all required fields of a protocol message are set."},
+ {"ListFields", (PyCFunction)ListFields, METH_NOARGS,
+ "Lists all set fields of a message."},
+ {"MergeFrom", (PyCFunction)MergeFrom, METH_O,
+ "Merges a protocol message into the current message."},
+ {"MergeFromString", (PyCFunction)MergeFromString, METH_O,
+ "Merges a serialized message into the current message."},
+ {"ParseFromString", (PyCFunction)ParseFromString, METH_O,
+ "Parses a serialized message into the current message."},
+ {"RegisterExtension", (PyCFunction)RegisterExtension, METH_O | METH_CLASS,
+ "Registers an extension with the current message."},
+ {"SerializePartialToString", (PyCFunction)SerializePartialToString,
+ METH_VARARGS | METH_KEYWORDS,
+ "Serializes the message to a string, even if it isn't initialized."},
+ {"SerializeToString", (PyCFunction)SerializeToString,
+ METH_VARARGS | METH_KEYWORDS,
+ "Serializes the message to a string, only for initialized messages."},
+ {"SetInParent", (PyCFunction)SetInParent, METH_NOARGS,
+ "Sets the has bit of the given field in its parent message."},
+ {"UnknownFields", (PyCFunction)UnknownFieldSet, METH_NOARGS,
+ "Parse unknown field set"},
+ {"WhichOneof", (PyCFunction)WhichOneof, METH_O,
+ "Returns the name of the field set inside a oneof, "
+ "or None if no field is set."},
+
+ // Static Methods.
+ {"_CheckCalledFromGeneratedFile",
+ (PyCFunction)_CheckCalledFromGeneratedFile, METH_NOARGS | METH_STATIC,
+ "Raises TypeError if the caller is not in a _pb2.py file."},
+ {nullptr, nullptr}};
bool SetCompositeField(CMessage* self, const FieldDescriptor* field,
ContainerBase* value) {
- if (self->composite_fields == NULL) {
+ if (self->composite_fields == nullptr) {
self->composite_fields = new CMessage::CompositeFieldsMap();
}
(*self->composite_fields)[field] = value;
@@ -2525,7 +2509,7 @@ bool SetCompositeField(CMessage* self, const FieldDescriptor* field,
}
bool SetSubmessage(CMessage* self, CMessage* submessage) {
- if (self->child_submessages == NULL) {
+ if (self->child_submessages == nullptr) {
self->child_submessages = new CMessage::SubMessagesMap();
}
(*self->child_submessages)[submessage->message] = submessage;
@@ -2536,11 +2520,11 @@ PyObject* GetAttr(PyObject* pself, PyObject* name) {
CMessage* self = reinterpret_cast<CMessage*>(pself);
PyObject* result = PyObject_GenericGetAttr(
reinterpret_cast<PyObject*>(self), name);
- if (result != NULL) {
+ if (result != nullptr) {
return result;
}
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
- return NULL;
+ return nullptr;
}
PyErr_Clear();
@@ -2565,7 +2549,7 @@ PyObject* GetFieldValue(CMessage* self,
"descriptor to field '%s' doesn't apply to '%s' object",
field_descriptor->full_name().c_str(),
Py_TYPE(self)->tp_name);
- return NULL;
+ return nullptr;
}
if (!field_descriptor->is_repeated() &&
@@ -2576,12 +2560,12 @@ PyObject* GetFieldValue(CMessage* self,
ContainerBase* py_container = nullptr;
if (field_descriptor->is_map()) {
const Descriptor* entry_type = field_descriptor->message_type();
- const FieldDescriptor* value_type = entry_type->FindFieldByName("value");
+ const FieldDescriptor* value_type = entry_type->map_value();
if (value_type->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
CMessageClass* value_class = message_factory::GetMessageClass(
GetFactoryForMessage(self), value_type->message_type());
- if (value_class == NULL) {
- return NULL;
+ if (value_class == nullptr) {
+ return nullptr;
}
py_container =
NewMessageMapContainer(self, field_descriptor, value_class);
@@ -2592,8 +2576,8 @@ PyObject* GetFieldValue(CMessage* self,
if (field_descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
CMessageClass* message_class = message_factory::GetMessageClass(
GetFactoryForMessage(self), field_descriptor->message_type());
- if (message_class == NULL) {
- return NULL;
+ if (message_class == nullptr) {
+ return nullptr;
}
py_container = repeated_composite_container::NewContainer(
self, field_descriptor, message_class);
@@ -2608,12 +2592,12 @@ PyObject* GetFieldValue(CMessage* self,
PyErr_SetString(PyExc_SystemError, "Should never happen");
}
- if (py_container == NULL) {
- return NULL;
+ if (py_container == nullptr) {
+ return nullptr;
}
if (!SetCompositeField(self, field_descriptor, py_container)) {
Py_DECREF(py_container);
- return NULL;
+ return nullptr;
}
return py_container->AsPyObject();
}
@@ -2689,8 +2673,8 @@ CMessage* CMessage::BuildSubMessageFromPointer(
} else {
cmsg = cmessage::NewEmptyMessage(message_class);
- if (cmsg == NULL) {
- return NULL;
+ if (cmsg == nullptr) {
+ return nullptr;
}
cmsg->message = sub_message;
Py_INCREF(this);
@@ -2719,47 +2703,51 @@ CMessage* CMessage::MaybeReleaseSubMessage(Message* sub_message) {
return released;
}
-static CMessageClass _CMessage_Type = { { {
- PyVarObject_HEAD_INIT(&_CMessageClass_Type, 0)
- FULL_MODULE_NAME ".CMessage", // tp_name
- sizeof(CMessage), // tp_basicsize
- 0, // tp_itemsize
- (destructor)cmessage::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- (reprfunc)cmessage::ToStr, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- PyObject_HashNotImplemented, // tp_hash
- 0, // tp_call
- (reprfunc)cmessage::ToStr, // tp_str
- cmessage::GetAttr, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
- | Py_TPFLAGS_HAVE_VERSION_TAG, // tp_flags
- "A ProtocolMessage", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- (richcmpfunc)cmessage::RichCompare, // tp_richcompare
- offsetof(CMessage, weakreflist), // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- cmessage::Methods, // tp_methods
- 0, // tp_members
- cmessage::Getters, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- (initproc)cmessage::Init, // tp_init
- 0, // tp_alloc
- cmessage::New, // tp_new
-} } };
+static CMessageClass _CMessage_Type = {{{
+ PyVarObject_HEAD_INIT(&_CMessageClass_Type, 0) FULL_MODULE_NAME
+ ".CMessage", // tp_name
+ sizeof(CMessage), // tp_basicsize
+ 0, // tp_itemsize
+ (destructor)cmessage::Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ (reprfunc)cmessage::ToStr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ PyObject_HashNotImplemented, // tp_hash
+ nullptr, // tp_call
+ (reprfunc)cmessage::ToStr, // tp_str
+ cmessage::GetAttr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
+ Py_TPFLAGS_HAVE_VERSION_TAG, // tp_flags
+ "A ProtocolMessage", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ (richcmpfunc)cmessage::RichCompare, // tp_richcompare
+ offsetof(CMessage, weakreflist), // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ cmessage::Methods, // tp_methods
+ nullptr, // tp_members
+ cmessage::Getters, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ (initproc)cmessage::Init, // tp_init
+ nullptr, // tp_alloc
+ cmessage::New, // tp_new
+}}};
PyTypeObject* CMessage_Type = &_CMessage_Type.super.ht_type;
// --- Exposing the C proto living inside Python proto to C code:
@@ -2769,18 +2757,18 @@ Message* (*MutableCProtoInsidePyProtoPtr)(PyObject* msg);
static const Message* GetCProtoInsidePyProtoImpl(PyObject* msg) {
const Message* message = PyMessage_GetMessagePointer(msg);
- if (message == NULL) {
+ if (message == nullptr) {
PyErr_Clear();
- return NULL;
+ return nullptr;
}
return message;
}
static Message* MutableCProtoInsidePyProtoImpl(PyObject* msg) {
Message* message = PyMessage_GetMutableMessagePointer(msg);
- if (message == NULL) {
+ if (message == nullptr) {
PyErr_Clear();
- return NULL;
+ return nullptr;
}
return message;
}
@@ -2788,7 +2776,7 @@ static Message* MutableCProtoInsidePyProtoImpl(PyObject* msg) {
const Message* PyMessage_GetMessagePointer(PyObject* msg) {
if (!PyObject_TypeCheck(msg, CMessage_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a Message instance");
- return NULL;
+ return nullptr;
}
CMessage* cmsg = reinterpret_cast<CMessage*>(msg);
return cmsg->message;
@@ -2797,7 +2785,7 @@ const Message* PyMessage_GetMessagePointer(PyObject* msg) {
Message* PyMessage_GetMutableMessagePointer(PyObject* msg) {
if (!PyObject_TypeCheck(msg, CMessage_Type)) {
PyErr_SetString(PyExc_TypeError, "Not a Message instance");
- return NULL;
+ return nullptr;
}
CMessage* cmsg = reinterpret_cast<CMessage*>(msg);
@@ -2811,7 +2799,7 @@ Message* PyMessage_GetMutableMessagePointer(PyObject* msg) {
PyErr_SetString(PyExc_ValueError,
"Cannot reliably get a mutable pointer "
"to a message with extra references");
- return NULL;
+ return nullptr;
}
cmessage::AssureWritable(cmsg);
return cmsg->message;
@@ -2884,8 +2872,8 @@ void InitGlobals() {
// also be freed and reset to NULL during finalization.
kDESCRIPTOR = PyUnicode_FromString("DESCRIPTOR");
- PyObject *dummy_obj = PySet_New(NULL);
- kEmptyWeakref = PyWeakref_NewRef(dummy_obj, NULL);
+ PyObject* dummy_obj = PySet_New(nullptr);
+ kEmptyWeakref = PyWeakref_NewRef(dummy_obj, nullptr);
Py_DECREF(dummy_obj);
}
@@ -2952,22 +2940,22 @@ bool InitProto2MessageModule(PyObject *m) {
// Register them as MutableSequence.
ScopedPyObjectPtr collections(PyImport_ImportModule("collections.abc"));
- if (collections == NULL) {
+ if (collections == nullptr) {
return false;
}
ScopedPyObjectPtr mutable_sequence(
PyObject_GetAttrString(collections.get(), "MutableSequence"));
- if (mutable_sequence == NULL) {
+ if (mutable_sequence == nullptr) {
return false;
}
if (ScopedPyObjectPtr(
PyObject_CallMethod(mutable_sequence.get(), "register", "O",
- &RepeatedScalarContainer_Type)) == NULL) {
+ &RepeatedScalarContainer_Type)) == nullptr) {
return false;
}
if (ScopedPyObjectPtr(
PyObject_CallMethod(mutable_sequence.get(), "register", "O",
- &RepeatedCompositeContainer_Type)) == NULL) {
+ &RepeatedCompositeContainer_Type)) == nullptr) {
return false;
}
}
@@ -3036,7 +3024,7 @@ bool InitProto2MessageModule(PyObject *m) {
PyObject* enum_type_wrapper = PyImport_ImportModule(
"google.protobuf.internal.enum_type_wrapper");
- if (enum_type_wrapper == NULL) {
+ if (enum_type_wrapper == nullptr) {
return false;
}
EnumTypeWrapper_class =
@@ -3045,7 +3033,7 @@ bool InitProto2MessageModule(PyObject *m) {
PyObject* message_module = PyImport_ImportModule(
"google.protobuf.message");
- if (message_module == NULL) {
+ if (message_module == nullptr) {
return false;
}
EncodeError_class = PyObject_GetAttrString(message_module, "EncodeError");
@@ -3054,7 +3042,7 @@ bool InitProto2MessageModule(PyObject *m) {
Py_DECREF(message_module);
PyObject* pickle_module = PyImport_ImportModule("pickle");
- if (pickle_module == NULL) {
+ if (pickle_module == nullptr) {
return false;
}
PickleError_class = PyObject_GetAttrString(pickle_module, "PickleError");
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message.h b/contrib/python/protobuf/py3/google/protobuf/pyext/message.h
index ca81a87521..28dbda6798 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message.h
@@ -34,6 +34,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <cstdint>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc
index 5483c56061..35d6214d7d 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc
@@ -30,6 +30,7 @@
#include <unordered_map>
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/dynamic_message.h>
@@ -38,12 +39,13 @@
#include <google/protobuf/pyext/message_factory.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#define PyString_AsStringAndSize(ob, charpp, sizep) \
- (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>( \
- PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
- ? -1 \
- : 0) \
- : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob) \
+ ? ((*(charpp) = const_cast<char*>( \
+ PyUnicode_AsUTF8AndSize(ob, (sizep)))) == nullptr \
+ ? -1 \
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
namespace google {
namespace protobuf {
@@ -54,8 +56,8 @@ namespace message_factory {
PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool) {
PyMessageFactory* factory = reinterpret_cast<PyMessageFactory*>(
PyType_GenericAlloc(type, 0));
- if (factory == NULL) {
- return NULL;
+ if (factory == nullptr) {
+ return nullptr;
}
DynamicMessageFactory* message_factory = new DynamicMessageFactory();
@@ -72,25 +74,25 @@ PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool)
}
PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
- static const char* kwlist[] = {"pool", 0};
- PyObject* pool = NULL;
+ static const char* kwlist[] = {"pool", nullptr};
+ PyObject* pool = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O",
const_cast<char**>(kwlist), &pool)) {
- return NULL;
+ return nullptr;
}
ScopedPyObjectPtr owned_pool;
- if (pool == NULL || pool == Py_None) {
+ if (pool == nullptr || pool == Py_None) {
owned_pool.reset(PyObject_CallFunction(
- reinterpret_cast<PyObject*>(&PyDescriptorPool_Type), NULL));
- if (owned_pool == NULL) {
- return NULL;
+ reinterpret_cast<PyObject*>(&PyDescriptorPool_Type), nullptr));
+ if (owned_pool == nullptr) {
+ return nullptr;
}
pool = owned_pool.get();
} else {
if (!PyObject_TypeCheck(pool, &PyDescriptorPool_Type)) {
PyErr_Format(PyExc_TypeError, "Expected a DescriptorPool, got %s",
pool->ob_type->tp_name);
- return NULL;
+ return nullptr;
}
}
@@ -164,8 +166,8 @@ CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
}
ScopedPyObjectPtr py_descriptor(
PyMessageDescriptor_FromDescriptor(descriptor));
- if (py_descriptor == NULL) {
- return NULL;
+ if (py_descriptor == nullptr) {
+ return nullptr;
}
// Create a new message class.
ScopedPyObjectPtr args(Py_BuildValue(
@@ -173,24 +175,24 @@ CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
"DESCRIPTOR", py_descriptor.get(),
"__module__", Py_None,
"message_factory", self));
- if (args == NULL) {
- return NULL;
+ if (args == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr message_class(PyObject_CallObject(
reinterpret_cast<PyObject*>(CMessageClass_Type), args.get()));
- if (message_class == NULL) {
- return NULL;
+ if (message_class == nullptr) {
+ return nullptr;
}
// Create messages class for the messages used by the fields, and registers
// all extensions for these messages during the recursion.
for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) {
const Descriptor* sub_descriptor =
descriptor->field(field_idx)->message_type();
- // It is NULL if the field type is not a message.
- if (sub_descriptor != NULL) {
+ // It is null if the field type is not a message.
+ if (sub_descriptor != nullptr) {
CMessageClass* result = GetOrCreateMessageClass(self, sub_descriptor);
- if (result == NULL) {
- return NULL;
+ if (result == nullptr) {
+ return nullptr;
}
Py_DECREF(result);
}
@@ -202,17 +204,17 @@ CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
ScopedPyObjectPtr py_extended_class(
GetOrCreateMessageClass(self, extension->containing_type())
->AsPyObject());
- if (py_extended_class == NULL) {
- return NULL;
+ if (py_extended_class == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr py_extension(PyFieldDescriptor_FromDescriptor(extension));
- if (py_extension == NULL) {
- return NULL;
+ if (py_extension == nullptr) {
+ return nullptr;
}
ScopedPyObjectPtr result(cmessage::RegisterExtension(
py_extended_class.get(), py_extension.get()));
- if (result == NULL) {
- return NULL;
+ if (result == nullptr) {
+ return nullptr;
}
}
return reinterpret_cast<CMessageClass*>(message_class.release());
@@ -226,14 +228,15 @@ CMessageClass* GetMessageClass(PyMessageFactory* self,
if (ret == self->classes_by_descriptor->end()) {
PyErr_Format(PyExc_TypeError, "No message class registered for '%s'",
message_descriptor->full_name().c_str());
- return NULL;
+ return nullptr;
} else {
return ret->second;
}
}
static PyMethodDef Methods[] = {
- {NULL}};
+ {nullptr},
+};
static PyObject* GetPool(PyMessageFactory* self, void* closure) {
Py_INCREF(self->pool);
@@ -241,8 +244,8 @@ static PyObject* GetPool(PyMessageFactory* self, void* closure) {
}
static PyGetSetDef Getters[] = {
- {"pool", (getter)GetPool, NULL, "DescriptorPool"},
- {NULL}
+ {"pool", (getter)GetPool, nullptr, "DescriptorPool"},
+ {nullptr},
};
} // namespace message_factory
@@ -253,38 +256,42 @@ PyTypeObject PyMessageFactory_Type = {
sizeof(PyMessageFactory), // tp_basicsize
0, // tp_itemsize
message_factory::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ nullptr, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, // tp_flags
"A static Message Factory", // tp_doc
message_factory::GcTraverse, // tp_traverse
message_factory::GcClear, // tp_clear
- 0, // tp_richcompare
+ nullptr, // tp_richcompare
0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
message_factory::Methods, // tp_methods
- 0, // tp_members
+ nullptr, // tp_members
message_factory::Getters, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
0, // tp_dictoffset
- 0, // tp_init
- 0, // tp_alloc
+ nullptr, // tp_init
+ nullptr, // tp_alloc
message_factory::New, // tp_new
PyObject_GC_Del, // tp_free
};
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h b/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h
index 515c29cdb8..7dfe425dd5 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_FACTORY_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_FACTORY_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <unordered_map>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc
index 971d2bad70..2d3c1d2087 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc
@@ -28,6 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <google/protobuf/message_lite.h>
@@ -93,28 +94,28 @@ static PyMethodDef ModuleMethods[] = {
(PyCFunction)google::protobuf::python::cmessage::SetAllowOversizeProtos, METH_O,
"Enable/disable oversize proto parsing."},
// DO NOT USE: For migration and testing only.
- {NULL, NULL}};
+ {nullptr, nullptr}};
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
"_message",
module_docstring,
-1,
ModuleMethods, /* m_methods */
- NULL,
- NULL,
- NULL,
- NULL};
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr};
PyMODINIT_FUNC PyInit__message() {
PyObject* m;
m = PyModule_Create(&_module);
- if (m == NULL) {
- return NULL;
+ if (m == nullptr) {
+ return nullptr;
}
if (!google::protobuf::python::InitProto2MessageModule(m)) {
Py_DECREF(m);
- return NULL;
+ return nullptr;
}
// Adds the C++ API
@@ -126,7 +127,7 @@ PyMODINIT_FUNC PyInit__message() {
})) {
PyModule_AddObject(m, "proto_API", api);
} else {
- return NULL;
+ return nullptr;
}
return m;
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.cc
index 2e8ff4b425..0b63f82256 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.cc
@@ -40,12 +40,12 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/message.h>
+#include <google/protobuf/reflection.h>
#include <google/protobuf/pyext/descriptor.h>
#include <google/protobuf/pyext/descriptor_pool.h>
#include <google/protobuf/pyext/message.h>
#include <google/protobuf/pyext/message_factory.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#include <google/protobuf/reflection.h>
#include <google/protobuf/stubs/map_util.h>
namespace google {
@@ -74,17 +74,15 @@ PyObject* Add(RepeatedCompositeContainer* self, PyObject* args,
if (cmessage::AssureWritable(self->parent) == -1) return nullptr;
Message* message = self->parent->message;
- Message* sub_message =
- message->GetReflection()->AddMessage(
- message,
- self->parent_field_descriptor,
- self->child_message_class->py_message_factory->message_factory);
+ Message* sub_message = message->GetReflection()->AddMessage(
+ message, self->parent_field_descriptor,
+ self->child_message_class->py_message_factory->message_factory);
CMessage* cmsg = self->parent->BuildSubMessageFromPointer(
self->parent_field_descriptor, sub_message, self->child_message_class);
if (cmessage::InitAttributes(cmsg, args, kwargs) < 0) {
- message->GetReflection()->RemoveLast(
- message, self->parent_field_descriptor);
+ message->GetReflection()->RemoveLast(message,
+ self->parent_field_descriptor);
Py_DECREF(cmsg);
return nullptr;
}
@@ -108,8 +106,7 @@ static PyObject* AddMessage(RepeatedCompositeContainer* self, PyObject* value) {
if (py_cmsg == nullptr) return nullptr;
CMessage* cmsg = reinterpret_cast<CMessage*>(py_cmsg);
if (ScopedPyObjectPtr(cmessage::MergeFrom(cmsg, value)) == nullptr) {
- reflection->RemoveLast(
- message, self->parent_field_descriptor);
+ reflection->RemoveLast(message, self->parent_field_descriptor);
Py_DECREF(cmsg);
return nullptr;
}
@@ -152,7 +149,7 @@ static PyObject* Insert(PyObject* pself, PyObject* args) {
Py_ssize_t end_index = index;
if (end_index < 0) end_index += length;
if (end_index < 0) end_index = 0;
- for (Py_ssize_t i = length; i > end_index; i --) {
+ for (Py_ssize_t i = length; i > end_index; i--) {
reflection->SwapElements(message, field_descriptor, i, i - 1);
}
@@ -268,8 +265,7 @@ static PyObject* SubscriptMethod(PyObject* self, PyObject* slice) {
return Subscript(reinterpret_cast<RepeatedCompositeContainer*>(self), slice);
}
-int AssignSubscript(RepeatedCompositeContainer* self,
- PyObject* slice,
+int AssignSubscript(RepeatedCompositeContainer* self, PyObject* slice,
PyObject* value) {
if (value != nullptr) {
PyErr_SetString(PyExc_TypeError, "does not support assignment");
@@ -368,27 +364,22 @@ static void ReorderAttached(RepeatedCompositeContainer* self,
const FieldDescriptor* descriptor = self->parent_field_descriptor;
const Py_ssize_t length = Length(reinterpret_cast<PyObject*>(self));
- // We need to rearrange things to match python's sort order. Because there
- // was already an O(n*log(n)) step in python and a bunch of reflection, we
- // expect an O(n**2) step in C++ won't hurt too much.
+ // We need to rearrange things to match python's sort order.
+ for (Py_ssize_t i = 0; i < length; ++i) {
+ reflection->UnsafeArenaReleaseLast(message, descriptor);
+ }
for (Py_ssize_t i = 0; i < length; ++i) {
Message* child_message =
reinterpret_cast<CMessage*>(PyList_GET_ITEM(child_list, i))->message;
- for (Py_ssize_t j = i; j < length; ++j) {
- if (child_message ==
- &reflection->GetRepeatedMessage(*message, descriptor, j)) {
- reflection->SwapElements(message, descriptor, i, j);
- break;
- }
- }
+ reflection->UnsafeArenaAddAllocatedMessage(message, descriptor,
+ child_message);
}
}
// Returns 0 if successful; returns -1 and sets an exception if
// unsuccessful.
-static int SortPythonMessages(RepeatedCompositeContainer* self,
- PyObject* args,
- PyObject* kwds) {
+static int SortPythonMessages(RepeatedCompositeContainer* self, PyObject* args,
+ PyObject* kwds) {
ScopedPyObjectPtr child_list(
PySequence_List(reinterpret_cast<PyObject*>(self)));
if (child_list == nullptr) {
@@ -486,9 +477,8 @@ PyObject* DeepCopy(PyObject* pself, PyObject* arg) {
}
// The private constructor of RepeatedCompositeContainer objects.
-RepeatedCompositeContainer *NewContainer(
- CMessage* parent,
- const FieldDescriptor* parent_field_descriptor,
+RepeatedCompositeContainer* NewContainer(
+ CMessage* parent, const FieldDescriptor* parent_field_descriptor,
CMessageClass* child_message_class) {
if (!CheckFieldBelongsToMessage(parent_field_descriptor, parent->message)) {
return nullptr;
@@ -525,9 +515,9 @@ static PySequenceMethods SqMethods = {
};
static PyMappingMethods MpMethods = {
- Length, /* mp_length */
- SubscriptMethod, /* mp_subscript */
- AssignSubscriptMethod, /* mp_ass_subscript */
+ Length, /* mp_length */
+ SubscriptMethod, /* mp_subscript */
+ AssignSubscriptMethod, /* mp_ass_subscript */
};
static PyMethodDef Methods[] = {
@@ -555,14 +545,14 @@ static PyMethodDef Methods[] = {
PyTypeObject RepeatedCompositeContainer_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
- ".RepeatedCompositeContainer", // tp_name
- sizeof(RepeatedCompositeContainer), // tp_basicsize
- 0, // tp_itemsize
- repeated_composite_container::Dealloc, // tp_dealloc
+ ".RepeatedCompositeContainer", // tp_name
+ sizeof(RepeatedCompositeContainer), // tp_basicsize
+ 0, // tp_itemsize
+ repeated_composite_container::Dealloc, // tp_dealloc
#if PY_VERSION_HEX >= 0x03080000
- 0, // tp_vectorcall_offset
+ 0, // tp_vectorcall_offset
#else
- nullptr, // tp_print
+ nullptr, // tp_print
#endif
nullptr, // tp_getattr
nullptr, // tp_setattr
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.h b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.h
index e241827ef5..30536eabd4 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.h
@@ -34,6 +34,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <memory>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.cc
index c7ebcbbf00..a9d96f03a0 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.cc
@@ -274,6 +274,11 @@ static PyObject* Subscript(PyObject* pself, PyObject* slice) {
bool return_list = false;
if (PyLong_Check(slice)) {
from = to = PyLong_AsLong(slice);
+ } else if (PyIndex_Check(slice)) {
+ from = to = PyNumber_AsSsize_t(slice, PyExc_ValueError);
+ if (from == -1 && PyErr_Occurred()) {
+ return nullptr;
+ }
} else if (PySlice_Check(slice)) {
length = Len(pself);
if (PySlice_GetIndicesEx(slice, length, &from, &to, &step, &slicelength) ==
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.h b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.h
index f9f0ea8f31..372b6f0a35 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.h
@@ -34,6 +34,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <memory>
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/scoped_pyobject_ptr.h b/contrib/python/protobuf/py3/google/protobuf/pyext/scoped_pyobject_ptr.h
index 6f7fc29813..ad3fa9462d 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/scoped_pyobject_ptr.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/scoped_pyobject_ptr.h
@@ -35,6 +35,7 @@
#include <google/protobuf/stubs/common.h>
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
namespace google {
namespace protobuf {
@@ -47,7 +48,7 @@ class ScopedPythonPtr {
public:
// Takes the ownership of the specified object to ScopedPythonPtr.
// The reference count of the specified py_object is not incremented.
- explicit ScopedPythonPtr(PyObjectStruct* py_object = NULL)
+ explicit ScopedPythonPtr(PyObjectStruct* py_object = nullptr)
: ptr_(py_object) {}
// If a PyObject is owned, decrement its reference count.
@@ -59,7 +60,7 @@ class ScopedPythonPtr {
// This function must be called with a reference that you own.
// this->reset(this->get()) is wrong!
// this->reset(this->release()) is OK.
- PyObjectStruct* reset(PyObjectStruct* p = NULL) {
+ PyObjectStruct* reset(PyObjectStruct* p = nullptr) {
Py_XDECREF(ptr_);
ptr_ = p;
return ptr_;
@@ -69,7 +70,7 @@ class ScopedPythonPtr {
// The caller now owns the returned reference.
PyObjectStruct* release() {
PyObject* p = ptr_;
- ptr_ = NULL;
+ ptr_ = nullptr;
return p;
}
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc
index 7f4fb23edf..dcd63b2e29 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc
@@ -30,6 +30,7 @@
#include <google/protobuf/pyext/unknown_fields.h>
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <set>
#include <memory>
@@ -49,7 +50,7 @@ namespace unknown_fields {
static Py_ssize_t Len(PyObject* pself) {
PyUnknownFields* self =
reinterpret_cast<PyUnknownFields*>(pself);
- if (self->fields == NULL) {
+ if (self->fields == nullptr) {
PyErr_Format(PyExc_ValueError,
"UnknownFields does not exist. "
"The parent message might be cleared.");
@@ -64,7 +65,7 @@ void Clear(PyUnknownFields* self) {
it != self->sub_unknown_fields.end(); it++) {
Clear(*it);
}
- self->fields = NULL;
+ self->fields = nullptr;
self->sub_unknown_fields.clear();
}
@@ -74,11 +75,11 @@ PyObject* NewPyUnknownFieldRef(PyUnknownFields* parent,
static PyObject* Item(PyObject* pself, Py_ssize_t index) {
PyUnknownFields* self =
reinterpret_cast<PyUnknownFields*>(pself);
- if (self->fields == NULL) {
+ if (self->fields == nullptr) {
PyErr_Format(PyExc_ValueError,
"UnknownFields does not exist. "
"The parent message might be cleared.");
- return NULL;
+ return nullptr;
}
Py_ssize_t total_size = self->fields->field_count();
if (index < 0) {
@@ -88,7 +89,7 @@ static PyObject* Item(PyObject* pself, Py_ssize_t index) {
PyErr_Format(PyExc_IndexError,
"index (%zd) out of range",
index);
- return NULL;
+ return nullptr;
}
return unknown_fields::NewPyUnknownFieldRef(self, index);
@@ -97,8 +98,8 @@ static PyObject* Item(PyObject* pself, Py_ssize_t index) {
PyObject* NewPyUnknownFields(CMessage* c_message) {
PyUnknownFields* self = reinterpret_cast<PyUnknownFields*>(
PyType_GenericAlloc(&PyUnknownFields_Type, 0));
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
// Call "placement new" to initialize PyUnknownFields.
new (self) PyUnknownFields;
@@ -116,8 +117,8 @@ PyObject* NewPyUnknownFieldRef(PyUnknownFields* parent,
Py_ssize_t index) {
PyUnknownFieldRef* self = reinterpret_cast<PyUnknownFieldRef*>(
PyType_GenericAlloc(&PyUnknownFieldRef_Type, 0));
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
Py_INCREF(parent);
@@ -137,58 +138,63 @@ static void Dealloc(PyObject* pself) {
reinterpret_cast<CMessage*>(self->parent)->unknown_field_set = nullptr;
}
Py_CLEAR(self->parent);
+ auto* py_type = Py_TYPE(pself);
self->~PyUnknownFields();
- Py_TYPE(pself)->tp_free(pself);
+ py_type->tp_free(pself);
}
static PySequenceMethods SqMethods = {
- Len, /* sq_length */
- 0, /* sq_concat */
- 0, /* sq_repeat */
- Item, /* sq_item */
- 0, /* sq_slice */
- 0, /* sq_ass_item */
+ Len, /* sq_length */
+ nullptr, /* sq_concat */
+ nullptr, /* sq_repeat */
+ Item, /* sq_item */
+ nullptr, /* sq_slice */
+ nullptr, /* sq_ass_item */
};
} // namespace unknown_fields
PyTypeObject PyUnknownFields_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".PyUnknownFields", // tp_name
- sizeof(PyUnknownFields), // tp_basicsize
- 0, // tp_itemsize
- unknown_fields::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- &unknown_fields::SqMethods, // tp_as_sequence
- 0, // tp_as_mapping
- PyObject_HashNotImplemented, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "unknown field set", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
- 0, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".PyUnknownFields", // tp_name
+ sizeof(PyUnknownFields), // tp_basicsize
+ 0, // tp_itemsize
+ unknown_fields::Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ &unknown_fields::SqMethods, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ PyObject_HashNotImplemented, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "unknown field set", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
+ nullptr, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
};
namespace unknown_field {
@@ -196,8 +202,8 @@ static PyObject* PyUnknownFields_FromUnknownFieldSet(
PyUnknownFields* parent, const UnknownFieldSet& fields) {
PyUnknownFields* self = reinterpret_cast<PyUnknownFields*>(
PyType_GenericAlloc(&PyUnknownFields_Type, 0));
- if (self == NULL) {
- return NULL;
+ if (self == nullptr) {
+ return nullptr;
}
// Call "placement new" to initialize PyUnknownFields.
new (self) PyUnknownFields;
@@ -212,26 +218,26 @@ static PyObject* PyUnknownFields_FromUnknownFieldSet(
const UnknownField* GetUnknownField(PyUnknownFieldRef* self) {
const UnknownFieldSet* fields = self->parent->fields;
- if (fields == NULL) {
+ if (fields == nullptr) {
PyErr_Format(PyExc_ValueError,
"UnknownField does not exist. "
"The parent message might be cleared.");
- return NULL;
+ return nullptr;
}
- ssize_t total_size = fields->field_count();
+ Py_ssize_t total_size = fields->field_count();
if (self->index >= total_size) {
PyErr_Format(PyExc_ValueError,
"UnknownField does not exist. "
"The parent message might be cleared.");
- return NULL;
+ return nullptr;
}
return &fields->field(self->index);
}
static PyObject* GetFieldNumber(PyUnknownFieldRef* self, void *closure) {
const UnknownField* unknown_field = GetUnknownField(self);
- if (unknown_field == NULL) {
- return NULL;
+ if (unknown_field == nullptr) {
+ return nullptr;
}
return PyLong_FromLong(unknown_field->number());
}
@@ -239,8 +245,8 @@ static PyObject* GetFieldNumber(PyUnknownFieldRef* self, void *closure) {
using internal::WireFormatLite;
static PyObject* GetWireType(PyUnknownFieldRef* self, void *closure) {
const UnknownField* unknown_field = GetUnknownField(self);
- if (unknown_field == NULL) {
- return NULL;
+ if (unknown_field == nullptr) {
+ return nullptr;
}
// Assign a default value to suppress may-uninitialized warnings (errors
@@ -268,19 +274,19 @@ static PyObject* GetWireType(PyUnknownFieldRef* self, void *closure) {
static PyObject* GetData(PyUnknownFieldRef* self, void *closure) {
const UnknownField* field = GetUnknownField(self);
- if (field == NULL) {
- return NULL;
+ if (field == nullptr) {
+ return nullptr;
}
- PyObject* data = NULL;
+ PyObject* data = nullptr;
switch (field->type()) {
case UnknownField::TYPE_VARINT:
- data = PyLong_FromLong(field->varint());
+ data = PyLong_FromUnsignedLongLong(field->varint());
break;
case UnknownField::TYPE_FIXED32:
- data = PyLong_FromLong(field->fixed32());
+ data = PyLong_FromUnsignedLong(field->fixed32());
break;
case UnknownField::TYPE_FIXED64:
- data = PyLong_FromLong(field->fixed64());
+ data = PyLong_FromUnsignedLongLong(field->fixed64());
break;
case UnknownField::TYPE_LENGTH_DELIMITED:
data = PyBytes_FromStringAndSize(field->length_delimited().data(),
@@ -301,54 +307,57 @@ static void Dealloc(PyObject* pself) {
}
static PyGetSetDef Getters[] = {
- {"field_number", (getter)GetFieldNumber, NULL},
- {"wire_type", (getter)GetWireType, NULL},
- {"data", (getter)GetData, NULL},
- {NULL}
+ {"field_number", (getter)GetFieldNumber, nullptr},
+ {"wire_type", (getter)GetWireType, nullptr},
+ {"data", (getter)GetData, nullptr},
+ {nullptr},
};
} // namespace unknown_field
PyTypeObject PyUnknownFieldRef_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- FULL_MODULE_NAME ".PyUnknownFieldRef", // tp_name
- sizeof(PyUnknownFieldRef), // tp_basicsize
- 0, // tp_itemsize
- unknown_field::Dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- 0, // tp_repr
- 0, // tp_as_number
- 0, // tp_as_sequence
- 0, // tp_as_mapping
- PyObject_HashNotImplemented, // tp_hash
- 0, // tp_call
- 0, // tp_str
- 0, // tp_getattro
- 0, // tp_setattro
- 0, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "unknown field", // tp_doc
- 0, // tp_traverse
- 0, // tp_clear
- 0, // tp_richcompare
- 0, // tp_weaklistoffset
- 0, // tp_iter
- 0, // tp_iternext
- 0, // tp_methods
- 0, // tp_members
- unknown_field::Getters, // tp_getset
- 0, // tp_base
- 0, // tp_dict
- 0, // tp_descr_get
- 0, // tp_descr_set
- 0, // tp_dictoffset
- 0, // tp_init
+ PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
+ ".PyUnknownFieldRef", // tp_name
+ sizeof(PyUnknownFieldRef), // tp_basicsize
+ 0, // tp_itemsize
+ unknown_field::Dealloc, // tp_dealloc
+#if PY_VERSION_HEX < 0x03080000
+ nullptr, // tp_print
+#else
+ 0, // tp_vectorcall_offset
+#endif
+ nullptr, // tp_getattr
+ nullptr, // tp_setattr
+ nullptr, // tp_compare
+ nullptr, // tp_repr
+ nullptr, // tp_as_number
+ nullptr, // tp_as_sequence
+ nullptr, // tp_as_mapping
+ PyObject_HashNotImplemented, // tp_hash
+ nullptr, // tp_call
+ nullptr, // tp_str
+ nullptr, // tp_getattro
+ nullptr, // tp_setattro
+ nullptr, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "unknown field", // tp_doc
+ nullptr, // tp_traverse
+ nullptr, // tp_clear
+ nullptr, // tp_richcompare
+ 0, // tp_weaklistoffset
+ nullptr, // tp_iter
+ nullptr, // tp_iternext
+ nullptr, // tp_methods
+ nullptr, // tp_members
+ unknown_field::Getters, // tp_getset
+ nullptr, // tp_base
+ nullptr, // tp_dict
+ nullptr, // tp_descr_get
+ nullptr, // tp_descr_set
+ 0, // tp_dictoffset
+ nullptr, // tp_init
};
-
} // namespace python
} // namespace protobuf
} // namespace google
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h
index 94d55e148d..e7b0b35c41 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h
@@ -31,6 +31,7 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELDS_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELDS_H__
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <memory>
diff --git a/contrib/python/protobuf/py3/google/protobuf/service_reflection.py b/contrib/python/protobuf/py3/google/protobuf/service_reflection.py
index 75c51ff322..f82ab7145a 100644
--- a/contrib/python/protobuf/py3/google/protobuf/service_reflection.py
+++ b/contrib/python/protobuf/py3/google/protobuf/service_reflection.py
@@ -133,7 +133,7 @@ class _ServiceBuilder(object):
"""
self.descriptor = service_descriptor
- def BuildService(self, cls):
+ def BuildService(builder, cls):
"""Constructs the service class.
Args:
@@ -143,18 +143,26 @@ class _ServiceBuilder(object):
# CallMethod needs to operate with an instance of the Service class. This
# internal wrapper function exists only to be able to pass the service
# instance to the method that does the real CallMethod work.
- def _WrapCallMethod(srvc, method_descriptor,
- rpc_controller, request, callback):
- return self._CallMethod(srvc, method_descriptor,
- rpc_controller, request, callback)
- self.cls = cls
+ # Making sure to use exact argument names from the abstract interface in
+ # service.py to match the type signature
+ def _WrapCallMethod(self, method_descriptor, rpc_controller, request, done):
+ return builder._CallMethod(self, method_descriptor, rpc_controller,
+ request, done)
+
+ def _WrapGetRequestClass(self, method_descriptor):
+ return builder._GetRequestClass(method_descriptor)
+
+ def _WrapGetResponseClass(self, method_descriptor):
+ return builder._GetResponseClass(method_descriptor)
+
+ builder.cls = cls
cls.CallMethod = _WrapCallMethod
- cls.GetDescriptor = staticmethod(lambda: self.descriptor)
- cls.GetDescriptor.__doc__ = "Returns the service descriptor."
- cls.GetRequestClass = self._GetRequestClass
- cls.GetResponseClass = self._GetResponseClass
- for method in self.descriptor.methods:
- setattr(cls, method.name, self._GenerateNonImplementedMethod(method))
+ cls.GetDescriptor = staticmethod(lambda: builder.descriptor)
+ cls.GetDescriptor.__doc__ = 'Returns the service descriptor.'
+ cls.GetRequestClass = _WrapGetRequestClass
+ cls.GetResponseClass = _WrapGetResponseClass
+ for method in builder.descriptor.methods:
+ setattr(cls, method.name, builder._GenerateNonImplementedMethod(method))
def _CallMethod(self, srvc, method_descriptor,
rpc_controller, request, callback):
diff --git a/contrib/python/protobuf/py3/ya.make b/contrib/python/protobuf/py3/ya.make
index 7850737cdc..93b23a6f9b 100644
--- a/contrib/python/protobuf/py3/ya.make
+++ b/contrib/python/protobuf/py3/ya.make
@@ -9,9 +9,9 @@ LICENSE(
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-VERSION(3.19.0)
+VERSION(3.20.3)
-ORIGINAL_SOURCE(mirror://pypi/p/protobuf/protobuf-3.19.0.tar.gz)
+ORIGINAL_SOURCE(mirror://pypi/p/protobuf/protobuf-3.20.3.tar.gz)
PEERDIR(
contrib/libs/protobuf
@@ -64,6 +64,7 @@ PY_SRCS(
google/protobuf/descriptor_pool.py
google/protobuf/internal/__init__.py
google/protobuf/internal/api_implementation.py
+ google/protobuf/internal/builder.py
google/protobuf/internal/containers.py
google/protobuf/internal/decoder.py
google/protobuf/internal/encoder.py
diff --git a/contrib/tools/protoc/ya.make.induced_deps b/contrib/tools/protoc/ya.make.induced_deps
index 55ede44772..3d70a8bf3f 100644
--- a/contrib/tools/protoc/ya.make.induced_deps
+++ b/contrib/tools/protoc/ya.make.induced_deps
@@ -11,10 +11,10 @@ INDUCED_DEPS(cpp
INDUCED_DEPS(h+cpp
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/arena.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/arenastring.h
+ ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/extension_set.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h
- ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/map.h